含有章节索引的中文 文章模板

::-- ["nickcheng"] [DateTime(2007-01-13T03:30:15Z)] TableOfContents

1. Emacs23 (Unicode branch)

Emacs23是Emacs在CVS中的一个分支: emacs-unicode-2 branch, 这个分支的内部编码改为了Unicode. 这样一来, 在Emacs21和Emacs22中困扰咱们的中文问题就直接迎刃而解了! 再也不用配置那么一大堆CJK的东东了!

1.1. 下载

1.1.1. Win32平台

1.1.2. Linux平台

1.1.3. 其他平台

1.1.3.1. MacOS

1.1.3.2. Any others?

1.2. 配置

1.2.1. 用于Python开发的配置

在啄木鸟, 当然要说Python相关的话题了!

1.3. 技巧

1.3.1. .emacs文件的位置

1.3.2. 如何方便的加载配置

1.3.3. Folding

参考: http://groups.google.ca/group/comp.lang.python/browse_thread/thread/43a4d75404cc64fe/956f1c2d37f93995?&hl=en#956f1c2d37f93995 python-mode不带folding功能. 我们只能使用Emacs内建的outline-minor-mode, 来为python设置不同的outline-regexp和outline-level. 参考下面的代码:

;; setup python mode
(setq auto-mode-alist ; trigger python mode automatically
      (cons '("\\.py$" . python-mode) auto-mode-alist))
(setq interpreter-mode-alist
      (cons '("python" . python-mode)
            interpreter-mode-alist))
(autoload 'python-mode "python-mode" "Python editing mode." t)
; add my customization
(add-hook 'python-mode-hook 'my-python-hook)
; this gets called by outline to deteremine the level. Just use the length of the whitespace
(defun py-outline-level ()
  (let (buffer-invisibility-spec)
    (save-excursion
      (skip-chars-forward "\t ")
      (current-column))))
; this get called after python mode is enabled
(defun my-python-hook ()
  ; outline uses this regexp to find headers. I match lines with no indent and indented "class"
  ; and "def" lines.
  (setq outline-regexp "[^ \t]\\|[ \t]*\\(def\\|class\\) ")
  ; enable our level computation
  (setq outline-level 'py-outline-level)
  ; do not use their \C-c@ prefix, too hard to type. Note this overides some python mode bindings
  (setq outline-minor-mode-prefix "\C-c")
  ; turn on outline mode
  (outline-minor-mode t)
  ; initially hide all but the headers
  (hide-body)
  ; I use CUA mode on the PC so I rebind these to make the more accessible
  (local-set-key [?\C-\t] 'py-shift-region-right)
  (local-set-key [?\C-\S-\t] 'py-shift-region-left)
  ; make paren matches visible
  (show-paren-mode 1)
) 

功能

快捷键

折叠所有(hide-sublevels)

C-c C-q

展开所有(show-all)

C-c C-a

折叠当前(hide-entry)

C-c C-c

展开当前(show-entry)

C-c C-e

1.3.4. Tab Bar

在smth.org的Emacs版上看到zslevin (Levin Du)发表的他改的比较顺手的Tabbar, 自己试了以下, 感觉还不错.

原地址: http://www.newsmth.net/bbstcon.php?board=Emacs&gid=49730

1.3.4.1. 安装