I defined a function in my .emacs file, and I want to call it when a major mode is loaded. My function is interactive.

If I invoke my function by M-x, everything seems alright. But if I invoke my function from the mode hook, I got below error:

File mode specification error: (void-variable set-color-theme)

But actually, the function has been invoked correctly. So, I do not understand why it reports the variable is void.

  • 2
    (Show your code!) For example, it looks like this: (add-hook 'rmail-show-message-hook 'turn-on-visual-line-mode) Make sure your function (turn-on-visual-line-mode in the example) is defined above the line where you try to make your hook. – Emanuel Berg Sep 2 '12 at 5:37
  • @EmanuelBerg thanks, moving the code works :) – David S. Sep 2 '12 at 14:02

Your Answer

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

Browse other questions tagged or ask your own question.