David S.
David S.

Reputation: 11168

How to call a function in a user defined function im Emacs?

I use defun to define a function in my .emacs file:

(defun myfun ()
   "i am already loaded the color-theme lib"
   (color-theme-initialize)
   (color-theme-darkblue))

Then I want to use this function in my mode-hook:

(add-hook 'python-mode-hook
   '(lambda ()
       (myfun)
       (...)))

But I got an error saying that the color-theme-initialize function is void.

P.S. my ~/.emacs snippet

(progn (require 'color-theme)
       (color-theme-initialize))

(progn (setq-default indent-tabs-mode nil)
       (setq-default tab-width 2)
       (setq indent-line-function 'insert-tab))

(add-hook 'emacs-lisp-mode-hook
          '(lambda ()
             (color-theme-resolve)
             (show-paren-mode t)
             (linum-mode t)))

Upvotes: 0

Views: 1070

Answers (2)

tripleee
tripleee

Reputation: 189357

You need to require (or otherwise load) the library which provides color-theme-initialize. I'm guessing (require 'color-theme).

Upvotes: 2

Daimrod
Daimrod

Reputation: 5020

Read the error, it's not your function that cannot be called, but the function named color-theme-initialize. This function has been removed some times ago but can still be present in some older version of color-theme. Thus, check your version of color-theme and see if there is a function called color-theme-initialize (with C-hfcolor-theme-initializeRET). If the function is present then you have to (require 'color-theme), otherwise you don't need to call this function.

Upvotes: 0

Related Questions