Make things in contrib directory installable.
[muse-el.git] / examples / mwolson / muse-init.el
blob110929f65f43fa8cc87197f05917cfe06f85e823
1 ;;; muse-init.el --- Initialize Emacs Muse
3 ;; Author: Michael Olson
5 ;; In order to see the scripts that I use to publish my website to a
6 ;; remote webserver, check out
7 ;; http://www.mwolson.org/projects/SiteScripts.html.
9 ;;; Setup
11 ;; Add to load path
12 (add-to-list 'load-path "/home/mwolson/proj/emacs/muse/mwolson/lisp")
13 (add-to-list 'load-path "/home/mwolson/proj/emacs/muse/mwolson/experimental")
15 ;; Initialize
16 (require 'outline) ; I like outline-style faces
17 (require 'muse) ; load generic module
18 (require 'muse-colors) ; load coloring/font-lock module
19 (require 'muse-mode) ; load authoring mode
20 (require 'muse-blosxom) ; load blosxom module
21 (require 'muse-docbook) ; load DocBook publishing style
22 (require 'muse-html) ; load (X)HTML publishing style
23 (require 'muse-latex) ; load LaTeX/PDF publishing styles
24 (require 'muse-texinfo) ; load Info publishing style
25 (require 'muse-wiki) ; load Wiki support
26 (require 'muse-xml) ; load XML support
27 ;;(require 'muse-message) ; load message support (experimental)
29 ;; Setup projects
31 ;; Here is an example of making a customized version of your favorite
32 ;; publisher. All this does is run `my-muse-blosoxm-finalize' on the
33 ;; published file immediately after saving it.
35 (unless (assoc "my-blosxom" muse-publishing-styles)
36 (muse-derive-style "my-blosxom" "blosxom-xhtml"
37 :final 'my-muse-blosxom-finalize)
39 (muse-derive-style "my-pdf" "pdf"
40 :before 'my-muse-pdf-prepare-buffer)
42 (muse-derive-style "my-xhtml" "xhtml"
43 :header "~/personal-site/muse/header.html"
44 :footer "~/personal-site/muse/footer.html"))
46 ;; Here is my master project listing.
48 (setq muse-project-alist
50 ("Website" ("~/proj/wiki/web/"
51 :force-publish ("WikiIndex")
52 :default "WelcomePage")
53 (:base "my-xhtml"
54 :path "~/personal-site/site/web")
55 (:base "my-pdf"
56 :path "~/personal-site/site/web"
57 :include "/CurriculumVitae[^/]*$"))
59 ("Projects" ("~/proj/wiki/projects/"
60 :force-publish ("WikiIndex")
61 :default "WelcomePage")
62 (:base "my-xhtml"
63 :path "~/personal-site/site/projects"))
65 ("Blog" (,@(muse-project-alist-dirs "~/proj/wiki/blog")
66 :default "index")
68 ;; Publish this directory and its subdirectories. Arguments
69 ;; are as follows. The above `muse-project-alist-dirs' part
70 ;; is also needed, using Argument 1.
72 ;; 1. Source directory
73 ;; 2. Output directory
74 ;; 3. Publishing style
75 ,@(muse-project-alist-styles "~/proj/wiki/blog"
76 "~/personal-site/site/blog"
77 "my-blosxom"))
79 ("MyNotes" ("~/proj/wiki/notes/"
80 :force-publish ("index")
81 :default "index")
82 (:base "xhtml"
83 :path "~/personal-site/site/notes")
84 (:base "my-pdf"
85 :path "~/personal-site/site/notes"))
87 ("Private" ("~/Documents" "~/Documents/work-school"
88 :default "movielist")
89 ,@(muse-project-alist-styles "~/Documents"
90 "~/Documents"
91 "pdf"))
93 ("Classes" (,@(muse-project-alist-dirs "~/proj/wiki/classes")
94 :default "index")
95 ,@(muse-project-alist-styles "~/proj/wiki/classes"
96 "~/personal-site/site/classes"
97 "xhtml"))
99 ("Plans" ("~/proj/wiki/plans/"
100 :default "TaskPool"
101 :major-mode planner-mode
102 :visit-link planner-visit-link)
103 (:base "planner-xhtml"
104 :path "~/proj/notmine/planner-out"))
107 ;; Wiki settings
108 (setq muse-wiki-interwiki-alist
109 '(("PlugWiki" . "http://plug.student-orgs.purdue.edu/wiki/")
110 ("EmacsWiki" . "http://www.emacswiki.org/cgi-bin/wiki/")
111 ("ArchWiki" . "http://wiki.gnuarch.org/")
112 ;; abbreviations
113 ("CERIAS" . "http://www.cerias.purdue.edu/")
114 ("PlannerMode" . "http://www.plannerlove.com/")
115 ("GP2X" . "http://www.gp2x.co.uk/")
116 ("UbuntuLinux" . "http://ubuntulinux.org/")
117 ("PLUG" . "http://plug.student-orgs.purdue.edu/wiki/")))
119 ;;; Functions
121 ;; Turn relative links into absolute ones
122 (defun my-muse-pdf-make-links-absolute (str &rest ignored)
123 "Make relative links absolute."
124 (when str
125 (save-match-data
126 (if (string-match "\\`[/.]+" str)
127 (replace-match "http://www.mwolson.org/" nil t str)
128 str))))
130 ;; Make sure my interproject links become absolute when published in
131 ;; PDFs
132 (defun my-muse-pdf-prepare-buffer ()
133 (set (make-local-variable 'muse-publish-url-transforms)
134 (cons 'my-muse-pdf-make-links-absolute muse-publish-url-transforms)))
136 ;; Switch to the given project and prompt for a file
137 (defun my-muse-project-find-file (project)
138 (interactive)
139 (let ((muse-current-project (muse-project project)))
140 (call-interactively 'muse-project-find-file)))
142 ;; Determine whether we are publishing a certain kind of output
143 (defsubst my-muse-format-p (format)
144 (let ((base (muse-get-keyword :base muse-publishing-current-style)))
145 (when base (string-match format base))))
147 (defun my-muse-blosxom-finalize (file output-path target)
148 ;; (my-muse-prepare-entry-for-xanga output-path)
149 ;; For now, do nothing.
152 ;; Make the current file display correctly in Xanga
153 ;; I call this using C-c p x now.
154 (defun my-muse-prepare-entry-for-xanga (file)
155 "Mangle FILE so that Xanga doesn't bug out, saving to X clipboard.
157 If FILE is not specified, use the published version of the current file."
158 (interactive
159 (list
160 (expand-file-name (concat (muse-page-name) muse-blosxom-extension)
161 (muse-style-element
162 :path (car (muse-project-applicable-styles
163 buffer-file-name
164 (cddr (muse-project-of-file))))))))
165 (save-match-data
166 (muse-with-temp-buffer
167 (insert-file-contents file)
168 ;; surround first line in <h3></h3>
169 (goto-char (point-min))
170 (insert "<h3>")
171 (end-of-line)
172 (insert "</h3>")
173 ;; treat example regions properly
174 (let (beg end)
175 (while (re-search-forward "<pre[^>]*>" nil t)
176 (setq beg (match-end 0))
177 (setq end (if (re-search-forward "</pre>" nil 1)
178 (match-beginning 0)
179 (point)))
180 (save-restriction
181 (narrow-to-region beg end)
182 ;; change initial spaces to &nbsp;
183 (goto-char (point-min))
184 (while (re-search-forward "^ +" nil t)
185 (replace-match (apply 'concat (make-list
186 (length (match-string 0))
187 "&nbsp;"))))
188 ;; change newline to <br />
189 (goto-char (point-min))
190 (while (re-search-forward "\n" nil t)
191 (replace-match "<br />")))))
192 ;; get rid of 2 spaces together and merge lines
193 (goto-char (point-min))
194 (while (re-search-forward (concat "[" muse-regexp-blank "\n]+") nil t)
195 (replace-match " "))
196 ;; remove trailing space
197 (goto-char (point-min))
198 (while (re-search-forward " *</p> *" nil t)
199 (replace-match "</p>"))
200 ;; make relative links work
201 (goto-char (point-min))
202 (while (re-search-forward "href=\"[/.]+" nil t)
203 (replace-match "href=\"http://www.mwolson.org/" nil t))
204 ;; copy entry to clipboard
205 (clipboard-kill-ring-save (point-min) (point-max)))))
207 ;;; Key customizations
209 (global-set-key "\C-cpl" 'muse-blosxom-new-entry)
210 (global-set-key "\C-cpL" #'(lambda () (interactive)
211 (my-muse-project-find-file "Blog")))
212 (global-set-key "\C-cpi" #'(lambda () (interactive)
213 (my-muse-project-find-file "Private")))
214 (global-set-key "\C-cpn" #'(lambda () (interactive)
215 (my-muse-project-find-file "MyNotes")))
216 (global-set-key "\C-cpp" #'(lambda () (interactive)
217 (my-muse-project-find-file "Plans")))
218 (global-set-key "\C-cpr" #'(lambda () (interactive)
219 (my-muse-project-find-file "Projects")))
220 (global-set-key "\C-cps" #'(lambda () (interactive)
221 (my-muse-project-find-file "Classes")))
222 (global-set-key "\C-cpw" #'(lambda () (interactive)
223 (my-muse-project-find-file "Website")))
224 (global-set-key "\C-cpx" 'my-muse-prepare-entry-for-xanga)
226 ;;; Custom variables
228 (custom-set-variables
229 '(muse-blosxom-base-directory "~/proj/wiki/blog/")
230 '(muse-colors-autogen-headings (quote outline))
231 '(muse-colors-inline-image-method (quote muse-colors-use-publishing-directory))
232 '(muse-file-extension "muse")
233 '(muse-html-charset-default "utf-8")
234 '(muse-html-encoding-default (quote utf-8))
235 '(muse-html-footer "~/personal-site/muse/generic-footer.html")
236 '(muse-html-header "~/personal-site/muse/generic-header.html")
237 '(muse-html-meta-content-encoding (quote utf-8))
238 '(muse-html-style-sheet "<link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"all\" href=\"/common.css\" />
239 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"screen\" href=\"/screen.css\" />
240 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"print\" href=\"/print.css\" />")
241 '(muse-latex-header "~/personal-site/muse/header.tex")
242 '(muse-mode-auto-p nil nil (muse-project))
243 '(muse-mode-highlight-p t nil (muse-colors))
244 '(muse-mode-hook (quote (flyspell-mode footnote-mode)))
245 '(muse-publish-comments-p t)
246 '(muse-publish-desc-transforms (quote (muse-wiki-publish-pretty-title muse-wiki-publish-pretty-interwiki)))
247 '(muse-wiki-publish-small-title-words (quote ("the" "and" "at" "on" "of" "for" "in" "an" "a" "page")))
248 '(muse-xhtml-footer "~/personal-site/muse/generic-footer.html")
249 '(muse-xhtml-header "~/personal-site/muse/generic-header.html"))
250 (custom-set-faces
251 '(muse-bad-link ((t (:foreground "DeepPink" :underline "DeepPink" :weight bold))))
252 '(muse-link ((t (:foreground "blue" :underline "blue" :weight bold)))))
254 ;;; muse-init.el ends here