I wrote this code to bind both Alt+c and F5 to compile

(defun dg/cedet-hook()
  (add-to-list 'ac-sources 'ac-source-semantic)
  (local-set-key (kbd "C-c C-j") 'semantic-ia-fast-jump)
  (local-set-key (kbd "M-c") 'compile)
  (local-set-key (kbd "<f5>") 'compile)
  (yas-global-mode 1)

(add-hook 'c-mode-common-hook 'dg/cedet-hook)

But, when I open a .cpp file Emacs returns the following error:

File mode specification error: (invalid-function (local-set-key (kbd <f5>) (quote compile)))

I don't undertand what's wrong in the syntax above, and why the error triggers in only the statement which uses F5.

Any clue? Thanks in advance.


The error shows something different than the code above. Compare (local-set-key (kbd "<f5>") 'compile) with (local-set-key (kbd <f5>) 'compile) and it should be obvious what the mistake is. Assuming the above code is part of your init file, restarting Emacs to clean out any old definition of it should do the trick.

  • Yeah, but there's a problem, the one I showed above is the only occurrence in all of my configuration.
    – Daniele
    Apr 30 '17 at 15:57

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.