Go to the first, previous, next, last section, table of contents.


Loading Files

Many people in the GNU Emacs community have written extensions to Emacs. As time goes by, these extensions are often included in new releases. For example, the Calendar and Diary packages are now part of the standard Emacs version 19 distribution; they were not part of the standard Emacs version 18 distribution.

(Calc, which I consider a vital part of Emacs, would be part of the standard distribution except that it is so large it is packaged separately.)

You can use a load command to evaluate a complete file and thereby install all the functions and variables in the file into Emacs. For example:

(load "~/emacs/kfill")

This evaluates, i.e. loads, the `kfill.el' file (or if it exists, the faster, byte compiled `kfill.elc' file) from the `emacs' sub-directory of your home directory.

(`kfill.el' was adapted from Kyle E. Jones' `filladapt.el' package by Bob Weiner and "provides no muss, no fuss word wrapping and filling of paragraphs with hanging indents, included text from news and mail messages, and Lisp, C++, PostScript or shell comments." I use it all the time and hope it is incorporated into the standard distribution.)

If you load many extensions, as I do, then instead of specifying the exact location of the extension file, as shown above, you can specify that directory as part of Emacs's load-path. Then, when Emacs loads a file, it will search that directory as well as its default list of directories. (The default list is specified in `paths.h' when Emacs is built.)

The following command adds your `~/emacs' directory to the existing load path:

;;; Emacs Load Path
(setq load-path (cons "~/emacs" load-path))

Incidentally, load-library is an interactive interface to the load function. The complete function looks like this:

(defun load-library (library)
  "Load the library named LIBRARY.
This is an interface to the function `load'."
  (interactive "sLoad library: ")
  (load library))

The name of the function, load-library, comes from the use of `library' as a conventional synonym for `file'. The source for the load-library command is in the `files.el' library.

Another interactive command that does a slightly different job is load-file. See section `Libraries of Lisp Code for Emacs' in The GNU Emacs Manual, for information on the distinction between load-library and this command.


Go to the first, previous, next, last section, table of contents.