5

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.

Dan
  • 32,584
  • 6
  • 98
  • 168
Jason Mirk
  • 713
  • 3
  • 15
  • 1
    While 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 Answers1

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
  • 1
    The 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
  • Yes I ended up using orgmode. – Jason Mirk Jul 10 '15 at 00:02
  • @lawlist Great idea, let me know if you wind up writing code to remove frames from speedbar. – incandescentman Jul 23 '15 at 03:36