0

Function modifiers in Emacs conflicts with many hotkeys I have (for example, conflicts with i3wm). By using evil I could use evil to avoid most of conflict hotkeys.

However, I do still need to use those function modifiers to use, for example, M-x, but it conflicts with other hotkeys. (For Emacs keymap, ESC can be used. But now ESC is used by evil, and is no longer a meta substitute.)

What I want to achieve is in normal mode, ; acts as ctrl, and ' as alt, the meta key.

I tried the following but none of them worked:

(define-key evil-normal-state-map (kbd "'") 'event-apply-meta-modifier)
(define-key evil-normal-state-map (kbd "'") 'meta)

Any ideas how to achieve that?

1 Answer 1

0

event-apply-meta-modifier is only to be used in translation keymaps. You should try

(define-key key-translation-map "'" 'event-apply-meta-modifier)
(define-key key-translation-map ";" 'event-apply-control-modifier)

This will also make it possible to use these keys in the middle of a key sequence. If you want the keys to only work in normal state, you could use something like

(defun evil-normal-state-filter (cmd)
  (and (fboundp 'evil-normal-state-p)
       (evil-normal-state-p)
       cmd))
(define-key key-translation-map "'"
  '(menu-item "" event-apply-meta-modifier :filter evil-normal-state-filter))
(define-key key-translation-map ";"
  '(menu-item "" event-apply-control-modifier :filter evil-normal-state-filter))

See info node (elisp) Translation Keymaps and (elisp) Extended Menu Items for more information.

1
  • It works. Thanks!
    – user30786
    Nov 16, 2020 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy