0

I've been keeping note files with the following header

###--- section
##-- subsection
#- subsubsection

Is there a way to customize speedbar to navigate over these? Right now M-x speedbar just gives me directory listing. So far I've been using "M-x occur #-" for this purpose.

Yaroslav Bulatov
  • 57,332
  • 22
  • 139
  • 197

2 Answers2

2

You could use a simple derived mode and imenu. For example, suppose your notes are in files with the extension ".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"))

The regexp is a bit crude, but you get the idea. You could font-lock the headers too if you want to make them stand out.

scottfrazer
  • 17,079
  • 4
  • 51
  • 49
1

Add -*- mode: outline-mode; outline-regexp: "#+" -*- on the first line of your file (together with the (eval-after-load "speedbar" '(speedbar-add-supported-extension ".notes")) suggested by scottfrazer) and you should be set.

But as event_jr mentions, you might be better off renaming your file with a ".org" extension and replacing your "#" chars with "*".

Org-mode is basically a (much larger) superset of outline-mode.

Stefan
  • 27,908
  • 4
  • 53
  • 82