Emacs: Caps lock as M-x

Inspired by Lennart Borgman’s recent post on help.gnu.emacs about binding Caps Lock to M-x on Microsoft Windows, I set my system up with the Linux equivalent.

To make Caps Lock a shortcut for M-x, add the following lines to your ~/.emacs:

(if (eq window-system 'x)
    (shell-command "xmodmap -e 'clear Lock' -e 'keycode 66 = F13'"))
(global-set-key [f13] 'execute-extended-command)
  • Caps Lock is definitely better as a control key. Your pinky finger will thank you for it. Luckily on my Japanese iBook they put the Control key where the Caps Lock key should be already.

    I wonder if it would be possible to make hitting Alt twice be M-x without interfering with the other M- bindings.

  • I agree, Caps is much better as Control. I rarely press M-x, due to it’s inefficiency relative to other Emacs bindings. You use control mxh more than M-x. And caps is right on the home row, next to all those keys you use it with.

    What you might do is rebind M-x to a function key.

  • I went ahead and added that key-binding to my .emacs and it seems like an ergonomically useful addition.

  • Yeah, count me as another one that thinks caps lock is better served as a Control key.

    I’ve got M-x bound to C-x C-m (and C-c C-m because I’m spastic) which are a lot easier to type than M-x IMHO.

  • This is a really neat idea. Unfortunately, it doesn’t seem to be working for me. I assume it’s either because I run “emacs -nw” inside a urxvt session, or because I’ve already got caps lock modded to be Super in my .Xmodmap (my Model M doesn’t have a Super key).

    Spooky. My captcha is “Daniels.”

    best wishes,

  • p.daniels: It’s your Xmodmap, then. =)