0

[Edit: I should specify that there are many keybindings in the major mode that overide the desired keybinding. They all start with a whereas I would like a to do something else. I already thought about trying to remove each one one individually, but I would prefer a method that does not involve changing so many keybindings.]

It seems other major modes can overwrite a configured keybinding for a in visual mode in doom emacs.

I am using a non qwerty keyboard layout and

 (map! :nv "a" #'evil-previous-line)

does not work in visual mode with latex documents or org documents. It seems to be overidden by keybindings in doom emacs that start with a.

That keybinding does however work in fundamental mode.

How can I make that work in org and latex files?

2 Answers 2

1

Any time a mode defines a key that you don’t like, you just delete that keybinding and perhaps replace it with one that you do like. You can find a thousand other people asking the same question here on Stack Exchange, so I won’t bother to write a duplicate answer for you. You could also read about it in the Emacs manual, or in whatever help files or manuals are provided by Doom Emacs.

Edit:

If the key you don’t like is a prefix, you don’t have to individually remove all of the key bindings that have that prefix. Just remove the one binding for the prefix and they will all go away. This is because prefixes are just a key binding that points to another key map, instead of to a command.

3
  • My apologies, I should have mentioned that there are many keybindings that start with a. I was trying to avoid removing every one of them one by one. Perhaps with some tool that disables all keybindings that start with a Commented Mar 3 at 2:56
  • I have edited the post but perhaps it is better that I simply revert back to the previous version and ask a separate question as you already gave an answer Commented Mar 3 at 3:06
  • 1
    Thank you it seems that I gave up too early as I remembered trying to just unbind "a" in a specifc major mode but there were still remaining key bindings. It turns out that those remaining key bindings were from another mode and disabling both worked. Commented Mar 3 at 5:23
1

Just providing the syntax for anyone not sure how to do this for doom emacs. In my case only visual mode was a problem so I used :v below.

Placing the snippet below in config.el worked for me. In the code below I did not verify if I should use :after org and :after evil-org for org files, I just guessed and tried.

(map! :after org
      :map org-mode-map
      :v "a" nil)
(map! :after evil-org
      :map evil-org-mode-map
      :v "a" nil)

It also worked without using :after but maybe it is safer to use that as according to https://discourse.doomemacs.org/t/how-to-re-bind-keys/56 (I did a lot of formating for the quote below to get a similar format as in the link, there might be remaining errors in what I did.):

It is important to bind your keys after the keymap is defined, for two reasons:

  • You will get void-variable errors if you try to bind keys to a keymap that isn’t defined.

  • Doom or other packages may bind their own default keys to that keymap – running yours after ensures yours override the defaults and not the other way around.

The key to achieving this is one of: the after! macro, map!'s :after keyword, or with-eval-after-load:

(map! :after python
      :map python-mode-map
      "C-x C-r" #'python-shell-send-region) 

;; or

(after! python
  (map! :map python-mode-map "C-x C-r" #'python-shell-send-region))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.