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

::-- nickcheng [2007-01-13 03:30:15]

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. 如何方便的加载配置

一般的配置都是写在.emacs中的, 不过时间一长,emacs文件就会变得冗长, 可读性和可维护性很差.为了解决这个问题, 就有了下面的程序

(mapc '(lambda (file)
         (load (file-name-sans-extension file)))
      (directory-files "~/emacs.d/init.d/" t "\\.el$"))

这三行语句的作用就是加载指定目录中的所有扩展名为el的文件. 文中的目录我是放在了HOME(~/)下的"emacs.d/init.d". 所有配置就可以按照不同的功用, 拆成不同的.el文件,分别放于“emacs.d/init.d”下。

需要注意的一点是, 默认是按照文件名的字母顺序来加载.el文件的, 所以如果你的.el文件之间有依赖的话, 就需要在文件名前缀数字来避免加载的失败。

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. 在 tab 上按中键会关闭 buffer,按右键则弹出切换菜单,可以在当前 tabgroup 或其它 tabgroup 中切换。
  2. 加入移动 tab 功能。在原先 scroll 按钮的基础上加入鼠标中键和右键的处理,例如,在 ">" 上按右键,会将 tab 右移,按中键则移到最右处。

  3. 增加快捷键来切换 buffer。定义了 0~9, a~z 这些快捷键来快速地切换 buffer。
  4. 增加 M-x tabbar-goto-group,配合自动完成来快速切换到某 tab group。

1.3.4.1. 安装

1.3.4.2. 配置

在.emacs文件中增加如下代码:

(require 'tabbar)
(setq tabbar-speedkey-use t)
(setq tabbar-speedkey-prefix (kbd "<f1>"))
(tabbar-mode 1)

这里对应的上面的功能3中的快捷键为"F1"

1.3.5. Snippets like TextMate

2. 交流反馈

修改 -- -- flyinflash [2010-01-11]

2.1. 常见问题

2.2. 讨论

Emacs23 (last edited 2010-01-11 17:55:01 by flyinflash)