better console/keyboard menus for emacs

Development Consulting Articles

News

One of the projects I’m working on is in Ruby on Rails, and I’m using emacs-rails (with some small tweaks) as the development environment.

Emacs rails works fine, except for one thing: the navigation menus (x-popup-menus) are awkward when you want to use the keyboard. So I thought I’d switch on the rails-always-use-text-menus option. Which didn’t actually work, but I fixed that bit.

Rails-always-use-text-menus uses tmm-prompt, which is the standard function on emacs to mimic drop-down menus on the console. and it’s almost as horrible as x-popup-menu: if the items in the menu aren’t static you can’t predict the which key activates which item, and it takes up a lot of screen space:

Which key can I press to go to the UserPreference model?

Before

I really like iswitch buffers for buffer navigation, and it seemed to me that it should be possible to navigate the menus using the same technique, even for nested menus.

So here is iswitch-menu, a direct replacement for tmm-prompt and/or x-popup-menu. It’s not quite finished yet – I’m working out the last issues with some of the more “interesting” constructs used by the menubar keymap – but it’s more than adequate for use with emacs-rails, at least.

Now, I can just type some substring of the name of the model, and go there

after, step 1

First character typed, we can see which models still match

after2.png

Second character typed, only one model still matches.

after3.png

Pressing TAB completes the typed text, and goes to the selected model if there’s only one. Pressing ENTER opens the first matched model. See also the iswitchb documentation for available tweaks and key bindings.

Get iswitch-menu at github