User super key for meta commands in emacs
Asked Answered
G

2

10

I'm trying to learn emacs and would like to use the super key on my keyboard for any meta commands in emacs, because I use dwm as my window manager and it uses the meta key extensively. I have read this page, using it to try

(setq x-meta-keysym 'super)
(setq x-super-keysym 'meta)

with no luck. Ideally I'd like to simply flip them, but only in emacs. when I inspect the variables x-meta-keysym and x-super-keysym with C-h v the commands do seem to be evaluated correctly. When I check the super key with the linux utility xev it confirms that the key I'm pressing is mapped to Super_L.

Gilmore answered 24/9, 2013 at 0:17 Comment(3)
This works for me. However, your window manager will intercept keypresses before Emacs sees them. So if your window-manager uses the super key at all, you'll get conflicts that may make it seem like Emacs isn't working properly.Linders
When I use them, I try to use M-x and see if it has any affect. When I try with my super key, I just insert an x into the buffer. But when I try with the meta key, M-x still works. So I don't think its the windows manager.Gilmore
The original code worked for me. It is very funny to use the super key for emacs instead of the Window Manager. Shows commitment to emacs :)Bullock
G
5

So, it turns out that the above commands work when emacs is not used in terminal mode. I had been trying it in the terminal exclusively which is why it wasn't working. I'm not sure how to fix it in the terminal, but it's good enough I suppose.

edit: it was the terminal emulator that was gobbling the keypresses before they got to emacs, so the original commands do work, so long as the keypress actually makes it to emacs.

Gilmore answered 4/10, 2013 at 0:7 Comment(0)
D
9

I agree with @Tyler

In my case I use dwm as window manager, so meta (ALT) key is used to control almost all its features. When using emacs, meta key conflicts with some key bindings, eg: when I'm moving around words M-f or Mb (that's why I came to this thread ;)), so I found three choices to get rid with this issue:

1) change emacs key binding and use super key as meta key

(setq  x-meta-keysym 'super
       x-super-keysym 'meta)

Both symbols (variables) are required, because if you just use only x-super-keysym 'meta, it enables both keys as meta key. If you just use only x-meta-keysym 'super, it disables both and de command buffer will return s-x is undefined.

2) change dwm key binding for meta to super key in config.h file. take a look in http://dwm.suckless.org/customisation/windows_key

 /* key definitions */
 -#define MODKEY Mod1Mask /* meta (ALT) key */
 +#define MODKEY Mod4Mask /* super (windows or cmd) key */

3) override xmodmap keymap bindings swapping mod1 to super and mod4 to meta (be sure to check what xmodmap returns at first glance, and not affect keybindings of other programs)

Finally, I recommend not to change default emacs meta key because is less comfortable to your fingers and may cause you to respond slowly to keystrokes. Try options 2 or 3 depending your environment.

Disheveled answered 11/8, 2014 at 4:36 Comment(0)
G
5

So, it turns out that the above commands work when emacs is not used in terminal mode. I had been trying it in the terminal exclusively which is why it wasn't working. I'm not sure how to fix it in the terminal, but it's good enough I suppose.

edit: it was the terminal emulator that was gobbling the keypresses before they got to emacs, so the original commands do work, so long as the keypress actually makes it to emacs.

Gilmore answered 4/10, 2013 at 0:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.