Differences between revisions 6 and 9 (spanning 3 versions)
Revision 6 as of 2007-01-13 03:53:27
Size: 1123
Editor: nickcheng
Comment:
Revision 9 as of 2007-01-15 05:43:47
Size: 3549
Editor: nickcheng
Comment:
Deletions are marked like this. Additions are marked like this.
Line 28: Line 28:

=== 用于Python开发的配置 ===
'' 在啄木鸟, 当然要说Python相关的话题了! ''
Line 33: Line 36:

=== 如何方便的加载配置 ===

=== 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)
)
}}}

 * 配置完毕后, 可以在python模式下使用快捷键来操作Folding. 快捷键的使用可以参考: http://www.woodpecker.org.cn:9081/graspOnline/learn.tsinghua.edu.cn/homepage/2001315450/emacs_outline.html
  * 注意把文章中的C-o换成上面配置中的C-c
 * 方便起见, 列几个常用的快捷键:
||'''功能'''||'''快捷键'''||
||折叠所有(hide-sublevels)||C-c C-q||
||展开所有(show-all)||C-c C-a||
||折叠当前(hide-entry)||C-c C-c||
||展开当前(show-entry)||C-c C-e||

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

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

1. Emacs23 (Unicode branch)

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

  • 据目前的了解, Emacs的主力都在应对Emacs22的最后的bug, 也许是RMS想现Release Emacs22, 然后再把主力放入Emacs23的开发. -- ["nickcheng"] [DateTime(2007-01-13T03:40:42Z)]

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

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