I'm trying unbind org-cycle-agenda-files which is set by default to C-' and C-,.

My weapon of choice to do so is use-package package.

On github.com/use-package/bind-key.el page I have found following lines:

;; To unbind a key within a keymap (for example, to stop your favorite major
;; mode from changing a binding that you don't want to override everywhere),
;; use `unbind-key':
;;   (unbind-key "c-c x" some-other-mode-map)

This resulted in me unsuccessfully trying following variations:

(unbind-key "C-'" )
(unbind-key "C-," )
(unbind-key "C-'" (org-cycle-agenda-files))
(unbind-key "C-," (org-cycle-agenda-files))
(bind-keys :map org-mode-map
       :unbind "C-'")
(unbind-key "C-'" org-cycle-agenda-files)

After that fail I triyed some "traditional" solution to the problem.

Information found in gnu.org manual, and some emacs.stackexchange answers resulted in me producing following useless havoc:

(define-key (org-cycle-agenda-files) key nil)
(define-key (current-global-map) "C-'" nil)
(local-unset-key "C-'")
(global-unset-key "C-'")
(with-eval-after-load org-mode
  (unbind-key "C-'" org-mode-map)
  (unbind-key "C-," org-mode-map))
(global-set-key (kbd "C-'") 'nil)

Yep.... None these variations vorks. :D

I would love to find use-package based solution, since I'm already using some of it's awesome capabilities.

Any kind of suggestion is welcome.


If you C-h f and enter unbind-key, the help says:

unbind-key is an autoloaded Lisp macro in `bind-key.el'.

(unbind-key KEY-NAME &optional KEYMAP)

Not documented.

The second argument to unbind-key is a key map -- for example org-mode-map.

This works for me:

(require 'bind-key)
(unbind-key "C-," org-mode-map)
(unbind-key "C-'" org-mode-map)

A good place to put this would be the :config section of a use-package form.


Yeah the unbinding does not look elegant, but that's the main approach according to this answer.

As for use-package, I have been using unbind under :init directive like so:

(unbind-key "C-'" org-mode-map)
(unbind-key "C-," org-mode-map)

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.