10

I have a couple of emacs configuration files. I was going to consolidate them down into a common file and then a couple other files that import the common file. Then have their own functions. I was just going to have them all as .emacsCommon in my home folder but when I write:

(require '.emacsCommon)

it doesn't load the function. What is the right way to do this??

Cheers

2 Answers 2

12

Use 'load-file' to load a EmacsLisp file

(load-file "./.emacsCommon")

Sign up to request clarification or add additional context in comments.

Comments

6

If you want to use require, you should add (provide 'foo) at the end of a file named foo.el. If that file is on the load-path, you can then use (require 'foo) to load this file, and add the feature (foo) to the feature list. (The printname of 'foo, the feature name, is used as a filename here.)

Since your filename has a leading dot, and doesn't end in .el, you should give the filename as an argument to require though:

(require 'foo ".foo")

Note, that you could also just use load or load-file.

2 Comments

This is mostly superfluous information if you just want to load the file, though.
Fair enough. But you can use things like featurep, files will not be loaded unnecessarily, and it seems a little tidier to me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.