I would like to write in markdown mode for example and then have a sidebar that shows me a table of contents of the buffer I am currently in.
Asked
Active
Viewed 1,261 times
5
-
1While not a sidebar, the `imenu` library works with `org-mode` and `markdown-mode` among others -- it provides a nice table of contents in the menubar or a mouse-pop-up-menu (e.g., right-click-context-menu, which is especially nice if the menubar is hidden by choice). `imenu` can be activated for supported modes by adding `(imenu-add-menubar-index)` to the major-mode hook. [FYI: speedbar taps into the functionality of imenu and/or etags.] – lawlist Jul 15 '15 at 20:10
1 Answers
3
You can get that, more or less, with M-x speedbar
. It displays the files in the current directory, and lets you expand the files to see a table of contents. (For source code, it shows a list of functions.)
However, you need to tell Speedbar to show contents for Markdown files, by customizing speedbar-supported-extension-expressions
and adding the file extension you use for Markdown files.
By default, Speedbar hides files not matching speedbar-supported-extension-expressions
entirely. You can set speedbar-show-unknown-files
to t
to make it show them in the list, even though it doesn't display an outline for them.

legoscia
- 6,012
- 29
- 54
-
1The original poster is also apparently fond of `org-mode` [based on other recent threads], and said poster may be interested to know that speedbar can create a table of contents for `org-mode` files by adding the `org-mode` file extensions to `speedbar-supported-extension-expressions`. The original poster is not fond of speedbar frames, however, it is possible to modify the source code of speedbar to entirely remove the frame sutff -- unfortunately, that requires semi-advanced `elisp` skills. `sr-speedbar` advices too many functions for my taste, but that is one method of reducing frames. – lawlist Jul 09 '15 at 19:23
-
-
@lawlist Great idea, let me know if you wind up writing code to remove frames from speedbar. – incandescentman Jul 23 '15 at 03:36