Emacs: Install Package with ELPA/MELPA
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 Features (released 2012-06)]
- ELPA is a mechanism for emacs to support packages.
- “ELPA” also means “GNU Emacs Lisp Package Archive”, a emacs lisp package repository containing packages sactioned by Free Software Foundation.
- MELPA (Milkypostman's Emacs Lisp Package Archive) is a ELPA-compatible package repository. It contains some thousands times more packages than ELPA.
Add this to your emacs init:
;; load emacs 24's package system. Add MELPA repository. (when (>= emacs-major-version 24) (require 'package) (add-to-list 'package-archives ;; '("melpa" . "http://stable.melpa.org/packages/") ; many packages won't show if using stable '("melpa" . "https://melpa.org/packages/") t))
To install a package:
- Find the package you want, move cursor to the line, press Enter. A description pane will pop up.
- Put cursor on the pane, press Tab to move cursor to the “Install” button then press Enter.
- The package is now installed.
- Read the package doc to see what command to start it, if necessary. (no restart is needed)
By default, packages are installed at
You can go to that directory, open the package you are interested, and read the file header doc.
Following are details.
Listing Available Packages
This list is shown in
package-menu-mode. In this mode, here's the most useful keys:
- Enter (
- Describe the package under cursor.
- i (
- Mark for installation.
- u (
- d (
- Mark for deletion (removal of a installed package).
- x (
- For “execute” (start install/uninstall of marked items).
- r (
- Refresh the list from server.
(For complete list of keys, Alt+x
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.
~/.emacs.d/elpa/clojure-mode-1.7.1: clojure-mode-autoloads.el clojure-mode-pkg.el clojure-mode-pkg.elc clojure-mode.el clojure-mode.elc
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.)
To upgrade packages, just press U x.
- For any package that has a new version, the installed one will be marked “D” (for delete), and new one will be marked “I” (to install).
- Run the marked commands on packages.
WARNING: package upgrade is not reliable. It is better to upgrade one package at a time. First delete the package, then install the latest.
New packages are installed at
If you want to remove all external packages, you can delete this entire directory and restart emacs. It is harmless to do so.
The source of the packages are from package servers. There are several.
- http://elpa.gnu.org/ Default. Official GNU Emacs package repository. This repository contains the minimal set, and each package is copyrighted by Free Software Foundation.
- http://marmalade-repo.org/ Marmalade. More extensive number of packages.
- https://melpa.org/ MELPA. As of , MELPA has most packages, and updated daily.
Note: the emacs package system, called ELPA (aka package.el), is started by Tom Tromey.
Marmalade is started by
MELPA is started by Donald Ephraim Curtis
Thank you guys.
Helpful Commands and Variables
package-enable-at-startup. By default, this is
package-load-list. This determines which packages should be loaded at start-up.
describe-variable for details.