outline-regexp在elisp文件时标题的层级问题

个人用outline-minor-mode比较多,主要用来显示函数列表。当打开elisp文件时,outline-minor-mode也能有比较好的折叠效果。

但是,我对outline-minor-mode对elisp文件的折叠层次有些疑问。根据manual,标题以及标题的层次是由outline-regexp决定的,它是一个regexp,能够匹配上的行就是一个标题,匹配的长短决定标题的层次,匹配越长,标题层次越低:

The length of the matching text determines the level of the heading; longer matches make a more deeply nested level. Thus, for example, if a text formatter has commands ‘chapter’, ‘section’ and ‘subsection’ to divide the document into chapters and sections, you could make those lines count as heading lines by setting outline-regexp to ‘“chap\|\(sub\)*section”’. Note the trick: the two words ‘chapter’ and ‘section’ are equally long, but by defining the regexp to match only ‘chap’ we ensure that the length of the text matched on a chapter heading is shorter, so that Outline mode will know that sections are contained in chapters. This works as long as no other command starts with ‘chap’.

在elisp-mode中,对应的outline-regexp;;;\\(;* [^\n]\\|###autoload\\)\\|(,这个regexp匹配到;;; 的长度会长于匹配到的(,所以按道理,在elisp中,应该是以(开始的函数标题层次会比以;;;开始的注释层次高,也就是说以;;;开始的标题应该是以(开始的标题的子标题。

但实际情况不是这样,比如下面例子。上面左边是全部展开的文本,光标在第一行第一列,上面右边是outline-hide-subtrees后再outline-show-children后的结果,可以看到,outline-minor-mode显然是把以(开始的函数作为以;;;开始的标题的子标题了。

说实话,这个问题困扰我相当一段时间,一直没搞明白,不知是否有了解这一块的人能给一些提示?谢谢各位!