I'm using prelude mode, and in a file .emacs.d/personal/old-settings.el I have, amongst other things:

(global-set-key (kbd "C-c C-c") 'comment-region)

(add-hook 'c-mode-common-hook
        (local-set-key  (kbd "C-c o") 'ff-find-other-file)))

Now when editing a c++-mode file, comment-region has been set, but ff-find-other-file hasn't.

I did F1 v c-mode-common-hook and see this:

c-mode-common-hook is a variable defined in `cc-vars.el'.
Its value is ((lambda nil
   (kbd "C-c o")
(lambda nil
  (run-hooks 'prelude-c-mode-common-hook)))

How would I go about debugging this? There doesn't seem to be a way to list-hooks, detect if the hook had already fired, etc.

  • C-c C-c is bound to comment-region in c++-mode by default (against my wishes). BTW, M-; is the standard global binding to comment a region (using comment-dwim which provides a superset of the functionality of comment-region) and the use of C-c C-c for it is an old habit that's mildly discouraged. – Stefan May 24 '17 at 12:57
up vote 0 down vote accepted
  1. You could print a message from your hook, like this:

    (add-hook 'c-mode-common-hook (lambda() (message "fired") (local-set-key (kbd "C-c o") 'ff-find-other-file)))

  2. You can have a look at the current mode and his Key-Bindings with C-h m

  3. You can write a short config.el which only handels the Part you try to debug and start it with emacs -Q -l config.el

Btw: I have done all 3 steps above and the hook fires.

Can someone help me formating this code-snippet? :)

  • Thanks, I think that has me going in the right direction. It seems that prelude mode has gone and defined a series of conflicting key-bindings, which I found via 2) above. 4 spaces at start of each line make the snippet appear as intended. – tlrrd May 24 '17 at 11:07
  • Glad I could help. Indenting did not work, because the code is in a list ... it seems – jue May 24 '17 at 11:50
  • Thanks, I managed to identify that it was a conflicting keybinding doing this and I can now disable prelude mode by adding (prelude-off) to the hook as follows: (add-hook 'c-mode-common-hook (lambda() (prelude-off) (local-set-key (kbd "C-c o") 'ff-find-other-file))) – tlrrd May 24 '17 at 13:15

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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