1 ;;; muse-init.el --- Initialize Emacs Muse
3 ;; This file is part of Michael Olson's Emacs settings.
5 ;; The code in this file may be used, distributed, and modified
6 ;; without restriction.
8 ;; I use initsplit.el to separate customize settings on a per-project
11 ;; In order to see the scripts that I use to publish my website to a
12 ;; remote webserver, check out
13 ;; http://mwolson.org/projects/SiteScripts.html.
18 (add-to-list 'load-path
"/home/mwolson/proj/emacs/muse/git-muse/lisp")
19 (add-to-list 'load-path
"/home/mwolson/proj/emacs/muse/git-muse/experimental")
22 (require 'outline
) ; I like outline-style faces
23 (require 'muse
) ; load generic module
24 (require 'muse-colors
) ; load coloring/font-lock module
25 (require 'muse-mode
) ; load authoring mode
26 (require 'muse-blosxom
) ; load blosxom module
27 (require 'muse-docbook
) ; load DocBook publishing style
28 (require 'muse-html
) ; load (X)HTML publishing style
29 (require 'muse-latex
) ; load LaTeX/PDF publishing styles
30 (require 'muse-latex2png
) ; publish <latex> tags
31 (require 'muse-project
) ; load support for projects
32 (require 'muse-texinfo
) ; load Info publishing style
33 (require 'muse-wiki
) ; load Wiki support
34 (require 'muse-xml
) ; load XML support
35 ;;(require 'muse-message) ; load message support (experimental)
39 ;; Here is an example of making a customized version of your favorite
40 ;; publisher. All this does is run `my-muse-blosoxm-finalize' on the
41 ;; published file immediately after saving it.
42 (muse-derive-style "my-blosxom" "blosxom-xhtml"
43 :final
'my-muse-blosxom-finalize
)
45 ;; This turns relative links into absolute links
46 (muse-derive-style "my-pdf" "pdf"
47 :before
'my-muse-pdf-prepare-buffer
)
49 ;; This uses a different header and footer than normal
50 (muse-derive-style "my-xhtml" "xhtml"
51 :header
"~/personal-site/muse/header.html"
52 :footer
"~/personal-site/muse/footer.html")
54 ;; Define a draft style which provides extra space between sections
56 (defvar muse-latex-draft-markup-strings
57 '((chapter .
"\\bigskip\n\\bigskip\n\\chapter{")
58 (section .
"\\bigskip\n\\bigskip\n\\section{")
59 (subsection .
"\\bigskip\n\\bigskip\n\\subsection{")
60 (subsubsection .
"\\bigskip\n\\bigskip\n\\subsubsection{"))
61 "Strings used for marking up Latex draft text.")
63 (muse-derive-style "latex-draft" "latex"
64 :strings
'muse-latex-draft-markup-strings
)
65 (muse-derive-style "pdf-draft" "latex-draft"
66 :final
'muse-latex-pdf-generate
67 :browser
'muse-latex-pdf-browse-file
68 :link-suffix
'muse-latex-pdf-extension
69 :osuffix
'muse-latex-pdf-extension
)
71 ;; Define a style with unnumbered titles
73 (defvar muse-latex-uh-markup-strings
74 '((chapter .
"\\chapter*{")
75 (section .
"\\section*{")
76 (subsection .
"\\subsection*{")
77 (subsubsection .
"\\subsubsection*{"))
78 "Strings used for marking up Latex text with unnumbered headings.")
80 (muse-derive-style "latex-uh" "latex"
81 :strings
'muse-latex-uh-markup-strings
)
82 (muse-derive-style "pdf-uh" "latex-uh"
83 :final
'muse-latex-pdf-generate
84 :browser
'muse-latex-pdf-browse-file
85 :link-suffix
'muse-latex-pdf-extension
86 :osuffix
'muse-latex-pdf-extension
)
88 ;; Here is my master project listing.
90 (setq muse-project-alist
92 ("Website" ("~/proj/wiki/web/" "~/proj/wiki/web/testdir/"
93 :force-publish
("WikiIndex")
94 :default
"WelcomePage")
96 :base-url
"http://mwolson.org/web/"
98 :path
"~/personal-site/site/web")
100 :base-url
"http://mwolson.org/web/"
101 :include
"/testdir/[^/]+"
102 :path
"~/personal-site/site/web/testdir")
104 :base-url
"http://mwolson.org/web/"
105 :path
"~/personal-site/site/web"
106 :include
"/\\(CurriculumVitae\\|BriefResume\\)[^/]*$"))
108 ("Projects" ("~/proj/wiki/projects/"
109 :force-publish
("WikiIndex" "MuseQuickStart")
110 :default
"WelcomePage")
112 :base-url
"http://mwolson.org/projects/"
113 :path
"~/personal-site/site/projects"))
115 ("Blog" (,@(muse-project-alist-dirs "~/proj/wiki/blog")
117 ;; Publish this directory and its subdirectories. Arguments
118 ;; are as follows. The above `muse-project-alist-dirs' part
120 ;; 1. Source directory
121 ;; 2. Output directory
122 ;; 3. Publishing style
123 ;; remainder: Other things to put in every generated style
124 ,@(muse-project-alist-styles "~/proj/wiki/blog"
125 "~/personal-site/site/blog"
127 :base-url
"http://blog.mwolson.org/"))
129 ("MyNotes" ("~/proj/wiki/notes/"
130 :force-publish
("index")
133 :base-url
"http://mwolson.org/notes/"
134 :path
"~/personal-site/site/notes")
136 :base-url
"http://mwolson.org/notes/"
137 :path
"~/personal-site/site/notes"))
139 ("Private" ("~/Documents"
140 :default
"movielist")
141 ,@(muse-project-alist-styles "~/Documents"
145 ("Classes" (,@(muse-project-alist-dirs "~/proj/wiki/classes")
147 ,@(muse-project-alist-styles "~/proj/wiki/classes"
148 "~/personal-site/site/classes"
151 ("MA366" ("~/proj/classes/ma366")
153 :path
"~/proj/classes/ma366"))
155 ("ENGL238" ("~/proj/classes/engl238")
157 :path
"~/proj/classes/engl238"))
159 ("CS426" ("~/proj/classes/cs426")
161 :path
"~/proj/classes/cs426"))
163 ("Plans" ("~/proj/wiki/plans/"
165 :major-mode planner-mode
166 :visit-link planner-visit-link
)
167 (:base
"planner-xhtml"
168 :path
"~/proj/notmine/planner-out"))
172 (setq muse-wiki-interwiki-alist
173 '(("PlugWiki" .
"http://wiki.purduelug.org/")
174 ("EmacsWiki" .
"http://www.emacswiki.org/cgi-bin/wiki/")
175 ("ArchWiki" .
"http://gnuarch.org/gnuarchwiki/")
177 ("CERIAS" .
"http://www.cerias.purdue.edu/")
178 ("PlannerMode" .
"http://www.emacswiki.org/cgi-bin/wiki/PlannerMode")
179 ("RememberMode" .
"http://www.emacswiki.org/cgi-bin/wiki/RememberMode")
180 ("GP2X" .
"http://www.gp2x.co.uk/")
181 ("UbuntuLinux" .
"http://ubuntulinux.org/")
182 ("PLUG" .
"http://purduelug.org/")
183 ("PAC" .
"http://web.ics.purdue.edu/~pac/")))
187 ;; Turn relative links into absolute ones
188 (defun my-muse-pdf-make-links-absolute (str &rest ignored
)
189 "Make relative links absolute."
192 (if (string-match "\\`[/.]+" str
)
193 (replace-match "http://mwolson.org/" nil t str
)
196 ;; Make sure my interproject links become absolute when published in
198 (defun my-muse-pdf-prepare-buffer ()
199 (set (make-local-variable 'muse-publish-url-transforms
)
200 (cons 'my-muse-pdf-make-links-absolute muse-publish-url-transforms
)))
202 ;; Switch to the given project and prompt for a file
203 (defun my-muse-project-find-file (project)
205 (let ((muse-current-project (muse-project project
)))
206 (call-interactively 'muse-project-find-file
)))
208 (defun my-muse-blosxom-finalize (file output-path target
)
209 ;; (my-muse-prepare-entry-for-xanga output-path)
210 ;; For now, do nothing.
213 ;; Make the current file display correctly in Xanga
214 ;; I call this using C-c p x now.
215 (defun my-muse-prepare-entry-for-xanga (file)
216 "Mangle FILE so that Xanga doesn't bug out, saving to X clipboard.
218 If FILE is not specified, use the published version of the current file."
221 (expand-file-name (concat (muse-page-name) muse-blosxom-extension
)
223 :path
(car (muse-project-applicable-styles
225 (cddr (muse-project-of-file))))))))
227 (muse-with-temp-buffer
228 (muse-insert-file-contents file
)
229 ;; surround first line in <h3></h3>
230 (goto-char (point-min))
234 ;; treat example regions properly
236 (while (re-search-forward "<pre[^>]*>" nil t
)
237 (setq beg
(match-end 0))
238 (setq end
(if (re-search-forward "</pre>" nil
1)
242 (narrow-to-region beg end
)
243 ;; change initial spaces to
244 (goto-char (point-min))
245 (while (re-search-forward "^ +" nil t
)
246 (replace-match (apply 'concat
(make-list
247 (length (match-string 0))
249 ;; change newline to <br />
250 (goto-char (point-min))
251 (while (re-search-forward "\n" nil t
)
252 (replace-match "<br />")))))
253 ;; get rid of 2 spaces together and merge lines
254 (goto-char (point-min))
255 (while (re-search-forward (concat "[" muse-regexp-blank
"\n]+") nil t
)
257 ;; remove trailing space
258 (goto-char (point-min))
259 (while (re-search-forward " *</p> *" nil t
)
260 (replace-match "</p>"))
261 ;; make relative links work
262 (goto-char (point-min))
263 (while (re-search-forward "href=\"[/.]+" nil t
)
264 (replace-match "href=\"http://mwolson.org/" nil t
))
265 ;; copy entry to clipboard
266 (clipboard-kill-ring-save (point-min) (point-max))
267 (message "Copied blog entry to clipboard"))))
269 ;; Turn a word or phrase into a clickable Wikipedia link
270 (defun my-muse-dictize (beg end
)
272 (let* ((text (buffer-substring-no-properties beg end
))
273 (link (concat "dict:" (replace-regexp-in-string " " "_" text t t
))))
274 (delete-region beg end
)
275 (insert "[[" link
"][" text
"]]")))
277 (defun my-muse-surround-math (&optional beg end
)
278 "If a region is higlighted, surround it with <math>...</math>.
279 If no region is highlighted, insert <math></math> and leave the point
280 between the two tags."
281 (interactive (list (ignore-errors (mark)) (point)))
284 (narrow-to-region beg end
)
285 (goto-char (point-min))
287 (goto-char (point-max))
290 (save-excursion (insert "</math>"))))
292 (defun my-muse-cdotize-region (beg end
)
295 (narrow-to-region beg end
)
296 (goto-char (point-min))
297 (while (re-search-forward " *\\* *" nil t
)
298 (replace-match " \\\\cdot "))))
300 ;;; Key customizations
302 (global-set-key "\C-cpl" 'muse-blosxom-new-entry
)
303 (global-set-key "\C-cpL" #'(lambda () (interactive)
304 (my-muse-project-find-file "Blog")))
305 (global-set-key "\C-cpi" #'(lambda () (interactive)
306 (my-muse-project-find-file "Private")))
307 (global-set-key "\C-cpm" #'(lambda () (interactive)
308 (my-muse-project-find-file "MA453")))
309 (global-set-key "\C-cpn" #'(lambda () (interactive)
310 (my-muse-project-find-file "MyNotes")))
311 (global-set-key "\C-cpp" #'(lambda () (interactive)
312 (my-muse-project-find-file "Plans")))
313 (global-set-key "\C-cpr" #'(lambda () (interactive)
314 (my-muse-project-find-file "Projects")))
315 (global-set-key "\C-cps" #'(lambda () (interactive)
316 (my-muse-project-find-file "Classes")))
317 (global-set-key "\C-cpw" #'(lambda () (interactive)
318 (my-muse-project-find-file "Website")))
319 (global-set-key "\C-cpC" #'my-muse-cdotize-region
)
320 (global-set-key "\C-cpM" #'my-muse-surround-math
)
321 (global-set-key "\C-cpW" #'my-muse-dictize
)
322 (global-set-key "\C-cpx" #'my-muse-prepare-entry-for-xanga
)
326 (custom-set-variables
327 '(muse-blosxom-base-directory "~/proj/wiki/blog/")
328 '(muse-colors-autogen-headings (quote outline
))
329 '(muse-colors-inline-image-method (quote muse-colors-use-publishing-directory
))
330 '(muse-completing-read-function (quote ido-completing-read
))
331 '(muse-html-charset-default "utf-8")
332 '(muse-html-encoding-default (quote utf-8
))
333 '(muse-html-footer "~/personal-site/muse/generic-footer.html")
334 '(muse-html-header "~/personal-site/muse/generic-header.html")
335 '(muse-html-meta-content-encoding (quote utf-8
))
336 '(muse-html-style-sheet "<link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"all\" href=\"/common.css\" />
337 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"screen\" href=\"/screen.css\" />
338 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"print\" href=\"/print.css\" />")
339 '(muse-latex-header "~/personal-site/muse/header.tex")
340 '(muse-mode-hook (quote (flyspell-mode footnote-mode
)))
341 '(muse-publish-comments-p t
)
342 '(muse-publish-date-format "%b. %e, %Y")
343 '(muse-publish-desc-transforms (quote (muse-wiki-publish-pretty-title muse-wiki-publish-pretty-interwiki muse-publish-strip-URL
)))
344 '(muse-wiki-publish-small-title-words (quote ("the" "and" "at" "on" "of" "for" "in" "an" "a" "page")))
345 '(muse-xhtml-footer "~/personal-site/muse/generic-footer.html")
346 '(muse-xhtml-header "~/personal-site/muse/generic-header.html")
347 '(muse-xhtml-style-sheet "<link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"all\" href=\"/common.css\" />
348 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"screen\" href=\"/screen.css\" />
349 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"print\" href=\"/print.css\" />"))
351 '(muse-bad-link ((t (:foreground
"DeepPink" :underline
"DeepPink" :weight bold
)))))
353 ;;; muse-init.el ends here