Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running my own code when during Emacs startup

Tags:

emacs

Let's say I have my own elisp code in ~/bin/hello.el.

The ~/.emacs file has the following code to run hello.el at startup.

(add-to-list 'load-path "~/bin/elisp")
(require 'hello)

But, I get the following error message.

Warning (initialization): An error occurred while loading `/Users/smcho/.emacs':

error: Required feature `hello' was not provided

What's wrong with this?

like image 835
prosseek Avatar asked Jul 28 '10 01:07

prosseek


3 Answers

Does hello.el provide hello? It should start with (provide 'hello). See the elisp manual. Does (load "hello.el") work?

like image 161
deinst Avatar answered Oct 22 '22 09:10

deinst


You have to put something like that in your LISP code:

(provide 'hello)

like image 43
Vlad Avatar answered Oct 22 '22 09:10

Vlad


If you added ~/bin/elisp to your load-path, then Emacs won't find a file in ~/bin. In this case, Emacs would try to load ~/bin/elisp/hello.el, and if it can't find that, then it will look for a file named hello.elc or hello.el (in that order) in the other parts of your load-path.

Also, as others have mentioned, hello.el needs to have a (provide 'hello) in it (typically at the end).

like image 25
haxney Avatar answered Oct 22 '22 08:10

haxney