Nemacs, nevim

Had a discussion recently with Yaroslav on switching to Emacs or vi. And I tried again and I failed. The reason is so stupidly obvious it’s hard to explain. You see, I got this:


This is not a cultural thing. I need to switch my keyboard layout, hundreds of times a day. And the Cmd+Space combo is the most worn one on my keyboard, by far.

However, the problem is much deeper. The problem is what I call the text-meta-ui, and it boils down to escaping. Let me explain. A standard OS X app is driven by keyboard shortcuts, usually like so:


The beauty of Cocoa is that all the keyboard shortcuts implemented that way will be interpreted based in the keycode only. That means that independently of current keyboard layout, the commands get interpreted unambigously. Find is Cmd+F and so on. So if I am in a Russian-language file, and I need to find something, I never change my layout to anything - the shortcut for the find dialog works out of the box, the tab key is idempotent in all layouts, same for Enter/Return. No switching.

Now, some apps are buggy in that regard. Carbon apps do not honor the keycode convention until their authors have paid attention - all Adobe apps for OS X had this huge omission which make working with them akin to swimming in glue - it’s been enough to switch your layout and bam! all of your shortcuts are dead. TextMate bundles have the same gaping problem - when you are on the different layout, all of your shortcuts fall through to the viewport. Given that Textmate is now a dormant project, I don’t expect the problem to be fixed, but who knows.

Now let’s look at Aquamacs from this perspective (I am using it as an example). What is the shortcut for “Help”? C-h (Ctrl-and-then-h). Let’s call it up.


So far so good. Now let’s switch the layout and try that again.


Now this is what I call the meta WTF of UNIX editors. Aquamacs recognizes my input based on characters, not keycodes - therefore, when I am in the russian layout any kind of meta-command will involve a kbd switch. And not only that - the real annoyance is when the argument for the meta-command itself is going to be the in Russian as well. Not one, but two keyboard switches (one to go into meta mode, one to return to literal input in meta mode). And unfortunately, in that sequence:


This, for me, is a killer. Four times I’ve tried to start with the ubergeek editors, and every time it stopped at this very moment.

When you have to switch the keyboard layout. And yes, I know that you can toggle the layout temporarily on OS X - this does not scale.

So a question (for folks still reading this) - how do you handle Emacs/Vi(m) with multiple keyboard layouts (short of remapping the keyboard switch to capslock which does not really solve the problem)? Googling for discussions on that subject did not yield anything meaningful.