;;;;;;;;;;;;;;;;;;;;;;;;;;; -*- Mode: Emacs-Lisp -*- ;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; .emacs-wiki.el --- ;; ;; Filename: .emacs-wiki.el ;; Description: emacs-wiki配置模板 ;; Author: 李代斌 ;; Maintainer: 李代斌 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ==================== ;; Emacs Wiki配置模板说明 ;; ==================== ;; ;; 这是一个Emacs-wiki的配置文件模板,它的作用是 ;; ;; - 集中常用的Emacs-wiki的配置选项在一个文件中 ;; - 为新手提供一个入门指南 ;; - 做为中文FAQ的补充,让大家可以少敲几个字:^) ;; - 针对中文Emacs用户解决一个中文的问题 ;; ;; 这个模板的制作原因是出于对Emacs-wiki这个基于[[Emacs]]的Wiki系统喜爱 ;; ,希望你也喜欢它,也欢迎你帮助我完善这个模板。 ;; ;; ============= ;; 下载、安装和使用 ;; ============= ;; ;; * 下载 ;; ;; 地址 http://lidaibin.kmip.net/gentoo/conf/emacs-wiki.el ;; ;; 模板以一个el文件形式(文件名emacs-wiki.el)提供下载,在遵守GNU ;; Public License的原则下分发。 ;; ;; * 安装 ;; ;; 请将下载得到的文件置于硬盘某处(推荐放置在HOME文件夹,也就是.emacs的 ;; 同一个目录,并更名为.emacs-wiki.el),在你的.emacs中加入如下一行 ;; ;; (load-file "path/to/.emacs-wiki.el") ;; ;; 请将"path/to/"改成相应的路径(放置于HOME文件夹即为"~/")。然后用最顺 ;; 手的编辑器进入文件修改,仔细阅读其中的注释项,并且按照指示修改适应你 ;; 的情况,然后保存。重新启动Emacs即可以开始使用Emacs-wiki。 ;; ;; * 使用 ;; ;; Emacs-wiki配置模板中的各项配置使用请参照模板中注释说明,或者参考 ;; Emacs-wiki自带的文档、EmacsWikiNode、Emacs-wiki中文FAQ等资源。 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; * 基本设置 * ;; ;; 都是Emacs-wiki的基本设置,请按照注释修改 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 主程序,必须包含进来,Gentoo下不需要配置这行,已加入/usr/share/emacs/site-lisp/site-gentoo.el ;;(require 'emacs-wiki) ;; 设置Wiki页面存储的目录,Wiki的源文件将存储至此 ;;(setq emacs-wiki-directories '("~/Wiki/webpage")) ;; 设置publish的目录,生成的HTML页面将存储至此 ;;(setq emacs-wiki-publishing-directory "~/publish/webpage") ;; 设置存储源文件使用的默认的文字编码,使用GB2312环境的可以将值更改为gb2312 (setq emacs-wiki-coding-default "gbk") ;; 设置发布HTML页面使用的charset(字符集),使用GB2312环境的可以将值更改为gb2312 (setq emacs-wiki-charset-default "gbk") ;; 设置你的mail地址,它将做为不存在页面的默认链接地址 (setq emacs-wiki-maintainer "mailto:lidaibin@gmail.com") ;; 更改默认页面的名字(一般不用更改) ;;(setq emacs-wiki-default-page "WelcomePage") ;; 更改默认索引页面的名字(一般不用更改) ;;(setq emacs-wiki-index-page "WikiIndex") ;; 启用changelog美化支持,为真时会将changelog也当作Wiki页面发布 ;;(setq emacs-wiki-pretty-changelogs t) ;; 设置inline图片的查找路径,Emacs-wiki会在指定目录的根目录和images目录中查找 ;;(setq emacs-wiki-inline-relative-to 'emacs-wiki-publishing-directory) ;; 定义一个变量emacs-wiki-style-sheet,用于在页眉中指定CSS (setq emacs-wiki-style-sheet "") ;; 定义页眉页脚放置于文件中,如果文件未找到则插入默认的页眉页脚 (setq emacs-wiki-publishing-header "(my-publishing-header)") (setq emacs-wiki-publishing-footer "(my-publishing-footer)") (defun my-publishing-header () (if (file-readable-p "header.wiki") (ignore (insert-file-contents "header.wiki")) ;;这里是默认的页眉 " <lisp>(emacs-wiki-page-title)</lisp> emacs-wiki-meta-http-equiv\" content=\"emacs-wiki-meta-content\" /> emacs-wiki-maintainer\" /> (emacs-wiki-published-name emacs-wiki-home-page)\" /> (emacs-wiki-published-name emacs-wiki-index-page)\" /> emacs-wiki-style-sheet

(emacs-wiki-page-title)


\n" )) (defun my-publishing-footer () (if (file-readable-p "footer.wiki") (ignore (insert-file-contents "footer.wiki")) ;;这里是默认的页脚 "

