Fork me on GitHub
#emacs
<
2022-10-24
>
eggsyntax17:10:22

[EDIT - solved] Emacs/Spacemacs making me a bit crazy today. Anyone see what I'm doing wrong here? I'm defining a general binding for M-<up> like so:

(define-key evil-normal-state-map (kbd (right-mod "<up>"))
  #'(lambda () (interactive) (jump-to-same-indent -1)))
And a different binding in org-mode like so:
(evil-define-key '(normal insert) 'org-mode-map
  (kbd "M-<up>") 'outline-backward-same-level)
But the org-mode bindings are showing up in all modes. If on the other hand I wrap the org-mode binding like
(with-eval-after-load 'org-mode
  (evil-define-key '(normal insert) 'org-mode-map
   (kbd "M-<up>") 'outline-backward-same-level))
then the non org-mode bindings apply everywhere, including org-mode buffers. Anyone have a clue for me?

tomd19:10:10

if you try the evil-define-key without quoting 'org-mode-map then I don't think you'll see this binding showing up in all modes

tomd19:10:16

you don't need to do the with-eval-after-load thing because evil-define-key already handles this: > If `foo-map' has not been initialized yet, this macro adds an > entry to `after-load-functions', delaying execution as necessary.

eggsyntax19:10:29

> you don't need to do the with-eval-after-load thing because evil-define-key already handles this: That's what I expected, just casting around since it wasn't working > if you try the evil-define-key without quoting 'org-mode-map then I don't think you'll see this binding showing up in all modes Ahhhh that makes total sense and now I see that that matches the evil-define-key docs. <testing>

eggsyntax19:10:19

Bingo! Thank you so much, that was driving me absolutely crazy 🙏

🚀 1
tomd19:10:37

Glad it's fixed 🙂