A Guide on Emacs 24 Package System, ELPA, MELPA, Marmalade

, , …,

Emacs package system lets you auto-update and manage emacs packages. It lets you easily see packages available, update to latest version, install/remove packages. So you don't have to manually track what's installed, each package's home page, whether there's new version, etc. It is bundled with emacs 24. 〔☛ New Features in Emacs 24.1

Quick Summary

Here a summary for those impatient.

Add this to your emacs init:

(when (>= emacs-major-version 24)
  (require 'package)
  (package-initialize)
  (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
  )

restart emacs.

Now, just call list-packages. Find the package you want, move cursor to the line, press Enter ↵, then click Install. Then, you can start to use the package.

Listing Available Packages

Call list-packages. It'll list available packages, like this:

emacs packages elpa screenshot
Emacs “list-packages” screenshot

Install Packages

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

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

So, 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.)

Update Packages

To update packages, just press 【U x】.

Installed Packages Location

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

Packages Repositories

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

To add it, put the following in your emacs init file:

(when (>= emacs-major-version 24)
  (require 'package)
  (package-initialize)
  (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
  )

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) Thank you guys.

Helpful Commands and Variables

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

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

Call describe-function or describe-variable for details.

Flaw of Emacs 24's Package System

Emacs package system isn't perfect. For some modes, you still have to read the package header file and put stuff in your emacs init file for the package to work properly. For detail, see: Emacs 24 Package System Problems.

For a basic understanding of how to install emacs packages manually without package system, see: How to Install Emacs Packages.

Other Emacs Package Systems

There are other emacs package systems. example

blog comments powered by Disqus