Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to import a file to your .emacs

Tags:

emacs

How can you import a new chunk of code (an Emacs lisp library) into your .emacs file?

I do not want to put everything into one huge .emacs file.

like image 558
Léo Léopold Hertz 준영 Avatar asked Apr 26 '09 22:04

Léo Léopold Hertz 준영


People also ask

How do I install a .emacs file?

To load an Emacs Lisp file, type M-x load-file . This command reads a file name using the minibuffer, and executes the contents of that file as Emacs Lisp code. It is not necessary to visit the file first; this command reads the file directly from disk, not from an existing Emacs buffer.

Where is the Emacs Config file?

Emacs can also look in an XDG-compatible location for init. el , the default is the directory ~/. config/emacs .


1 Answers

Put the file google.el in a directory, say ~/lisp, and then in your .emacs:

(add-to-list 'load-path "~/lisp")
(require 'google)

If you want to add a directory and its sub-directories, you can check out the answers in this SO question.

And, as you add more and more 'require lines, you'll notice things slowing down on startup. At which point you'll want to find out how to make Emacs start up faster I of course like my answer best.

like image 143
Trey Jackson Avatar answered Sep 20 '22 06:09

Trey Jackson