I'm hacking together an extension which will display a sidebar with an outline of whatever document you're working on. It was initially written to support writing in markdown-mode, but the technique I'm using (which might be bone-headed) relies on using outline-mode commands like outline-hide-body. As such, the extension should, I think, work for any mode for which these commands have an effect.

So my question is: is there a way to determine if outline-mode commands - and specifically outline-hide-body - are properly defined for a given buffer?

Right now I just rely on a list of major-modes (e.g. org-mode, markdown-mode) for which I know these commands work. But this seems like a relatively weak approach since it ignores e.g. outline-minor-mode which I should probably check for as well. So before I go down the path of trying to enumerate the the major and minor modes I can work with, I thought I should see if there's a better way.

  • As you said, check if outline-minor-mode is on. I doubt (but can't say for sure) many (if any) major modes are "implemented on top of Outline mode" (as org-mode docstring says). – JeanPierre Jul 24 '17 at 11:45
  • Unfortunately that seems insufficient. For example, describe-mode doesn't list outline-minor-mode for markdown-mode (in my nearly stock spacemacs config). Or am I missing/misunderstanding something? – abingham Jul 24 '17 at 11:54
  • markdown-mode does not use outline-minormode but handles outlining itself. – Tobias Jul 24 '17 at 19:49
  • Right, but functions like outline-hide-body work properly in markdown-mode. I think this is because markdown-mode defines outline-regexp. – abingham Jul 25 '17 at 5:50
  • You might consider looking at navi-mode. You might be able to build your package on top of it and save yourself a lot of code. :) – blujay Jul 31 '17 at 0:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.