1 ;;; muse-init.el --- Initialize muse-mode.
3 ;; Hacked on by 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/mwolson/lisp")
14 (debian-pkg-add-load-path-item "/stuff/proj/emacs/muse/mwolson/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-texinfo
) ; load Info/PDF publishing styles
25 (require 'muse-wiki
) ; load Wiki support
26 (require 'muse-xml
) ; load experimental 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
52 :force-publish
("WikiIndex")
53 :default
"WelcomePage")
55 :path
"~/personal-site/site/web"))
58 ("~/proj/wiki/projects/"
59 :force-publish
("WikiIndex")
60 :default
"WelcomePage")
62 :path
"~/personal-site/site/projects"))
65 (,@(muse-project-alist-dirs "~/proj/wiki/blog")
68 ,@(muse-project-alist-styles "~/proj/wiki/blog"
69 "~/personal-site/site/blog"
74 :force-publish
("WikiIndex")
75 :default
"WelcomePage")
77 :path
"~/personal-site/site/notes"))
82 :major-mode planner-mode
83 :visit-link planner-visit-link
)
86 :path
"~/proj/notmine/planner-out"))
90 (setq muse-wiki-interwiki-alist
91 '(("PlugWiki" .
"http://plug.student-orgs.purdue.edu/plugwiki/")
92 ("TheEmacsWiki" .
"http://www.emacswiki.org/cgi-bin/wiki/")
93 ("ArchWiki" .
"http://wiki.gnuarch.org/")
95 ("CERIAS" .
"http://www.cerias.purdue.edu/")
96 ("PLUG" .
"http://plug.student-orgs.purdue.edu/plugwiki/")))
100 ;; Turn relative links into absolute ones
101 (defun my-muse-pdf-make-links-absolute (str &rest ignored
)
102 "Make relative links absolute."
105 (if (string-match "\\`[/.]+" str
)
106 (replace-match "http://www.mwolson.org/" nil t str
)
109 ;; Make sure my interproject links become absolute when published in
111 (defun my-muse-pdf-prepare-buffer ()
112 (set (make-local-variable 'muse-publish-url-transforms
)
113 (cons 'my-muse-pdf-make-links-absolute muse-publish-url-transforms
)))
115 ;; Switch to the given project and prompt for a file
116 (defun my-muse-project-find-file (project)
118 (let ((muse-current-project (muse-project project
)))
119 (call-interactively 'muse-project-find-file
)))
121 ;; Make the current file display correctly in Xanga
123 (defun my-muse-blosxom-finalize (file output-path target
)
124 ;; (my-muse-prepare-entry-for-xanga output-path)
125 ;; For now, do nothing.
128 ;; I call this using C-c p x now.
130 (defun my-muse-prepare-entry-for-xanga (file)
131 "Mangle FILE so that Xanga doesn't bug out, saving to X clipboard.
133 If FILE is not specified, use the published version of the current file."
136 (expand-file-name (concat (muse-page-name) muse-blosxom-extension
)
138 :path
(car (muse-project-applicable-styles
140 (cddr (muse-project-of-file))))))))
142 (muse-with-temp-buffer
143 (insert-file-contents file
)
144 ;; Surround first line in <h3></h3>
145 (goto-char (point-min))
149 ;; Treat example regions properly
151 (while (re-search-forward "<pre[^>]*>" nil t
)
152 (setq beg
(match-end 0))
153 (setq end
(if (re-search-forward "</pre>" nil
1)
157 (narrow-to-region beg end
)
158 ;; Change spaces to
159 (goto-char (point-min))
160 (while (re-search-forward "^ +" nil t
)
161 (replace-match (apply 'concat
(make-list
162 (length (match-string 0))
164 ;; Change newline to <br />
165 (goto-char (point-min))
166 (while (re-search-forward "\n" nil t
)
167 (replace-match "<br />")))))
168 ;; Get rid of 2 spaces together and merge lines
169 (goto-char (point-min))
170 (while (re-search-forward (concat "["
174 ;; Remove trailing space
175 (goto-char (point-min))
176 (while (re-search-forward " *</p> *" nil t
)
177 (replace-match "</p>"))
178 ;; Make relative links work
179 (goto-char (point-min))
180 (while (re-search-forward "href=\"[/.]+" nil t
)
181 (replace-match "href=\"http://www.mwolson.org/" nil t
))
182 ;; Copy entry to clipboard
183 (clipboard-kill-ring-save (point-min) (point-max)))))
185 ;;; Key customizations
187 (global-set-key "\C-cpl" 'muse-blosxom-new-entry
)
188 (global-set-key "\C-cpL" #'(lambda () (interactive)
189 (my-muse-project-find-file "Blog")))
190 (global-set-key "\C-cpn" #'(lambda () (interactive)
191 (my-muse-project-find-file "MyNotes")))
192 (global-set-key "\C-cpp" #'(lambda () (interactive)
193 (my-muse-project-find-file "Plans")))
194 (global-set-key "\C-cpr" #'(lambda () (interactive)
195 (my-muse-project-find-file "Projects")))
196 (global-set-key "\C-cpw" #'(lambda () (interactive)
197 (my-muse-project-find-file "Website")))
198 (global-set-key "\C-cpx" 'my-muse-prepare-entry-for-xanga
)
202 (custom-set-variables
203 '(muse-blosxom-base-directory "~/proj/wiki/blog/")
204 '(muse-colors-autogen-headings (quote outline
))
205 '(muse-file-extension "muse")
206 '(muse-html-charset-default "utf-8")
207 '(muse-html-encoding-default (quote utf-8
))
208 '(muse-html-meta-content-encoding (quote utf-8
))
209 '(muse-html-style-sheet "<link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"all\" href=\"/common.css\" />
210 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"screen\" href=\"/screen.css\" />
211 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"print\" href=\"/print.css\" />")
212 '(muse-mode-auto-p nil
)
213 '(muse-mode-hook (quote (footnote-mode muse-wiki-update-custom-values
)))
214 '(muse-publish-desc-transforms (quote (muse-wiki-publish-pretty-title muse-wiki-publish-pretty-interwiki muse-publish-escape-specials-in-string
)))
215 '(muse-wiki-publish-small-title-words (quote ("the" "and" "at" "on" "of" "for" "in" "an" "a" "page" "anime")))
216 '(muse-xhtml-footer "~/personal-site/muse/generic-footer.html")
217 '(muse-xhtml-header "~/personal-site/muse/generic-header.html"))
219 '(muse-bad-link-face ((t (:foreground
"DeepPink" :underline
"DeepPink" :weight bold
))))
220 '(muse-link-face ((t (:foreground
"blue" :underline
"blue" :weight bold
)))))
222 ;;; muse-init.el ends here