Comments on 2024-11-18 Discovering functions and variables in Elisp files

I like your discover-public-api method.

My usual solution for this is more interactive. I use outline-minor-mode (which I generally enable) and outline-cycle-buffer to fold the code to just headings which is mostly defuns and other defs. Usually files are organized well with public and private methods separated in reasonable sections, letting me skim the API.

Another method is to use a keybinding of imenu (or consult-imenu which I bind to M-g i) and some useful completion system (I use vertico). If using orderless, with a typical configuration of ! as negation (orderless-not), then inputting !– (that’s two hyphens, it looks like an m dash in this preview) will filter out all private defs. If you want this in a buffer, embark-collect or embark-export will do.

I think the nice thing about these approaches is that they generalize to more than just elisp (particularly if there’s some convention similar to --).

– hmelman 2024-11-20 16:07 UTC