(if buffer-file-name (concat \"最近更新: \" (format-time-string emacs-wiki-footer-date-format (nth 5 (file-attributes buffer-file-name))) (and emacs-wiki-serving-p (emacs-wiki-editable-p (emacs-wiki-page-name)) (concat \" / \" (emacs-wiki-link-href (concat \"editwiki?\" (emacs-wiki-page-name)) \"Edit\"))) \"\")) 主页 / (concat (and (emacs-wiki-page-file emacs-wiki-home-page t) (not (emacs-wiki-private-p emacs-wiki-home-page)) (concat (emacs-wiki-link-href emacs-wiki-home-page \"Wiki主页\") \" / \")) (emacs-wiki-link-href emacs-wiki-index-page \"索引\") (and (emacs-wiki-page-file \"ChangeLog\" t) (not (emacs-wiki-private-p \"ChangeLog\")) (concat \" / \" (emacs-wiki-link-href \"ChangeLog\" \"Changes\")))) (if emacs-wiki-serving-p (concat \"\" (emacs-wiki-link-href \"searchwiki?get\" \"搜索\") (and buffer-file-name (concat \" / \" (emacs-wiki-link-href (concat \"searchwiki?q=\" (emacs-wiki-page-name)) \"Referrers\"))) \"\"))
\n" )) ;; 自定义函数emacs-wiki-preview-source,快速查看publish的HTML代码 (defun emacs-wiki-preview-source () (interactive) (emacs-wiki-publish-this-page) (find-file (emacs-wiki-published-file))) ;; 自定义函数emacs-wiki-preview-html,快速本地预览生成的HTML (defun emacs-wiki-preview-html () (interactive) (emacs-wiki-publish-this-page) (browse-url (emacs-wiki-published-file))) ;; 自定义函数emacs-wiki-unline-toggle,用于自动对WikiName添加/删除标记 ;;{{{ copy from yason@emacswiki, modified by Yu Li (defun emacs-wiki-unlink-toggle () "Toggle string in the beginning of the current word, to un/make a word emacs-wiki link. The current word depends on the point: if the cursor is on a non-whitespace character, it's considered a word surrounded by whitespace. If the cursor is on a whitespace character, the next word is looked up. This way addressing a word works intuitively after having arrived on the spot using forward-word." (interactive) (save-excursion (with-current-buffer (current-buffer) (if (looking-at "[ \t]") (goto-char (- (re-search-forward "[A-Za-z<>]") 1)) (goto-char (+ (re-search-backward "[^A-za-z<>]") 1))) (if (looking-at "") (delete-char 5) (insert ""))))) ;;}}} ;; 绑定自定义函数到相应的键位组合 (add-hook 'emacs-wiki-mode-hook (lambda () (define-key emacs-wiki-mode-map (kbd "C-c C-h") 'emacs-wiki-preview-html) (define-key emacs-wiki-mode-map (kbd "C-c C-c") 'emacs-wiki-preview-source) (define-key emacs-wiki-mode-map (kbd "C-c C-v") 'emacs-wiki-change-project) (define-key emacs-wiki-mode-map (kbd "C-c C-n") 'emacs-wiki-unlink-toggle) )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; * Emacs-wiki多个project的设置 * ;; ;; 多个project设置,你可以用这种方式来组织你的网站的不同topic ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq emacs-wiki-projects `(("linux" . ((emacs-wiki-directories . ("~/Wiki/linux")) (emacs-wiki-project-server-prefix . "../linux/") (emacs-wiki-publishing-directory . "/data/myweb/public_html/linux"))) ("programming" . ((emacs-wiki-directories . ("~/Wiki/programming")) (emacs-wiki-project-server-prefix . "../programming/") (emacs-wiki-publishing-directory . "/data/myweb/public_html/programming"))) ;; 你可以添加新的project,如下是一个例子 ;; ("Project" . ;; ((emacs-wiki-directories . ("~/Wiki/project")) ;; (emacs-wiki-project-server-prefix . "../project/") ;; (emacs-wiki-publishing-directory . "/data/myweb/public_html/project"))) )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; * 其它 * ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 加入对Emacs可视化表格编辑模块table.el的支持 ;; 请参考Emacs-wiki文档Tables一节以及contrib目录中table.el (require 'emacs-wiki-table) ;; 加入自动生成menu的支持,具体配置请看后面的emacs-wiki-menu配置部分 (require 'emacs-wiki-menu) ;; 启动faq-mode支持,一个编辑faq页面的minor mode ;;(require 'faq-mode) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; * Hack * ;; ;; 一些Hack函数,更改一些东西,解决一些问题 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 解决Emacs-wiki当前存在的与mule-gbk不兼容的问题 ;; 问题:遇到GBK字符时会将其转义,结果导致乱码 ;;{{{ hack emacs-wiki-escape-html-string for mule-gbk support (defun emacs-wiki-escape-html-string (str) "Convert to character entities any non alphanumeric characters outside of a few punctuation symbols, that risk being misinterpreted if not escaped" (when str (let (pos code len) (save-match-data (while (setq pos (string-match (concat "[^-" emacs-wiki-regexp-alnum "/:._=@\\?~#]") str pos)) ;; Work around XEmacs differentiation of char and int (setq code (if (fboundp 'char-to-int) (int-to-string (char-to-int (aref str pos))) (int-to-string (aref str pos)))) (if (string= (charset-short-name (char-charset (aref str pos))) "ASCII") (setq len (length code) str (replace-match (concat "&#" code ";") nil nil str) pos (+ 3 len pos)) (cond ((string= (string (char-syntax (aref str pos))) "w") (setq pos (+ 1 pos))) ((string= (string (char-syntax (aref str pos))) "_") (setq pos (+ 1 pos))) ((string= (string (char-syntax (aref str pos))) "(") (setq pos (+ 1 pos))) ((string= (string (char-syntax (aref str pos))) ")") (setq pos (+ 1 pos))) (t (setq len (length code) str (replace-match (concat "&#" code ";") nil nil str) pos (+ 3 len pos)))))) str)))) ;;}}} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; .emacs-wiki.el ends here