Custom super key for meta commands in emacs

I am 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 read this page using it to try

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

bad luck. Ideally, I would just like to flip them, but only in emacs. when I check the x-meta-keysym and x-super-keysym variables with Ch v, the commands look correctly evaluated. When I check the super-key using the linux xev utility, it confirms that the key pressed is mapped to Super_L.

+6
source share
2 answers

So it turns out that the above commands work when emacs is not used in terminal mode. I tried this in the terminal exclusively, so it did not work. I'm not sure how to fix this in the terminal, but it's good enough, I suppose.

edit: it was a terminal emulator that collected keystrokes before they got to emacs, so the original commands work while keypress actually makes it emacs.

+3
source

I agree with @Tyler

In my case, I use dwm as a window manager, so the meta key (ALT) is used to control almost all of its functions. When using emacs, the meta key conflicts with some key bindings, for example: when I move the words Mf or Mb (why did I come to this topic;)), so I found three options to get rid of this problem:

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

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

Both characters (variables) are required because if you just use the x-super-keysym meta-integration, it includes both keys as a meta key. If you just use x-meta-keysym 'super only, it disables both and the command buffer will return sx undefined.

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

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

3) redefine the xmodmap keymap bindings, replacing mod1 with super and mod4 with meta (be sure to check that xmodmap returns at a glance and does not affect the key binding of other programs)

Finally, I recommend that you do not change the default metacharacter, because it is less convenient for your fingers and can make you respond slowly to keystrokes. Try options 2 or 3, depending on your environment.

+3
source

Source: https://habr.com/ru/post/954464/


All Articles