I currently trying to remap my org mode agenda keymap in Spacemacs for org-agenda-next-item and org-agenda-previous-item. In the agenda view I like to map the functions to k for next-line and l for previous-line.

I already tested different approaches like:

  (define-key org-agenda-mode-map (kbd "k") 'org-agenda-next-item)
  (define-key org-agenda-mode-map (kbd "l") 'org-agenda-previous-item)

The result of this one is: Error in dotspacemacs/user-config: Symbol’s value as variable is void: org-agenda-mode-map. And it doesn't matter if I put the key mappings into (add-hook 'org-agenda-mode-hook or (with-eval-after-load 'org environments..

Or this one (source: How do I change key bindings for org-mode agenda view?):

(add-hook 'org-agenda-mode-hook
          (lambda ()
                  (local-set-key (kbd "k") 'org-agenda-next-item)))

This runs without an error, but the remapping of the key k does not take place.

I also checked the command describe-keymap to search for the correct keymap register. But it seems, that org-agenda-mode-map is the correct one.

Is there another approach, which might work? Or am I doing something wrong?

  • (add-hook 'org-agenda-mode-hook (lambda () (define-key org-agenda-mode-map "k" 'org-agenda-next-item))) works for me.
    – NickD
    Mar 11, 2019 at 2:40
  • @NickD: I tested it but it does not work.. May be it is the wrong keymap?
    – M_____
    Mar 11, 2019 at 19:32
  • No, the keymap is correct. What does C-h c k say when you invoke it in the agenda buffer (first, without the above hook in place, then with it in place, killing the agenda buffer in between and recreating it)? I get org-agenda-capture in the first case, org-agenda-next-item in the second.
    – NickD
    Mar 11, 2019 at 20:08


Your Answer

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

Browse other questions tagged or ask your own question.