-->

Emacs Wiki

HOME
http://www.mwolson.org/projects/EmacsWiki.html (old location1) (old location2)
Intro
emacs-wiki.el (wiki mode for Emacs) 则能够把相应的文本转化为 html 文件, 它是作为 Emacs 的一个工具包提供的.
Mailing list
There is an emacs-wiki discussion list dedicated to discussion of emacs-wiki, planner and related modules. The details of this list are available here.

What's Wiki?

Wiki 采用 Wiki Markup 规则来写文本, 这些文本可以被转换成 html 文件(现在已经有工具用来生成 Latex, Docbook 等其它格式的文件). 换句话说是说 Wiki 就是用简单的文本规则来写网页的方式.
王垠对Wiki的简单介绍

配置 emacs-wiki

下面这段配置代码供 emacs-wiki 的初学者参考. 这是从我的 emacs-wiki 的设置代码中抽取出来后经过修改的, 事实上我把自己的和 emacs-wiki 有关的配置代码全放在一个单独的文件中, 有效代码约有 300 多行(还包含了 planner mode 等的配置).

;;; -----------------------------------------------
;;; Emacs Wiki
;;; See
;;;     http://members.iinet.net.au/~mtriggs/emacs-wiki.html
;;; -----------------------------------------------
(require 'emacs-wiki)
(require 'emacs-wiki-menu)
(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-x C-s") (lambda ()
                                (interactive)
                                (save-buffer)
                                (emacs-wiki-publish-files
                                 (list buffer-file-name) nil)
                                ))
            ))
(setq emacs-wiki-use-mode-flags "0644")
(setq emacs-wiki-maintainer "mailto:name@some.where.net")
(setq emacs-wiki-charset-default "gbk")
(setq emacs-wiki-style-sheet "<link rel=\"stylesheet\" href=\"main.css\" media=\"screen\">")
(setq emacs-wiki-inline-relative-to 'emacs-wiki-publishing-directory)

(defun emacs-wiki-preview-source ()
  (interactive)
  (emacs-wiki-publish-this-page)
  (find-file (emacs-wiki-published-file)))

(defun emacs-wiki-preview-html ()
  (interactive)
  (emacs-wiki-publish-this-page)
  (let ((file-name (emacs-wiki-published-file)))
    (if (string-match "/ftp:user_name.*/\\(\\w+\\.html\\)"
                      file-name)
        (browse-url (concat
                     "http://wiki.page.server.net/~user_name/"
                     (match-string 1 file-name)))
      (browse-url (file-name)))))

(setq emacs-wiki-projects
      `(("default" . ((fill-column . 4000)
                      (emacs-wiki-publishing-directory . "~/myweb")
                      (emacs-wiki-directories . ("~/myWiki"))))
        ("work1" . ((fill-column . 4000)
                    (emacs-wiki-publishing-directory
                     .
                     "/ftp:user_name@wiki.page.server.net:/public_html")
                    (emacs-wiki-directories . ("~/PubWiki"))))
        ))
和这段代码有关的 main.css 文件可以从这里获取, 这实际上是从 王垠 的 main.css 修改得来的. 注: 我现在已经改用 Xue Ruinicore.css(以及配套的 GIF 图像文件), 你可以从 他的主页 上获取这些东西, 真的很漂亮!

Fancy table

;;; To get fancy table markup
(require 'emacs-wiki-table)
则可以制作出像下面这样的 table

+------------------------------------------------------------------+ | A table header | +-------------------------------+----------------------------------+ | Column 1 | Column 2 | +-------------------------------+----------------------------------+ |Some text here |More text here, even wrapping to | | |the next line | +-------------------------------+----------------------------------+ |Some text here |More text here, even wrapping to | | |the next line | +-------------------------------+----------------------------------+

指定浏览器

Emacs 缺省最优先调用 gnome-moz-remote 来浏览网页, 你可以在文件 ~/.gnome/gnome-moz-remote 中指定自己喜欢的浏览器. 我在这个文件中放了如下内容, 以指定 firefox 为缺省的浏览器

[Mozilla]
filename=firefox
NEEDS_TERM=false
NREMOTE=ture

往 mail.ustc.edu.cn/staff.ustc.edu.cn 上 publish

在中国科学技术大学的 emacs-wiki 用户可能会需要把自己的 Wiki publish 到学校的邮件服务器上自己的个人主页目录下. 不幸的是 mail.ustc.edu.cnstaff.ustc.edu.cn 这两台服务器上有很多对用户的限制, 而且目前对普通用户而言只能使用 ftp 方式来上传网页, 给用户带来了很大不便, 事实上这正是我的 Wiki 只能在自己的硬盘上躺了N久的原因 :( .

这里是 中国科大电子邮件服务器常问问题 , 其中提到:

5. 如何设置个人主页? 
   邮件服务器用户都可以设置自己的主页: 
   5.1 用ftp 程序登录到服务器上 
       执行以下命令: 
       quote site umask 022 
   5.2 在ftp 程序中执行 
       mkdir public_html 
   5.3 把编辑好的html文件用ftp放到public_html子目录下, 并使开始文件为 
       index.html, 并保证文件有其他用户的读权限(也就是说你必须在上载前 
       必须执行命令 quote site umask 022) 
...
emacs-wiki 的 ftp publish 方式事实上利用了 ange-ftp, ange-ftp 事实上最终通过外部程序, 通常在 Linux 中是 netkits 套件里的程序 ftp, 这个 ftp client 支持 auto-login 的方式, 这给用户带来不少方便, 比如可以省去手动输入用户名和口令, 自动执行一些指令等(参看 ftp 和 netrc 的 manual page). 为了让 Emacs 的 ange-ftp 在上传网页之前就执行
quote site umask 022 
我试着写了一个 ~/.netrc 文件
machine host_name
login my_id
password my_password

macdef init
quote site umask 022

不过这并不解决问题, 尽管不用再手动输入 password 了.

分析了 Emacs 的代码 ange-ftp.el 才发现 ange-ftp 是自己解析 ~/.netrc 来获取 machine, loginpassword 等参数的, 而我写在 init 这个 macro 里的命令序列却没有被 ange-ftp 所执行.

又仔细分析了一下 ange-ftp 的代码, 发现 ange-ftp 提供了一个 hooks 供用户在 ftp 进程启动后插入自己的动作, 于是我把下面的代码放在了我的 Emacs 的 init file 中:

(require 'ange-ftp)
(add-hook 'ange-ftp-process-startup-hook
          (function
           (lambda ()
             (and (string= host "host_name")
                  (ange-ftp-raw-send-cmd proc
                                         "quote site umask 022")))))
这段代码在 ange-ftp 启动 ftp 进程后判断所连的站点名是否是 "host_name", 如果是的话就向相应的 ftp 进程发送命令 "quote site umask 022" 以改变 ftp server 的 umask 设置.