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/master/lisp")
19 (add-to-list 'load-path
"/home/mwolson/proj/emacs/muse/master/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 ;; Here is my master project listing.
73 (setq muse-project-alist
75 ("Website" ("~/proj/wiki/web/" "~/proj/wiki/web/testdir/"
76 :force-publish
("WikiIndex")
77 :default
"WelcomePage")
79 :base-url
"http://mwolson.org/web/"
81 :path
"~/personal-site/site/web")
83 :base-url
"http://mwolson.org/web/"
84 :include
"/testdir/[^/]+"
85 :path
"~/personal-site/site/web/testdir")
87 :base-url
"http://mwolson.org/web/"
88 :path
"~/personal-site/site/web"
89 :include
"/\\(CurriculumVitae\\|BriefResume\\)[^/]*$"))
91 ("Projects" ("~/proj/wiki/projects/"
92 :force-publish
("WikiIndex" "MuseQuickStart")
93 :default
"WelcomePage")
95 :base-url
"http://mwolson.org/projects/"
96 :path
"~/personal-site/site/projects"))
98 ("Blog" (,@(muse-project-alist-dirs "~/proj/wiki/blog")
100 ;; Publish this directory and its subdirectories. Arguments
101 ;; are as follows. The above `muse-project-alist-dirs' part
103 ;; 1. Source directory
104 ;; 2. Output directory
105 ;; 3. Publishing style
106 ;; remainder: Other things to put in every generated style
107 ,@(muse-project-alist-styles "~/proj/wiki/blog"
108 "~/personal-site/site/blog"
110 :base-url
"http://blog.mwolson.org/"))
112 ("MyNotes" ("~/proj/wiki/notes/"
113 :force-publish
("index")
116 :base-url
"http://mwolson.org/notes/"
117 :path
"~/personal-site/site/notes")
119 :base-url
"http://mwolson.org/notes/"
120 :path
"~/personal-site/site/notes"))
122 ("Private" ("~/Documents"
123 :default
"movielist")
124 ,@(muse-project-alist-styles "~/Documents"
128 ("Classes" (,@(muse-project-alist-dirs "~/proj/wiki/classes")
130 ,@(muse-project-alist-styles "~/proj/wiki/classes"
131 "~/personal-site/site/classes"
134 ("MA453" ("~/proj/classes/ma453")
136 :path
"~/proj/classes/ma453"))
138 ("CS565" ("~/proj/classes/cs565")
140 :path
"~/proj/classes/cs565"))
142 ("Plans" ("~/proj/wiki/plans/"
144 :major-mode planner-mode
145 :visit-link planner-visit-link
)
146 (:base
"planner-xhtml"
147 :path
"~/proj/notmine/planner-out"))
151 (setq muse-wiki-interwiki-alist
152 '(("PlugWiki" .
"http://wiki.purduelug.org/")
153 ("EmacsWiki" .
"http://www.emacswiki.org/cgi-bin/wiki/")
154 ("ArchWiki" .
"http://gnuarch.org/gnuarchwiki/")
156 ("CERIAS" .
"http://www.cerias.purdue.edu/")
157 ("PlannerMode" .
"http://www.emacswiki.org/cgi-bin/wiki/PlannerMode")
158 ("RememberMode" .
"http://www.emacswiki.org/cgi-bin/wiki/RememberMode")
159 ("GP2X" .
"http://www.gp2x.co.uk/")
160 ("UbuntuLinux" .
"http://ubuntulinux.org/")
161 ("PLUG" .
"http://purduelug.org/")
162 ("PAC" .
"http://web.ics.purdue.edu/~pac/")))
166 ;; Turn relative links into absolute ones
167 (defun my-muse-pdf-make-links-absolute (str &rest ignored
)
168 "Make relative links absolute."
171 (if (string-match "\\`[/.]+" str
)
172 (replace-match "http://mwolson.org/" nil t str
)
175 ;; Make sure my interproject links become absolute when published in
177 (defun my-muse-pdf-prepare-buffer ()
178 (set (make-local-variable 'muse-publish-url-transforms
)
179 (cons 'my-muse-pdf-make-links-absolute muse-publish-url-transforms
)))
181 ;; Switch to the given project and prompt for a file
182 (defun my-muse-project-find-file (project)
184 (let ((muse-current-project (muse-project project
)))
185 (call-interactively 'muse-project-find-file
)))
187 (defun my-muse-blosxom-finalize (file output-path target
)
188 ;; (my-muse-prepare-entry-for-xanga output-path)
189 ;; For now, do nothing.
192 ;; Make the current file display correctly in Xanga
193 ;; I call this using C-c p x now.
194 (defun my-muse-prepare-entry-for-xanga (file)
195 "Mangle FILE so that Xanga doesn't bug out, saving to X clipboard.
197 If FILE is not specified, use the published version of the current file."
200 (expand-file-name (concat (muse-page-name) muse-blosxom-extension
)
202 :path
(car (muse-project-applicable-styles
204 (cddr (muse-project-of-file))))))))
206 (muse-with-temp-buffer
207 (muse-insert-file-contents file
)
208 ;; surround first line in <h3></h3>
209 (goto-char (point-min))
213 ;; treat example regions properly
215 (while (re-search-forward "<pre[^>]*>" nil t
)
216 (setq beg
(match-end 0))
217 (setq end
(if (re-search-forward "</pre>" nil
1)
221 (narrow-to-region beg end
)
222 ;; change initial spaces to
223 (goto-char (point-min))
224 (while (re-search-forward "^ +" nil t
)
225 (replace-match (apply 'concat
(make-list
226 (length (match-string 0))
228 ;; change newline to <br />
229 (goto-char (point-min))
230 (while (re-search-forward "\n" nil t
)
231 (replace-match "<br />")))))
232 ;; get rid of 2 spaces together and merge lines
233 (goto-char (point-min))
234 (while (re-search-forward (concat "[" muse-regexp-blank
"\n]+") nil t
)
236 ;; remove trailing space
237 (goto-char (point-min))
238 (while (re-search-forward " *</p> *" nil t
)
239 (replace-match "</p>"))
240 ;; make relative links work
241 (goto-char (point-min))
242 (while (re-search-forward "href=\"[/.]+" nil t
)
243 (replace-match "href=\"http://mwolson.org/" nil t
))
244 ;; copy entry to clipboard
245 (clipboard-kill-ring-save (point-min) (point-max))
246 (message "Copied blog entry to clipboard"))))
248 ;; Turn a word or phrase into a clickable Wikipedia link
249 (defun my-muse-dictize (beg end
)
251 (let* ((text (buffer-substring-no-properties beg end
))
252 (link (concat "dict:" (replace-regexp-in-string " " "_" text t t
))))
253 (delete-region beg end
)
254 (insert "[[" link
"][" text
"]]")))
256 (defun my-muse-surround-math (beg end
)
259 (narrow-to-region beg end
)
260 (goto-char (point-min))
262 (goto-char (point-max))
265 (defun my-muse-cdotize-region (beg end
)
268 (narrow-to-region beg end
)
269 (goto-char (point-min))
270 (while (re-search-forward " *\\* *" nil t
)
271 (replace-match " \\\\cdot "))))
273 ;;; Key customizations
275 (global-set-key "\C-cpl" 'muse-blosxom-new-entry
)
276 (global-set-key "\C-cpL" #'(lambda () (interactive)
277 (my-muse-project-find-file "Blog")))
278 (global-set-key "\C-cpi" #'(lambda () (interactive)
279 (my-muse-project-find-file "Private")))
280 (global-set-key "\C-cpm" #'(lambda () (interactive)
281 (my-muse-project-find-file "MA453")))
282 (global-set-key "\C-cpn" #'(lambda () (interactive)
283 (my-muse-project-find-file "MyNotes")))
284 (global-set-key "\C-cpp" #'(lambda () (interactive)
285 (my-muse-project-find-file "Plans")))
286 (global-set-key "\C-cpr" #'(lambda () (interactive)
287 (my-muse-project-find-file "Projects")))
288 (global-set-key "\C-cps" #'(lambda () (interactive)
289 (my-muse-project-find-file "Classes")))
290 (global-set-key "\C-cpw" #'(lambda () (interactive)
291 (my-muse-project-find-file "Website")))
292 (global-set-key "\C-cpC" #'my-muse-cdotize-region
)
293 (global-set-key "\C-cpM" #'my-muse-surround-math
)
294 (global-set-key "\C-cpW" #'my-muse-dictize
)
295 (global-set-key "\C-cpx" #'my-muse-prepare-entry-for-xanga
)
299 (custom-set-variables
300 '(muse-blosxom-base-directory "~/proj/wiki/blog/")
301 '(muse-colors-autogen-headings (quote outline
))
302 '(muse-colors-inline-image-method (quote muse-colors-use-publishing-directory
))
303 '(muse-completing-read-function (quote ido-completing-read
))
304 '(muse-html-charset-default "utf-8")
305 '(muse-html-encoding-default (quote utf-8
))
306 '(muse-html-footer "~/personal-site/muse/generic-footer.html")
307 '(muse-html-header "~/personal-site/muse/generic-header.html")
308 '(muse-html-meta-content-encoding (quote utf-8
))
309 '(muse-html-style-sheet "<link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"all\" href=\"/common.css\" />
310 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"screen\" href=\"/screen.css\" />
311 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"print\" href=\"/print.css\" />")
312 '(muse-latex-header "~/personal-site/muse/header.tex")
313 '(muse-mode-hook (quote (flyspell-mode footnote-mode
)))
314 '(muse-publish-comments-p t
)
315 '(muse-publish-desc-transforms (quote (muse-wiki-publish-pretty-title muse-wiki-publish-pretty-interwiki muse-publish-strip-URL
)))
316 '(muse-wiki-publish-small-title-words (quote ("the" "and" "at" "on" "of" "for" "in" "an" "a" "page")))
317 '(muse-xhtml-footer "~/personal-site/muse/generic-footer.html")
318 '(muse-xhtml-header "~/personal-site/muse/generic-header.html")
319 '(muse-xhtml-style-sheet "<link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"all\" href=\"/common.css\" />
320 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"screen\" href=\"/screen.css\" />
321 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"print\" href=\"/print.css\" />"))
323 '(muse-bad-link ((t (:foreground
"DeepPink" :underline
"DeepPink" :weight bold
)))))
325 ;;; muse-init.el ends here