为自定义标题自定义速度条



我一直在保存带有以下标题的笔记文件

###---章节##--分节#-subobservation

有没有一种方法可以自定义速度条来浏览这些?现在M-x speedbar只给了我目录列表。到目前为止,我一直在使用"M-x发生#-"来达到这个目的。

您可以使用一个简单的派生模式和imenu。例如,假设您的笔记位于扩展名为".notes"的文件中:

(define-derived-mode notes-mode text-mode "notes"
"Mode for editing my notes."
(setq imenu-generic-expression (list '(nil "^\s-*[#]+[-]+\s-*\(.+\)" 1))))
(add-to-list 'auto-mode-alist '("\.notes" . notes-mode))
(eval-after-load "speedbar"
'(speedbar-add-supported-extension ".notes"))

正则表达式有点粗糙,但你已经明白了。如果你想让页眉突出,你也可以对其进行字体锁定。

在文件的第一行添加-*- mode: outline-mode; outline-regexp: "#+" -*-(以及scottrazer建议的(eval-after-load "speedbar" '(speedbar-add-supported-extension ".notes"))),就应该进行设置。

但正如event_jr所提到的,您最好将文件的扩展名重命名为".org",并将"#"字符替换为"*"。

组织模式基本上是大纲模式的超集(大得多)。

最新更新