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
"/home/mwolson/proj/emacs/muse/mwolson/lisp")
13 (add-to-list 'load-path
"/home/mwolson/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/" "~/proj/wiki/web/testdir/"
51 :force-publish
("WikiIndex")
52 :default
"WelcomePage")
55 :path
"~/personal-site/site/web")
57 :include
"/testdir/[^/]+"
58 :path
"~/personal-site/site/web/testdir")
60 :path
"~/personal-site/site/web"
61 :include
"/CurriculumVitae[^/]*$"))
63 ("Projects" ("~/proj/wiki/projects/"
64 :force-publish
("WikiIndex")
65 :default
"WelcomePage")
67 :path
"~/personal-site/site/projects"))
69 ("Blog" (,@(muse-project-alist-dirs "~/proj/wiki/blog")
72 ;; Publish this directory and its subdirectories. Arguments
73 ;; are as follows. The above `muse-project-alist-dirs' part
74 ;; is also needed, using Argument 1.
76 ;; 1. Source directory
77 ;; 2. Output directory
78 ;; 3. Publishing style
79 ,@(muse-project-alist-styles "~/proj/wiki/blog"
80 "~/personal-site/site/blog"
83 ("MyNotes" ("~/proj/wiki/notes/"
84 :force-publish
("index")
87 :path
"~/personal-site/site/notes")
89 :path
"~/personal-site/site/notes"))
91 ("Private" ("~/Documents" "~/Documents/work-school"
93 ,@(muse-project-alist-styles "~/Documents"
97 ("Classes" (,@(muse-project-alist-dirs "~/proj/wiki/classes")
99 ,@(muse-project-alist-styles "~/proj/wiki/classes"
100 "~/personal-site/site/classes"
103 ("Plans" ("~/proj/wiki/plans/"
105 :major-mode planner-mode
106 :visit-link planner-visit-link
)
107 (:base
"planner-xhtml"
108 :path
"~/proj/notmine/planner-out"))
112 (setq muse-wiki-interwiki-alist
113 '(("PlugWiki" .
"http://plug.student-orgs.purdue.edu/wiki/")
114 ("EmacsWiki" .
"http://www.emacswiki.org/cgi-bin/wiki/")
115 ("ArchWiki" .
"http://gnuarch.org/gnuarchwiki/")
117 ("CERIAS" .
"http://www.cerias.purdue.edu/")
118 ("PlannerMode" .
"http://www.plannerlove.com/")
119 ("GP2X" .
"http://www.gp2x.co.uk/")
120 ("UbuntuLinux" .
"http://ubuntulinux.org/")
121 ("PLUG" .
"http://plug.student-orgs.purdue.edu/wiki/")))
125 ;; Turn relative links into absolute ones
126 (defun my-muse-pdf-make-links-absolute (str &rest ignored
)
127 "Make relative links absolute."
130 (if (string-match "\\`[/.]+" str
)
131 (replace-match "http://www.mwolson.org/" nil t str
)
134 ;; Make sure my interproject links become absolute when published in
136 (defun my-muse-pdf-prepare-buffer ()
137 (set (make-local-variable 'muse-publish-url-transforms
)
138 (cons 'my-muse-pdf-make-links-absolute muse-publish-url-transforms
)))
140 ;; Switch to the given project and prompt for a file
141 (defun my-muse-project-find-file (project)
143 (let ((muse-current-project (muse-project project
)))
144 (call-interactively 'muse-project-find-file
)))
146 ;; Determine whether we are publishing a certain kind of output
147 (defun my-muse-format-p (format)
148 (let ((base (muse-get-keyword :base muse-publishing-current-style
)))
149 (when base
(string-match format base
))))
151 (defun my-muse-blosxom-finalize (file output-path target
)
152 ;; (my-muse-prepare-entry-for-xanga output-path)
153 ;; For now, do nothing.
156 ;; Make the current file display correctly in Xanga
157 ;; I call this using C-c p x now.
158 (defun my-muse-prepare-entry-for-xanga (file)
159 "Mangle FILE so that Xanga doesn't bug out, saving to X clipboard.
161 If FILE is not specified, use the published version of the current file."
164 (expand-file-name (concat (muse-page-name) muse-blosxom-extension
)
166 :path
(car (muse-project-applicable-styles
168 (cddr (muse-project-of-file))))))))
170 (muse-with-temp-buffer
171 (insert-file-contents file
)
172 ;; surround first line in <h3></h3>
173 (goto-char (point-min))
177 ;; treat example regions properly
179 (while (re-search-forward "<pre[^>]*>" nil t
)
180 (setq beg
(match-end 0))
181 (setq end
(if (re-search-forward "</pre>" nil
1)
185 (narrow-to-region beg end
)
186 ;; change initial spaces to
187 (goto-char (point-min))
188 (while (re-search-forward "^ +" nil t
)
189 (replace-match (apply 'concat
(make-list
190 (length (match-string 0))
192 ;; change newline to <br />
193 (goto-char (point-min))
194 (while (re-search-forward "\n" nil t
)
195 (replace-match "<br />")))))
196 ;; get rid of 2 spaces together and merge lines
197 (goto-char (point-min))
198 (while (re-search-forward (concat "[" muse-regexp-blank
"\n]+") nil t
)
200 ;; remove trailing space
201 (goto-char (point-min))
202 (while (re-search-forward " *</p> *" nil t
)
203 (replace-match "</p>"))
204 ;; make relative links work
205 (goto-char (point-min))
206 (while (re-search-forward "href=\"[/.]+" nil t
)
207 (replace-match "href=\"http://www.mwolson.org/" nil t
))
208 ;; copy entry to clipboard
209 (clipboard-kill-ring-save (point-min) (point-max))
210 (message "Copied blog entry to clipboard"))))
212 ;; Turn a word or phrase into a clickable Wikipedia link
213 (defun my-muse-dictize (beg end
)
215 (let* ((text (buffer-substring-no-properties beg end
))
216 (link (concat "dict:" (replace-regexp-in-string " " "_" text t t
))))
217 (delete-region beg end
)
218 (insert "[[" link
"][" text
"]]")))
220 ;;; Key customizations
222 (global-set-key "\C-cpl" 'muse-blosxom-new-entry
)
223 (global-set-key "\C-cpL" #'(lambda () (interactive)
224 (my-muse-project-find-file "Blog")))
225 (global-set-key "\C-cpi" #'(lambda () (interactive)
226 (my-muse-project-find-file "Private")))
227 (global-set-key "\C-cpn" #'(lambda () (interactive)
228 (my-muse-project-find-file "MyNotes")))
229 (global-set-key "\C-cpp" #'(lambda () (interactive)
230 (my-muse-project-find-file "Plans")))
231 (global-set-key "\C-cpr" #'(lambda () (interactive)
232 (my-muse-project-find-file "Projects")))
233 (global-set-key "\C-cps" #'(lambda () (interactive)
234 (my-muse-project-find-file "Classes")))
235 (global-set-key "\C-cpw" #'(lambda () (interactive)
236 (my-muse-project-find-file "Website")))
237 (global-set-key "\C-cpW" 'my-muse-dictize
)
238 (global-set-key "\C-cpx" 'my-muse-prepare-entry-for-xanga
)
242 (custom-set-variables
243 '(muse-blosxom-base-directory "~/proj/wiki/blog/")
244 '(muse-colors-autogen-headings (quote outline
))
245 '(muse-colors-inline-image-method (quote muse-colors-use-publishing-directory
))
246 '(muse-html-charset-default "utf-8")
247 '(muse-html-encoding-default (quote utf-8
))
248 '(muse-html-footer "~/personal-site/muse/generic-footer.html")
249 '(muse-html-header "~/personal-site/muse/generic-header.html")
250 '(muse-html-meta-content-encoding (quote utf-8
))
251 '(muse-html-style-sheet "<link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"all\" href=\"/common.css\" />
252 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"screen\" href=\"/screen.css\" />
253 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"print\" href=\"/print.css\" />")
254 '(muse-latex-header "~/personal-site/muse/header.tex")
255 '(muse-mode-hook (quote (flyspell-mode footnote-mode
)))
256 '(muse-publish-comments-p t
)
257 '(muse-publish-desc-transforms (quote (muse-wiki-publish-pretty-title muse-wiki-publish-pretty-interwiki
)))
258 '(muse-wiki-publish-small-title-words (quote ("the" "and" "at" "on" "of" "for" "in" "an" "a" "page")))
259 '(muse-xhtml-footer "~/personal-site/muse/generic-footer.html")
260 '(muse-xhtml-header "~/personal-site/muse/generic-header.html")
261 '(muse-xhtml-style-sheet "<link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"all\" href=\"/common.css\" />
262 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"screen\" href=\"/screen.css\" />
263 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"print\" href=\"/print.css\" />"))
265 '(muse-bad-link ((t (:foreground
"DeepPink" :underline
"DeepPink" :weight bold
)))))
267 ;;; muse-init.el ends here