;;; 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 "

") (end-of-line) (insert "

") ;; treat example regions properly (let (beg end) (while (re-search-forward "]*>" 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
(goto-char (point-min)) (while (re-search-forward "\n" nil t) (replace-match "
"))))) ;; get rid of 2 spaces together and merge lines (goto-char (point-min)) (while (re-search-forward (concat "[" muse-regexp-blank "\n]+") nil t) (replace-match " ")) ;; remove trailing space (goto-char (point-min)) (while (re-search-forward " *

*" nil t) (replace-match "

")) ;; make relative links work (goto-char (point-min)) (while (re-search-forward "href=\"[/.]+" nil t) ; (replace-match "href=\"http://www.mwolson.org/" nil t)) (replace-match "href=\"http://www.flyzhy.org/" nil t)) ;; copy entry to clipboard (clipboard-kill-ring-save (point-min) (point-max))))) ;;;###autoload ;; make the title of the page into the index (defun ywb-muse-generate-index (&optional project-list) "Generate the index of all wikifile except the file in the \"website\" project" (unless project-list (setq project-list (list (car (muse-project))))) (let (project-files) (muse-with-temp-buffer (dolist (project project-list) (setq project-files (muse-project-file-alist project)) (progn (insert "* " project "\n")) (dolist (file project-files) (unless (or (equal (car file) "WelcomePage") (equal (car file) "WikiIndex")) (insert " - [[" project "#" (car file) "][" (save-excursion (set-buffer (generate-new-buffer "*index*")) (insert-file-contents (cdr file)) (goto-char (point-min)) (setq title (if (re-search-forward "^#title" nil t) (buffer-substring (point) (line-end-position)) (car file))) (kill-buffer (current-buffer)) title) "]]\n"))) (insert "\n")) (buffer-string)))) ;;; Key customizations (global-set-key "\C-cpl" 'muse-blosxom-new-entry) (global-set-key "\C-cpL" #'(lambda () (interactive) (my-muse-project-find-file "Blog"))) (global-set-key "\C-cpi" #'(lambda () (interactive) (my-muse-project-find-file "Private"))) (global-set-key "\C-cpn" #'(lambda () (interactive) (my-muse-project-find-file "MyNotes"))) (global-set-key "\C-cpp" #'(lambda () (interactive) (my-muse-project-find-file "Plans"))) (global-set-key "\C-cpr" #'(lambda () (interactive) (my-muse-project-find-file "Projects"))) (global-set-key "\C-cps" #'(lambda () (interactive) (my-muse-project-find-file "Classes"))) (global-set-key "\C-cpw" #'(lambda () (interactive) (my-muse-project-find-file "Website"))) (global-set-key "\C-cpx" 'my-muse-prepare-entry-for-xanga) ;;; Custom variables (custom-set-variables '(muse-blosxom-base-directory "~/proj/wiki/blog/") '(muse-colors-autogen-headings (quote outline)) '(muse-colors-inline-image-method (quote muse-colors-use-publishing-directory)) '(muse-html-charset-default "utf-8") '(muse-html-encoding-default (quote utf-8)) '(muse-html-footer "~/personal-site/muse/generic-footer.html") '(muse-html-header "~/personal-site/muse/generic-header.html") '(muse-html-meta-content-encoding (quote utf-8)) '(muse-html-style-sheet " ") '(muse-latex-header "~/personal-site/muse/header.tex") '(muse-mode-hook (quote (flyspell-mode footnote-mode))) '(muse-publish-comments-p t) '(muse-publish-desc-transforms (quote (muse-wiki-publish-pretty-title muse-wiki-publish-pretty-interwiki))) '(muse-wiki-publish-small-title-words (quote ("the" "and" "at" "on" "of" "for" "in" "an" "a" "page"))) '(muse-xhtml-footer "~/personal-site/muse/generic-footer.html") '(muse-xhtml-header "~/personal-site/muse/generic-header.html") '(muse-xhtml-style-sheet " ")) (custom-set-faces '(muse-bad-link ((t (:foreground "DeepPink" :underline "DeepPink" :weight bold)))) '(muse-link ((t (:foreground "blue" :underline "blue" :weight bold))))) ;;; muse-init.el ends here