[xmonad] emacs -nw and xmonad key bindings

Andrew Sackville-West andrew at swclan.homelinux.org
Fri Dec 7 22:27:36 EST 2007

Just posting this up in case anyone comes looking for it. 

I use emacs -nw and xmonad together. It took me some trial and error
to figure this out. I don't know if it applies to the gui-fied emacs.

I have an IBM Model M keyboard (clickey clickey clickey), at 101 keys
(no win key, and whatnot). The following incantation will get you a
Left_Alt key that is recognised by emacs and a Right_Alt key
recognised by xmonad.

in Config.hs 

modMask = mod3Mask

to assign the mod3 key as the key to control xmonad.

In pc101 and pc105 (others?) XkbModel, XkbLayout "us", both Alt keys
are assigned to mod1. You can check this with 


which will show the current mappings. 

execute the following xmodmap expressions

add mod1 = Alt_L  (* see below)
remove mod1 = Alt_R
add mod1 = Alt_R

you can either do these as individual `xmodmap -e 'expression'`
instances or put them in a file and run `xmodmap file`

I do it in my .xinitrc and it gives me control of both xmonad using
Alt_R and emacs using Alt_L.

Hope this helps someone.


* if you look at the output from xmodmap, there is already an instance
  of Alt_L attached to mod1. But it you run this 'add', you'll get a
  second one with a different keycode. I don't know why this is, but
  it's required to get emacs to recognize the key.   
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/xmonad/attachments/20071207/e12ea5a7/attachment.bin

More information about the xmonad mailing list