index all rss twitter github linkedin email

Álvaro Ramírez

17 October 2018 imenu on Emacs eshell

imenu navigation is one of those Emacs gems I didn't discover until much later on. It does what you'd expect in all types of modes. In rare instances, I've found specific modes missing imenu support. Fortunately, this is Emacs and you can fix that.

Eshell has a handy feature to jump back and forth over previous prompts using M-x eshell-previous-prompt (C-c C-p) and M-x eshell-next-prompt (C-c C-n). Upon learning about these two functions, my immediate reaction was to try imenu. Surprisingly, it didn't "just work\n", but a tiny bit of elisp brought balance back to the Emacs universe.

In an eshell mode hook function, one can set the imenu-generic-expression to help it find your favorite prompt:

(setq-local imenu-generic-expression
                  '(("Prompt" " $ \\(.*\\)" 1)))

Ah it's the little things…

eshell-imenu.gif

ps. If wondering why my imenu experience looks a little different, that's because I'm using Abo Abo's wonderful counsel and M-x counsel-semantic-or-imenu.