2

after setting a path for my lisp files in emacs in the .emacs file, like this

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

logically I should also use a load command for a specific file I guess what is that command

I tried

(load-file-name "google-c-style") with the .el added also for the file, what should be the right way to do this

however no success.

3 Answers 3

7

If the .el has a line like (provide 'google-c-style), then all you need in your .emacs is:

(require 'google-c-style)
Sign up to request clarification or add additional context in comments.

1 Comment

This was exactly what I was looking for while writing my snake game in SFML and fuzzing about mixed indentation between .cc and .h files.
6

It's just (load), not (load-file-name).

Comments

2

load-file-name is a variable which holds the full name of the file loaded by 'load'

use C-h-v load-file-name to read the documentation

Now, to load a file use the function 'load' - This looks for elisp source or binaries in the loaded paths

Eg: (load "google-c-style.el")

Note: There are another functions 'load-file'and 'load-library which work slightly differently. Read more about these here: http://www.gnu.org/software/emacs/manual/html_node/emacs/Lisp-Libraries.html#Lisp-Libraries

Also, as mentioned in one of the answers one can also use the provide - require feature. Read this post to learn more about the differences between these functions(load, load-file, require, autoload)

http://ergoemacs.org/emacs/elisp_library_system.html

Comments

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.