Monday 6 July 2015

Parallels, Ubuntu, Emacs - weird Meta key behaviour

I'd been tearing my hair out over an issue I was having with Emacs (24.3.1) on an Ubuntu (14.04) VM running under Parallels (10.1.2) where I had to hold down the Meta key and hit the character key twice in order to make it work i.e. in order to get Emacs to respond to M-x I had to type M-x-x, or for M-w I had to type M-w-w.  Whilst this wasn't the end of the world, it was annoying as I want a consistent experience across environments when using Emacs.

I'm not sure where the problem stemmed from, but I do use Karabiner to remap my OSX modifier keys, so that I have Command, Control,  Option, Space, Option, Control, as that way I have two sets of Control and Meta keys, one under each hand.  Anyway, after spending too long trying to do more and more convoluted remapping in Karabiner to work around the problem (and failing) I discovered a far simpler solution in Parallels itself.

Opening up the configuration for the VM (Actions > Configure ...) then selecting the 'Hardware' tab, then 'Mouse & Keyboard' and clicking 'Shortcuts' presents you with a list of keyboard mappings (e.g. Command+x -> Ctrl+x).  Clicking the '+' symbol allows you to add further mappings and if you select 'Alt' in the 'From' row and 'Alt' in the 'To' row this maps 'Option' to 'Alt' and voila the Meta key works as expected in Emacs in the Ubuntu VM.

6 comments:

  1. I'm surprised that it seems like we're the only two people in the world that have been annoyed by this issue, but thank you for posting this fix!! I was not going to stumble across that for some time, but now I can copy from one C file to another without clicking all over the place.

    Thanks!!!
    Mike

    ReplyDelete
  2. Thank you, also, for this post. I can only conclude that the people at Parallels have little experience with actually using linux. Emacs isn't the only place the meta key is useful: bash command line editing uses it, as well.

    ReplyDelete
  3. Thanks man ! Really appreciate it.

    Do you happen to know this:
    If using e.g. QtCreator and you have a symbol, like a method name in C++ the cursor would change to a pointing hand under VirtualBox. You would then use Ctrl + MouseClick to jump to the definition. With Parallels the cursor does not change put it jumps to the definition.

    ReplyDelete
  4. Glad to see this blog! I've been experiencing the exactly same trouble.
    Thanks for your help! Appreciate!

    ReplyDelete
  5. I use Parallels 17 with Ubuntu 16.04.7 and had the *same hair pulling problem*. I just stumbled on this and ha ha! it solved the problem!! THANKS!!!!

    ReplyDelete