1;;; muse-init.el --- Initialize Emacs Muse 2 3;; This file is part of Michael Olson's Emacs settings. 4 5;; The code in this file may be used, distributed, and modified 6;; without restriction. 7 8;; I use initsplit.el to separate customize settings on a per-project 9;; basis. 10 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. 14 15;;; Setup 16 17;; Add to load path 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") 20 21;; Initialize 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) 36 37;; Setup projects 38 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) 44 45;; This turns relative links into absolute links 46(muse-derive-style "my-pdf" "pdf" 47 :before 'my-muse-pdf-prepare-buffer) 48 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") 53 54;; Define a draft style which provides extra space between sections 55 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.") 62 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) 70 71;; Define a style with unnumbered titles 72 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.") 79 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) 87 88;; Here is my master project listing. 89 90(setq muse-project-alist 91 `( 92 ("Website" ("~/proj/wiki/web/" "~/proj/wiki/web/testdir/" 93 :force-publish ("WikiIndex") 94 :default "WelcomePage") 95 (:base "my-xhtml" 96 :base-url "http://mwolson.org/web/" 97 :include "/web/[^/]+" 98 :path "~/personal-site/site/web") 99 (:base "my-xhtml" 100 :base-url "http://mwolson.org/web/" 101 :include "/testdir/[^/]+" 102 :path "~/personal-site/site/web/testdir") 103 (:base "my-pdf" 104 :base-url "http://mwolson.org/web/" 105 :path "~/personal-site/site/web" 106 :include "/\\(CurriculumVitae\\|BriefResume\\)[^/]*$")) 107 108 ("Projects" ("~/proj/wiki/projects/" 109 :force-publish ("WikiIndex" "MuseQuickStart") 110 :default "WelcomePage") 111 (:base "my-xhtml" 112 :base-url "http://mwolson.org/projects/" 113 :path "~/personal-site/site/projects")) 114 115 ("Blog" (,@(muse-project-alist-dirs "~/proj/wiki/blog") 116 :default "index") 117 ;; Publish this directory and its subdirectories. Arguments 118 ;; are as follows. The above `muse-project-alist-dirs' part 119 ;; is also needed. 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" 126 "my-blosxom" 127 :base-url "http://blog.mwolson.org/")) 128 129 ("MyNotes" ("~/proj/wiki/notes/" 130 :force-publish ("index") 131 :default "index") 132 (:base "xhtml" 133 :base-url "http://mwolson.org/notes/" 134 :path "~/personal-site/site/notes") 135 (:base "my-pdf" 136 :base-url "http://mwolson.org/notes/" 137 :path "~/personal-site/site/notes")) 138 139 ("Private" ("~/Documents" 140 :default "movielist") 141 ,@(muse-project-alist-styles "~/Documents" 142 "~/Documents" 143 "pdf")) 144 145 ("Classes" (,@(muse-project-alist-dirs "~/proj/wiki/classes") 146 :default "index") 147 ,@(muse-project-alist-styles "~/proj/wiki/classes" 148 "~/personal-site/site/classes" 149 "xhtml")) 150 151 ("MA366" ("~/proj/classes/ma366") 152 (:base "pdf-uh" 153 :path "~/proj/classes/ma366")) 154 155 ("ENGL238" ("~/proj/classes/engl238") 156 (:base "pdf-uh" 157 :path "~/proj/classes/engl238")) 158 159 ("CS426" ("~/proj/classes/cs426") 160 (:base "pdf-uh" 161 :path "~/proj/classes/cs426")) 162 163 ("Plans" ("~/proj/wiki/plans/" 164 :default "TaskPool" 165 :major-mode planner-mode 166 :visit-link planner-visit-link) 167 (:base "planner-xhtml" 168 :path "~/proj/notmine/planner-out")) 169 )) 170 171;; Wiki settings 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/") 176 ;; abbreviations 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/"))) 184 185;;; Functions 186 187;; Turn relative links into absolute ones 188(defun my-muse-pdf-make-links-absolute (str &rest ignored) 189 "Make relative links absolute." 190 (when str 191 (save-match-data 192 (if (string-match "\\`[/.]+" str) 193 (replace-match "http://mwolson.org/" nil t str) 194 str)))) 195 196;; Make sure my interproject links become absolute when published in 197;; PDFs 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))) 201 202;; Switch to the given project and prompt for a file 203(defun my-muse-project-find-file (project) 204 (interactive) 205 (let ((muse-current-project (muse-project project))) 206 (call-interactively 'muse-project-find-file))) 207 208(defun my-muse-blosxom-finalize (file output-path target) 209;; (my-muse-prepare-entry-for-xanga output-path) 210;; For now, do nothing. 211 ) 212 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. 217 218If FILE is not specified, use the published version of the current file." 219 (interactive 220 (list 221 (expand-file-name (concat (muse-page-name) muse-blosxom-extension) 222 (muse-style-element 223 :path (car (muse-project-applicable-styles 224 buffer-file-name 225 (cddr (muse-project-of-file)))))))) 226 (save-match-data 227 (muse-with-temp-buffer 228 (muse-insert-file-contents file) 229 ;; surround first line in <h3></h3> 230 (goto-char (point-min)) 231 (insert "<h3>") 232 (end-of-line) 233 (insert "</h3>") 234 ;; treat example regions properly 235 (let (beg end) 236 (while (re-search-forward "<pre[^>]*>" nil t) 237 (setq beg (match-end 0)) 238 (setq end (if (re-search-forward "</pre>" nil 1) 239 (match-beginning 0) 240 (point))) 241 (save-restriction 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)) 248 " ")))) 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) 256 (replace-match " ")) 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")))) 268 269;; Turn a word or phrase into a clickable Wikipedia link 270(defun my-muse-dictize (beg end) 271 (interactive "r") 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 "]]"))) 276 277(defun my-muse-surround-math (&optional beg end) 278 "If a region is higlighted, surround it with <math>...</math>. 279If no region is highlighted, insert <math></math> and leave the point 280between the two tags." 281 (interactive (list (ignore-errors (mark)) (point))) 282 (if (and beg end) 283 (save-restriction 284 (narrow-to-region beg end) 285 (goto-char (point-min)) 286 (insert "<math>") 287 (goto-char (point-max)) 288 (insert "</math>")) 289 (insert "<math>") 290 (save-excursion (insert "</math>")))) 291 292(defun my-muse-cdotize-region (beg end) 293 (interactive "r") 294 (save-restriction 295 (narrow-to-region beg end) 296 (goto-char (point-min)) 297 (while (re-search-forward " *\\* *" nil t) 298 (replace-match " \\\\cdot ")))) 299 300;;; Key customizations 301 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) 323 324;;; Custom variables 325 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\" />")) 350(custom-set-faces 351 '(muse-bad-link ((t (:foreground "DeepPink" :underline "DeepPink" :weight bold))))) 352 353;;; muse-init.el ends here 354