0

I want to unbind some keys in the org agenda display with use-package. I did the following:

 (use-package org
 :ensure t
 :pin gnu
 :config
 (define-key org-agenda-mode-map (kbd "<C-S-right>") nil)
 (define-key org-agenda-mode-map (kbd "<C-S-left>") nil)
 (define-key org-agenda-mode-map (kbd "<C-S-up>") nil)
 (define-key org-agenda-mode-map (kbd "<C-S-down>") nil))

However, this does not work. I get the message Error (use-package): org/:config: Symbol’s value as variable is void: org-agenda-mode-map. So why does this fail and what is the trick to get this working?

2 Answers 2

0

I can reproduce the error. Basically you need to load org-agenda for org-agenda-mode-map to be available. You can modify your config a few different ways to fix it.

 (use-package org
 :ensure t
 :pin gnu
 :config
 (require 'org-agenda)
 (define-key org-agenda-mode-map (kbd "<C-S-right>") nil)
 (define-key org-agenda-mode-map (kbd "<C-S-left>") nil)
 (define-key org-agenda-mode-map (kbd "<C-S-up>") nil)
 (define-key org-agenda-mode-map (kbd "<C-S-down>") nil))

The following is another equivalent option.

 (use-package org
   :config
   (use-package org-agenda
     :ensure nil
     :bind
     (:map org-agenda-mode-map
      ("<C-S-right>" . nil)
      ("<C-S-left>" . nil)
      ("<C-S-up>" . nil)
      ("<C-S-down>" . nil))))

You can also do something like :after org and use a separate use-package org-agenda block.

0

Thanks to the answer by Swarnendu Biswas I realised, that it is a bit convoluted to have the key-(un-)bindings for the agenda within the use-package block. I now settled with the following solution:

(add-hook 'org-agenda-mode-hook
  '(lambda ()
     (define-key org-agenda-mode-map (kbd "<C-S-right>") nil)
     (define-key org-agenda-mode-map (kbd "<C-S-left>") nil)
     (define-key org-agenda-mode-map (kbd "<C-S-up>") nil)
     (define-key org-agenda-mode-map (kbd "<C-S-down>") nil)
     )
)

Your Answer

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

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