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.
12 (when (fboundp 'debian-pkg-add-load-path-item
)
13 (debian-pkg-add-load-path-item "/stuff/proj/emacs/muse/rel--3.02/lisp")
14 (debian-pkg-add-load-path-item "/stuff/proj/emacs/muse/rel--3.02/experimental"))
17 (require 'outline
) ; I like outline-style faces
18 (require 'muse
) ; load generic module
19 (require 'muse-colors
) ; load coloring/font-lock module
20 (require 'muse-mode
) ; load authoring mode
21 (require 'muse-blosxom
) ; load blosxom module
22 (require 'muse-docbook
) ; load DocBook publishing style
23 (require 'muse-html
) ; load (X)HTML publishing style
24 (require 'muse-latex
) ; load LaTeX/PDF publishing styles
25 (require 'muse-texinfo
) ; load Info publishing style
26 (require 'muse-wiki
) ; load Wiki support
27 (require 'muse-xml
) ; load XML support
28 ;;(require 'muse-message) ; load message support (experimental)
32 ;; Here is an example of making a customized version of your favorite
33 ;; publisher. All this does is run `my-muse-blosoxm-finalize' on the
34 ;; published file immediately after saving it.
36 (unless (assoc "my-blosxom" muse-publishing-styles
)
37 (muse-derive-style "my-blosxom" "blosxom-xhtml"
38 :final
'my-muse-blosxom-finalize
)
40 (muse-derive-style "my-pdf" "pdf"
41 :before
'my-muse-pdf-prepare-buffer
)
43 (muse-derive-style "my-xhtml" "xhtml"
44 :header
"~/personal-site/muse/header.html"
45 :footer
"~/personal-site/muse/footer.html"))
47 ;; Here is my master project listing.
49 (setq muse-project-alist
51 ("Website" ("~/proj/wiki/web/"
52 :force-publish
("WikiIndex")
53 :default
"WelcomePage")
55 :path
"~/personal-site/site/web")
57 :path
"~/personal-site/site/web"
58 :include
"/CurriculumVitae[^/]*$"))
60 ("Projects" ("~/proj/wiki/projects/"
61 :force-publish
("WikiIndex")
62 :default
"WelcomePage")
64 :path
"~/personal-site/site/projects"))
66 ("Blog" (,@(muse-project-alist-dirs "~/proj/wiki/blog")
69 ;; Publish this directory and its subdirectories. Arguments
70 ;; are as follows. The above `muse-project-alist-dirs' part
71 ;; is also needed, using Argument 1.
73 ;; 1. Source directory
74 ;; 2. Output directory
75 ;; 3. Publishing style
76 ,@(muse-project-alist-styles "~/proj/wiki/blog"
77 "~/personal-site/site/blog"
80 ("MyNotes" ("~/proj/wiki/notes/"
81 :force-publish
("index")
84 :path
"~/personal-site/site/notes")
86 :path
"~/personal-site/site/notes"))
88 ("Private" ("~/Documents" "~/Documents/work-school"
90 ,@(muse-project-alist-styles "~/Documents"
94 ("Classes" (,@(muse-project-alist-dirs "~/proj/wiki/classes")
96 ,@(muse-project-alist-styles "~/proj/wiki/classes"
97 "~/personal-site/site/classes"
100 ("Plans" ("~/proj/wiki/plans/"
102 :major-mode planner-mode
103 :visit-link planner-visit-link
)
104 (:base
"planner-xhtml"
105 :path
"~/proj/notmine/planner-out"))
109 (setq muse-wiki-interwiki-alist
110 '(("PlugWiki" .
"http://plug.student-orgs.purdue.edu/wiki/")
111 ("TheEmacsWiki" .
"http://www.emacswiki.org/cgi-bin/wiki/")
112 ("ArchWiki" .
"http://wiki.gnuarch.org/")
114 ("CERIAS" .
"http://www.cerias.purdue.edu/")
115 ("Planner" .
"http://www.plannerlove.com/")
116 ("GP2X" .
"http://www.gp2x.co.uk/")
117 ("PLUG" .
"http://plug.student-orgs.purdue.edu/wiki/")))
121 ;; Turn relative links into absolute ones
122 (defun my-muse-pdf-make-links-absolute (str &rest ignored
)
123 "Make relative links absolute."
126 (if (string-match "\\`[/.]+" str
)
127 (replace-match "http://www.mwolson.org/" nil t str
)
130 ;; Make sure my interproject links become absolute when published in
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)
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."
160 (expand-file-name (concat (muse-page-name) muse-blosxom-extension
)
162 :path
(car (muse-project-applicable-styles
164 (cddr (muse-project-of-file))))))))
166 (muse-with-temp-buffer
167 (insert-file-contents file
)
168 ;; Surround first line in <h3></h3>
169 (goto-char (point-min))
173 ;; Treat example regions properly
175 (while (re-search-forward "<pre[^>]*>" nil t
)
176 (setq beg
(match-end 0))
177 (setq end
(if (re-search-forward "</pre>" nil
1)
181 (narrow-to-region beg end
)
182 ;; Change spaces to
183 (goto-char (point-min))
184 (while (re-search-forward "^ +" nil t
)
185 (replace-match (apply 'concat
(make-list
186 (length (match-string 0))
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
)
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
)
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 (muse-wiki-update-custom-values 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"))
251 '(muse-bad-link-face ((t (:foreground
"DeepPink" :underline
"DeepPink" :weight bold
))))
252 '(muse-link-face ((t (:foreground
"blue" :underline
"blue" :weight bold
)))))
254 ;;; muse-init.el ends here