Make `muse-project-alist' more intuitively customizable.
[muse-el.git] / examples / mwolson / muse-init.el
blobf7c0d325c7b693ef7db41d4715672c82cd29df56
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.
9 ;;; Setup
11 ;; Add to load path
12 (when (fboundp 'debian-pkg-add-load-path-item)
13 (debian-pkg-add-load-path-item "/stuff/proj/emacs/muse/mwolson/lisp"))
15 ;; Initialize
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-html) ; load (X)HTML publishing style
22 (require 'muse-wiki) ; load Wiki support
23 ;;(require 'muse-message) ; load message support (experimental)
25 ;; Setup projects
27 ;; Here is an example of making a customized version of your favorite
28 ;; publisher. All this does is run `my-muse-blosoxm-finalize' on the
29 ;; published file immediately after saving it.
31 (unless (assoc "my-blosxom" muse-publishing-styles)
32 (muse-derive-style "my-blosxom" "blosxom-xhtml"
33 :final 'my-muse-blosxom-finalize)
35 (muse-derive-style "my-xhtml" "xhtml"
36 :header "~/personal-site/muse/header.html"
37 :footer "~/personal-site/muse/footer.html"))
39 ;; Here is my master project listing.
41 ;; Note that I not do anything useful with the ProjectsWiki and
42 ;; WebWiki projects; only the BlogWiki project is published.
44 (setq muse-project-alist
46 ("Website"
47 ("~/proj/wiki/web/" :default "WelcomePage")
48 (:base "my-xhtml"
49 :path "~/personal-site/site/web"))
51 ("Projects"
52 ("~/proj/wiki/projects/" :default "WelcomePage")
53 (:base "my-xhtml"
54 :path "~/personal-site/site/projects"))
56 ("Blog"
57 (,@(muse-blosxom-project-alist-dirs "~/proj/wiki/blog")
58 :default "guestbook")
60 ,@(muse-blosxom-project-alist-entry "~/proj/wiki/blog"
61 "~/personal-site/site/blog"
62 "my-blosxom"))
64 ("Plans"
65 ("~/proj/wiki/plans/"
66 :default "TaskPool"
67 :major-mode planner-mode
68 :visit-link planner-visit-link)
70 (:base "xhtml"
71 :path "~/proj/notmine/planner-out"))
74 ;; Wiki settings
75 (setq muse-wiki-interwiki-alist
76 '(("PlugWiki" . "http://plug.student-orgs.purdue.edu/plugwiki/")
77 ("TheEmacsWiki" . "http://www.emacswiki.org/cgi-bin/wiki/")
78 ("ArchWiki" . "http://wiki.gnuarch.org/")
79 ("WebWiki" .
80 (lambda (tag)
81 (concat "../web/"
82 (or tag "WelcomePage"))))
83 ("ProjectsWiki" .
84 (lambda (tag)
85 (concat "../projects/"
86 (or tag "WelcomePage"))))))
88 ;;; Functions
90 ;; Make the current file display correctly in Xanga
92 (defun my-muse-blosxom-finalize (file output-path target)
93 ;; (my-muse-prepare-entry-for-xanga output-path)
94 ;; For now, do nothing.
97 ;; I call this using C-c p x now.
99 (defun my-muse-prepare-entry-for-xanga (file)
100 "Mangle FILE so that Xanga doesn't bug out, saving to X clipboard.
102 If FILE is not specified, use the published version of the current file."
103 (interactive
104 (list
105 (expand-file-name (concat (muse-page-name) ".txt")
106 (muse-style-element
107 :path (car (muse-project-applicable-styles
108 buffer-file-name
109 (cddr (muse-project-of-file))))))))
110 (save-match-data
111 (with-temp-buffer
112 (insert-file-contents file t)
113 ;; Surround first line in <h3></h3>
114 (goto-char (point-min))
115 (insert "<h3>")
116 (end-of-line)
117 (insert "</h3>")
118 ;; Treat example regions properly
119 (let (beg end)
120 (while (re-search-forward "<pre[^>]*>" nil t)
121 (setq beg (match-end 0))
122 (setq end (if (re-search-forward "</pre>" nil 1)
123 (match-beginning 0)
124 (point)))
125 (save-restriction
126 (narrow-to-region beg end)
127 ;; Change spaces to &nbsp;
128 (goto-char (point-min))
129 (while (re-search-forward "^ +" nil t)
130 (replace-match (apply 'concat (make-list
131 (length (match-string 0))
132 "&nbsp;"))))
133 ;; Change newline to <br />
134 (goto-char (point-min))
135 (while (re-search-forward "\n" nil t)
136 (replace-match "<br />")))))
137 ;; Get rid of 2 spaces together and merge lines
138 (goto-char (point-min))
139 (while (re-search-forward (concat "["
140 muse-regexp-space
141 "]+") nil t)
142 (replace-match " "))
143 ;; Remove trailing space
144 (goto-char (point-min))
145 (while (re-search-forward " *</p> *" nil t)
146 (replace-match "</p>"))
147 ;; Make relative links work
148 (goto-char (point-min))
149 (while (re-search-forward "href=\"/" nil t)
150 (replace-match "href=\"http://www.mwolson.org/" nil t))
151 ;; Copy entry to clipboard
152 (clipboard-kill-ring-save (point-min) (point-max))
153 ;; Don't prompt me about killing the buffer
154 (set-buffer-modified-p nil))))
156 ;;; Key customizations
158 (global-set-key "\C-cpl" 'muse-blosxom-new-entry)
159 (global-set-key "\C-cpL"
160 #'(lambda ()
161 (interactive)
162 (find-file muse-blosxom-base-directory)))
163 (global-set-key "\C-cpx" 'my-muse-prepare-entry-for-xanga)
165 ;;; Custom variables
167 (custom-set-variables
168 '(muse-blosxom-base-directory "~/proj/wiki/blog/")
169 '(muse-blosxom-publishing-directory "~/personal-site/site/blog")
170 '(muse-colors-autogen-headings (quote outline))
171 '(muse-file-extension "muse")
172 '(muse-html-charset-default "utf-8")
173 '(muse-html-encoding-default (quote utf-8))
174 '(muse-html-meta-content-encoding (quote utf-8))
175 '(muse-html-style-sheet "<link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"all\" href=\"/common.css\" />
176 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"screen\" href=\"/screen.css\" />
177 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"print\" href=\"/print.css\" />")
178 '(muse-xhtml-footer "~/personal-site/muse/generic-footer.html")
179 '(muse-xhtml-header "~/personal-site/muse/generic-header.html"))
180 (custom-set-faces
181 '(muse-bad-link-face ((t (:foreground "DeepPink" :underline "DeepPink" :weight bold))))
182 '(muse-link-face ((t (:foreground "blue" :underline "blue" :weight bold)))))
184 ;;; muse-init.el ends here