Emacs Init: Install Package Manually

By Xah Lee. Date: . Last updated: .

What is a Package

Load the File

Load the File Interactively

Alt+x load-file then give the file name.

or, open the file, then

Alt+x eval-buffer

Now, emacs is aware of the package.

Load File at Startup

If you want emacs to load the file when it starts, put the file in the dir

~/.emacs.d/lisp/

where ~/.emacs.d/ is your Emacs Init: File Location . Create that lisp directory if it doesn't exist.

put this in your Emacs Init File:

;; add lisp dir in emacs init dir, to load path

(add-to-list 'load-path (concat user-emacs-directory "lisp/" ))

;; load a package named xx.el
(load "xx")
;; best not to include the file name extension .el or .elc. because emacs will then use the byte compiled file .elc if available.

Byte Compile (Optional)

Activate the Mode

If the package is a Major Mode or Minor Mode, you have to activate it, by calling the command in the package.

For example, if the file name is xx.el, then the command to activate it is typically Alt+x xx or xx-mode.

Auto Activate Mode When Opening File

This is usually setup by the package, but not always. Here's the basics:

(add-to-list 'auto-mode-alist '("\\.el\\'" . xah-elisp-mode))

For detail, see: Emacs Init: Set Default Major Mode.

Mode Documentation

Emacs major mode usually have inline doc. To view it

  1. Activate the mode Alt+x mode_name
  2. Alt+x describe-mode

Sometimes, a mode comes with complete documentation in info format (file with suffix .info). To read the info, type Ctrl+u Alt+x info then type the info file's name.

Emacs, packages