Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
(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 :) – davidshen84 Sep 2 '12 at 14:02
up vote 1 down vote accepted

@EmanuelBerg thanks, moving the code works :)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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