;;; muse-init.el --- Initialize Emacs Muse ;; Author: Michael Olson ;; Modified by Haiyong Zheng flyzhy.org@gmail.com ;; In order to see the scripts that I use to publish my website to a ;; remote webserver, check out ;; http://www.mwolson.org/projects/SiteScripts.html. ;;; Setup ;; Add to load path ;(add-to-list 'load-path "/home/mwolson/proj/emacs/muse/mwolson/lisp") ;(add-to-list 'load-path "/home/mwolson/proj/emacs/muse/mwolson/experimental") (add-to-list 'load-path "~/Emacs/Extensions/EmacsMuse") (add-to-list 'load-path "~/Emacs/Extensions/EmacsMuse/experimental") (add-to-list 'load-path "~/Emacs/Extensions/EmacsMuse/contrib") ;; Initialize (require 'outline) ; I like outline-style faces (require 'muse) ; load generic module (require 'muse-colors) ; load coloring/font-lock module (require 'muse-mode) ; load authoring mode (require 'muse-blosxom) ; load blosxom module (require 'muse-journal) ; load journal module (require 'muse-docbook) ; load DocBook publishing style (require 'muse-html) ; load (X)HTML publishing style (require 'muse-latex) ; load LaTeX/PDF publishing styles (require 'muse-texinfo) ; load Info publishing style (require 'muse-wiki) ; load Wiki support (require 'muse-xml) ; load XML support ;(require 'muse-message) ; load message support (experimental) ;(require 'muse-srctag) ; load srctag support (require 'tp-muse-highlight) ;; Setup projects ;; Here is an example of making a customized version of your favorite ;; publisher. All this does is run `my-muse-blosoxm-finalize' on the ;; published file immediately after saving it. (unless (assoc "my-blosxom" muse-publishing-styles) (muse-derive-style "my-blosxom" "blosxom-xhtml" :final 'my-muse-blosxom-finalize) (muse-derive-style "my-pdf" "pdf" :before 'my-muse-pdf-prepare-buffer) (muse-derive-style "my-xhtml" "xhtml" :header "~/personal-site/muse/en-header.html" :footer "~/personal-site/muse/en-footer.html")) ;; Here is my master project listing. ;(setq muse-project-alist ; `( ; ("Website" ("~/proj/wiki/web/" ; :force-publish ("WikiIndex") ; :default "WelcomePage") ; (:base "my-xhtml" ; :path "~/personal-site/site/web") ; (:base "my-pdf" ; :path "~/personal-site/site/web" ; :include "/CurriculumVitae[^/]*$")) ; ; ("Projects" ("~/proj/wiki/projects/" ; :force-publish ("WikiIndex") ; :default "WelcomePage") ; (:base "my-xhtml" ; :path "~/personal-site/site/projects")) ; ; ("Blog" (,@(muse-project-alist-dirs "~/proj/wiki/blog") ; :default "index") ; ; ;; Publish this directory and its subdirectories. Arguments ; ;; are as follows. The above `muse-project-alist-dirs' part ; ;; is also needed, using Argument 1. ; ;; ; ;; 1. Source directory ; ;; 2. Output directory ; ;; 3. Publishing style ; ,@(muse-project-alist-styles "~/proj/wiki/blog" ; "~/personal-site/site/blog" ; "my-blosxom")) ; ; ("MyNotes" ("~/proj/wiki/notes/" ; :force-publish ("index") ; :default "index") ; (:base "xhtml" ; :path "~/personal-site/site/notes") ; (:base "my-pdf" ; :path "~/personal-site/site/notes")) ; ; ("Private" ("~/Documents" "~/Documents/work-school" ; :default "movielist") ; ,@(muse-project-alist-styles "~/Documents" ; "~/Documents" ; "pdf")) ; ; ("Classes" (,@(muse-project-alist-dirs "~/proj/wiki/classes") ; :default "index") ; ,@(muse-project-alist-styles "~/proj/wiki/classes" ; "~/personal-site/site/classes" ; "xhtml")) ; ; ("Plans" ("~/proj/wiki/plans/" ; :default "TaskPool" ; :major-mode planner-mode ; :visit-link planner-visit-link) ; (:base "planner-xhtml" ; :path "~/proj/notmine/planner-out")) ; )) ; (setq muse-project-alist ; '(("website" ; my various writings ; ("~/Pages" :default "index") ; (:base "html" :path "~/public_html") ; (:base "pdf" :path "~/public_html/pdf")))) '(("Website" ("~/personal-site/site/web" :force-publish ("WikiIndex") :default "WelcomePage") (:base "my-xhtml" :path "~/personal-site/publish/web")) ("Projects" ("~/personal-site/site/projects" :force-publish ("WikiIndex") :default "WelcomePage") (:base "my-xhtml" :path "~/personal-site/publish/projects")) ("Wiki" ("~/personal-site/site/wiki" :force-publish ("WikiIndex") :default "WelcomePage") (:base "my-xhtml" :path "~/personal-site/publish/wiki")) ("Bookmarks" ("~/personal-site/site/bookmarks" :default "index") (:base "my-xhtml" :path "~/personal-site/publish/bookmarks")))) ;; Wiki settings (setq muse-wiki-interwiki-alist '(("PlugWiki" . "http://plug.student-orgs.purdue.edu/wiki/") ("EmacsWiki" . "http://www.emacswiki.org/cgi-bin/wiki/") ("ArchWiki" . "http://wiki.gnuarch.org/") ;; abbreviations ("FlyZhy" . "http://www.flyzhy.org/") ("MWOLSON" . "http://www.mwolson.org/") ("CERIAS" . "http://www.cerias.purdue.edu/") ("PlannerMode" . "http://www.plannerlove.com/") ("GP2X" . "http://www.gp2x.co.uk/") ("UbuntuLinux" . "http://ubuntulinux.org/") ("PLUG" . "http://plug.student-orgs.purdue.edu/wiki/"))) ;(setq muse-xhtml-extension ".htm") ;;; Functions ;; Turn relative links into absolute ones (defun my-muse-pdf-make-links-absolute (str &rest ignored) "Make relative links absolute." (when str (save-match-data (if (string-match "\\`[/.]+" str) ; (replace-match "http://www.mwolson.org/" nil t str) (replace-match "http://www.flyzhy.org/" nil t str) str)))) ;; Make sure my interproject links become absolute when published in ;; PDFs (defun my-muse-pdf-prepare-buffer () (set (make-local-variable 'muse-publish-url-transforms) (cons 'my-muse-pdf-make-links-absolute muse-publish-url-transforms))) ;; Switch to the given project and prompt for a file (defun my-muse-project-find-file (project) (interactive) (let ((muse-current-project (muse-project project))) (call-interactively 'muse-project-find-file))) ;; Determine whether we are publishing a certain kind of output (defun my-muse-format-p (format) (let ((base (muse-get-keyword :base muse-publishing-current-style))) (when base (string-match format base)))) (defun my-muse-blosxom-finalize (file output-path target) ;; (my-muse-prepare-entry-for-xanga output-path) ;; For now, do nothing. ) ;; Make the current file display correctly in Xanga ;; I call this using C-c p x now. (defun my-muse-prepare-entry-for-xanga (file) "Mangle FILE so that Xanga doesn't bug out, saving to X clipboard. If FILE is not specified, use the published version of the current file." (interactive (list (expand-file-name (concat (muse-page-name) muse-blosxom-extension) (muse-style-element :path (car (muse-project-applicable-styles buffer-file-name (cddr (muse-project-of-file)))))))) (save-match-data (muse-with-temp-buffer (insert-file-contents file) ;; surround first line in
(goto-char (point-min)) (insert "]*>" nil t)
(setq beg (match-end 0))
(setq end (if (re-search-forward "" nil 1)
(match-beginning 0)
(point)))
(save-restriction
(narrow-to-region beg end)
;; change initial spaces to
(goto-char (point-min))
(while (re-search-forward "^ +" nil t)
(replace-match (apply 'concat (make-list
(length (match-string 0))
" "))))
;; change newline to