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 (add-to-list 'load-path
"/stuff/proj/emacs/muse/mwolson/lisp")
13 (add-to-list 'load-path
"/stuff/proj/emacs/muse/mwolson/experimental")
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)
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")
54 :path
"~/personal-site/site/web")
56 :path
"~/personal-site/site/web"
57 :include
"/CurriculumVitae[^/]*$"))
59 ("Projects" ("~/proj/wiki/projects/"
60 :force-publish
("WikiIndex")
61 :default
"WelcomePage")
63 :path
"~/personal-site/site/projects"))
65 ("Blog" (,@(muse-project-alist-dirs "~/proj/wiki/blog")
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"
79 ("MyNotes" ("~/proj/wiki/notes/"
80 :force-publish
("index")
83 :path
"~/personal-site/site/notes")
85 :path
"~/personal-site/site/notes"))
87 ("Private" ("~/Documents" "~/Documents/work-school"
89 ,@(muse-project-alist-styles "~/Documents"
93 ("Classes" (,@(muse-project-alist-dirs "~/proj/wiki/classes")
95 ,@(muse-project-alist-styles "~/proj/wiki/classes"
96 "~/personal-site/site/classes"
99 ("Plans" ("~/proj/wiki/plans/"
101 :major-mode planner-mode
102 :visit-link planner-visit-link
)
103 (:base
"planner-xhtml"
104 :path
"~/proj/notmine/planner-out"))
108 (setq muse-wiki-interwiki-alist
109 '(("PlugWiki" .
"http://plug.student-orgs.purdue.edu/wiki/")
110 ("TheEmacsWiki" .
"http://www.emacswiki.org/cgi-bin/wiki/")
111 ("ArchWiki" .
"http://wiki.gnuarch.org/")
113 ("CERIAS" .
"http://www.cerias.purdue.edu/")
114 ("Planner" .
"http://www.plannerlove.com/")
115 ("GP2X" .
"http://www.gp2x.co.uk/")
116 ("PLUG" .
"http://plug.student-orgs.purdue.edu/wiki/")))
120 ;; Turn relative links into absolute ones
121 (defun my-muse-pdf-make-links-absolute (str &rest ignored
)
122 "Make relative links absolute."
125 (if (string-match "\\`[/.]+" str
)
126 (replace-match "http://www.mwolson.org/" nil t str
)
129 ;; Make sure my interproject links become absolute when published in
131 (defun my-muse-pdf-prepare-buffer ()
132 (set (make-local-variable 'muse-publish-url-transforms
)
133 (cons 'my-muse-pdf-make-links-absolute muse-publish-url-transforms
)))
135 ;; Switch to the given project and prompt for a file
136 (defun my-muse-project-find-file (project)
138 (let ((muse-current-project (muse-project project
)))
139 (call-interactively 'muse-project-find-file
)))
141 ;; Determine whether we are publishing a certain kind of output
142 (defsubst my-muse-format-p
(format)
143 (let ((base (muse-get-keyword :base muse-publishing-current-style
)))
144 (when base
(string-match format base
))))
146 (defun my-muse-blosxom-finalize (file output-path target
)
147 ;; (my-muse-prepare-entry-for-xanga output-path)
148 ;; For now, do nothing.
151 ;; Make the current file display correctly in Xanga
152 ;; I call this using C-c p x now.
153 (defun my-muse-prepare-entry-for-xanga (file)
154 "Mangle FILE so that Xanga doesn't bug out, saving to X clipboard.
156 If FILE is not specified, use the published version of the current file."
159 (expand-file-name (concat (muse-page-name) muse-blosxom-extension
)
161 :path
(car (muse-project-applicable-styles
163 (cddr (muse-project-of-file))))))))
165 (muse-with-temp-buffer
166 (insert-file-contents file
)
167 ;; Surround first line in <h3></h3>
168 (goto-char (point-min))
172 ;; Treat example regions properly
174 (while (re-search-forward "<pre[^>]*>" nil t
)
175 (setq beg
(match-end 0))
176 (setq end
(if (re-search-forward "</pre>" nil
1)
180 (narrow-to-region beg end
)
181 ;; Change spaces to
182 (goto-char (point-min))
183 (while (re-search-forward "^ +" nil t
)
184 (replace-match (apply 'concat
(make-list
185 (length (match-string 0))
187 ;; Change newline to <br />
188 (goto-char (point-min))
189 (while (re-search-forward "\n" nil t
)
190 (replace-match "<br />")))))
191 ;; Get rid of 2 spaces together and merge lines
192 (goto-char (point-min))
193 (while (re-search-forward (concat "[" muse-regexp-blank
"\n]+") nil t
)
195 ;; Remove trailing space
196 (goto-char (point-min))
197 (while (re-search-forward " *</p> *" nil t
)
198 (replace-match "</p>"))
199 ;; Make relative links work
200 (goto-char (point-min))
201 (while (re-search-forward "href=\"[/.]+" nil t
)
202 (replace-match "href=\"http://www.mwolson.org/" nil t
))
203 ;; Copy entry to clipboard
204 (clipboard-kill-ring-save (point-min) (point-max)))))
206 ;;; Key customizations
208 (global-set-key "\C-cpl" 'muse-blosxom-new-entry
)
209 (global-set-key "\C-cpL" #'(lambda () (interactive)
210 (my-muse-project-find-file "Blog")))
211 (global-set-key "\C-cpi" #'(lambda () (interactive)
212 (my-muse-project-find-file "Private")))
213 (global-set-key "\C-cpn" #'(lambda () (interactive)
214 (my-muse-project-find-file "MyNotes")))
215 (global-set-key "\C-cpp" #'(lambda () (interactive)
216 (my-muse-project-find-file "Plans")))
217 (global-set-key "\C-cpr" #'(lambda () (interactive)
218 (my-muse-project-find-file "Projects")))
219 (global-set-key "\C-cps" #'(lambda () (interactive)
220 (my-muse-project-find-file "Classes")))
221 (global-set-key "\C-cpw" #'(lambda () (interactive)
222 (my-muse-project-find-file "Website")))
223 (global-set-key "\C-cpx" 'my-muse-prepare-entry-for-xanga
)
227 (custom-set-variables
228 '(muse-blosxom-base-directory "~/proj/wiki/blog/")
229 '(muse-colors-autogen-headings (quote outline
))
230 '(muse-colors-inline-image-method (quote muse-colors-use-publishing-directory
))
231 '(muse-file-extension "muse")
232 '(muse-html-charset-default "utf-8")
233 '(muse-html-encoding-default (quote utf-8
))
234 '(muse-html-footer "~/personal-site/muse/generic-footer.html")
235 '(muse-html-header "~/personal-site/muse/generic-header.html")
236 '(muse-html-meta-content-encoding (quote utf-8
))
237 '(muse-html-style-sheet "<link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"all\" href=\"/common.css\" />
238 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"screen\" href=\"/screen.css\" />
239 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"print\" href=\"/print.css\" />")
240 '(muse-latex-header "~/personal-site/muse/header.tex")
241 '(muse-mode-auto-p nil nil
(muse-project))
242 '(muse-mode-highlight-p t nil
(muse-colors))
243 '(muse-mode-hook (quote (muse-wiki-update-custom-values flyspell-mode footnote-mode
)))
244 '(muse-publish-comments-p t
)
245 '(muse-publish-desc-transforms (quote (muse-wiki-publish-pretty-title muse-wiki-publish-pretty-interwiki
)))
246 '(muse-wiki-publish-small-title-words (quote ("the" "and" "at" "on" "of" "for" "in" "an" "a" "page")))
247 '(muse-xhtml-footer "~/personal-site/muse/generic-footer.html")
248 '(muse-xhtml-header "~/personal-site/muse/generic-header.html"))
250 '(muse-bad-link-face ((t (:foreground
"DeepPink" :underline
"DeepPink" :weight bold
))))
251 '(muse-link-face ((t (:foreground
"blue" :underline
"blue" :weight bold
)))))
253 ;;; muse-init.el ends here