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.
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.
Emacs can also look in an XDG-compatible location for init. el , the default is the directory ~/. config/emacs .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With