Emacs的代码折叠

1 Outline mode

缺省是org方式来确定结构(准确地说是org继承了Outline的方式)

  • Very important

** Less important *** A detail And the rest is text between the headers.

但可以通过修改outline-regexp来定制,比如emacs-lisp-mode中可定义为"("

其它: 可将一节上移、下移,可升级、降级;可在同级之间导航

结论: 可用作major-mode,非常适合写文档

2 HideShow

很多major-mode都支持

可设置搜索时是否不搜索折叠的内容: code (搜索代码), comment(搜索注释), t(都搜索), nil(都不搜索) (注意需要先打开search-invisible)

缺点: 折叠的样式(face)不能定制

结论: 适合代码

3 FoldingMode

Not part of GNU Emacs

缺省通过{{{和}}}来表示段落, 可通过定制folding-mode-marks-alist来定制各个级别采用相同的marker 缺省支持用右键来折叠

可手工折叠选定范围

缺点: 层级关系不能清楚呈现

结论: 需要特殊marker。适合通过在注释中添加标记来自定义大的章节,结合hideshow使用

4 AllOut

part of GNUEmacs/XEmacs

???

5 其它

5.1 set-selective-display

指定隐藏缩进n列以上的行比如C-5 M-x set-selective-display会隐藏所有缩进大于5列的行不带参数执行set-selective-display,则取消可作为没有hideshow时的补充

5.2 FoldDwim

统一UI,支持Outline, HideShow, folding, tex-fold, nxml-outln

5.3 foldit

6 视觉效果

6.1 hideshowvis / wuxch-hideshow / hideshow-fringe

6.2 allout-widgets

6.3

posted @ 2011-04-11 06:57  巴蛮子  阅读(3865)  评论(6编辑  收藏  举报