Sunday 05 May 2024 Automagic outline of your Elisp code ==================================== Looking for a method to get an outline of my Elisp code, I stumbled on a nice solution, just using the build in outline functionality. This was buried in a large documentation page from Emacs-Leuven [1]. outline-minor-mode ------------------ With outline-minor-mode you can outline your code. Add this to your ~/.emacs: (add-hook 'outline-minor-mode-hook (lambda () (when (and outline-minor-mode (derived-mode-p 'emacs-lisp-mode)) (hide-sublevels 1000)))) Eval your .emacs or restart Emacs. Open an elisp code file and then run: M-x outline-minor-mode Now your Elisp code is shown in an outline format: * Every defun is collapsed to a single line, ending with three dots ("ellipses"). This not only works on defuns, but f.e. in your init file it collapses the use-package sexps, and so on. reveal-mode ----------- Next, run: M-x reveal-mode Go to a line with a collapsed defun, move point to the end of the line. The moment point enters the three dots, review-mode unhides the code of the sexp. Move down and at the moment point leaves the sexp, review-mode collapses it again. Works fine ---------- Outline mode uses `C-c @' as prefix, which results in some pretty finger wrecking keybindings. The combination reveal-mode with outline-minor-mode takes away the necessity to use these key chords most of the time. All in all this is a wonderful solution, completely with build in tools. Happy coding! [1]: https://emacs-leuven.readthedocs.io/en/stable/ Last edited: $Date: 2024/05/05 19:25:06 $