Emacs: error when the function is called in a hook

view story

http://unix.stackexchange.com – 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. (HowTos)