Emacs: How to Install Packages Using ELPA, MELPA

By Xah Lee. Date: . Last updated: .

Starting with emacs 24 (year 2012), it comes with a package system called ELPA (Emacs Lisp Package Archive). It lets you install and manage emacs packages. [see Emacs 24.1 New Features (released 2012-06)]

Quick Start

Add this to your emacs init:

;; load emacs 24's package system. Add MELPA repository.
(when (>= emacs-major-version 24)
  (require 'package)
   ;; '("melpa" . "http://stable.melpa.org/packages/") ; many packages won't show if using stable
   '("melpa" . "http://melpa.milkbox.net/packages/")

restart emacs.

emacs list packages 2017 07 02
Emacs Alt+x list-packages

To install a package:

  1. Alt+x list-packages.
  2. Find the package you want, move cursor to the line, press Enter. A description pane will pop up.
  3. Put cursor on the pane, press Tab to move cursor to the “Install” button then press Enter.
  4. The package is now installed.
  5. Read the package doc to see what command to start it, if necessary. (no restart is needed)

By default, packages are installed at ~/.emacs.d/elpa/

You can go to that directory, open the package you are interested, and read the file header doc.

Following are details.

Listing Available Packages

Alt+x list-packages.

Install Packages

This list is shown in package-menu-mode. In this mode, here's the most useful keys:

(For complete list of keys, Alt+x describe-modeCtrl+h m】)

For example, i want to install the clojure-mode. I type i to mark it, x to run install. Then, i got the following files in my dir, all automatically byte-compiled and loaded.


and now i can call clojure-mode, and it works right there! (no need to restart, but for some packages, you may need to turn it on or restart emacs.)

Upgrade Packages

To upgrade packages, just press 【U x】.

WARNING: package upgrade is not reliable. It is better to upgrade one package at a time. First delete the package, then install the latest.

Package Location

New packages are installed at ~/.emacs.d/elpa/.

If you want to remove all external packages, you can delete this entire directory and restart emacs. It is harmless to do so.

Package Repositories

The source of the packages are from package servers. There are several.

Note: the emacs package system, called ELPA (aka package.el), is started by Tom Tromey. Marmalade is started by Nathan Weizenbaum. MELPA is started by Donald Ephraim Curtis (aka milkypostman) http://milkbox.net/ Thank you guys.

Helpful Commands and Variables

package-enable-at-startup. By default, this is t (true).

package-load-list. This determines which packages should be loaded at start-up.

Alt+x describe-function or describe-variable for details.

Emacs Customization

  1. Emacs init file
  2. Install Packages
  3. Install Package Manually
  4. Define Keys
  5. M-x customize
  6. What's Major Mode?
  7. What's Minor Mode?
  8. Set File to Open in a Major Mode
  9. Organize Init File
  10. Byte Compile Elisp
  11. What's Hook?
  12. Environment Variables in Emacs
  13. Set Default Window Size
  14. Font Setup
  15. Set Color Theme
  16. Turn Off Auto Backup
  17. Check OS, Version, Host Name
  18. Check Defined/Loaded

If you have a question, put $5 at patreon and message me.
Or Buy Xah Emacs Tutorial
Or buy a nice keyboard: Best Keyboards for Emacs


Emacs Lisp