2009-04-19

package management with ELPA

Today, the two major surviving branches on the emacs family tree are GNU/Emacs (or 'FSF/Emacs'), and XEmacs – they split off after the so-called Emacs Schism of the 1990's. Much has been said and written about it, so I don't need to go into that here - see EmacsWiki for the details. Anyway, the 'schism' seems less important now, as XEmacs seems to have lost a bit of steam, with GNU/Emacs picking up all the cool stuff that only XEmacs used to have, and then some.

Admittedly, it's been a while since I used XEmacs, but the one thing I remember that it still somewhat missing in GNU/Emacs, is package management. XEmacs has a nice system where you can mark packages for installation, and then get them from a website; much easier than the GNU/Emacs way, where you need to manually download things, maybe compile them, and update your .emacs - at least for things that your OS or distribution does not provide.

This has changed now with ELPA, the Emacs Lisp Package Archive. It's Tom Tromey's answer to the XEmacs package manager. The ELPA website explains its installation quite clearly; basically, evaluate:

(let ((buffer (url-retrieve-synchronously
               "http://tromey.com/elpa/package-install.el")))
  (save-excursion
    (set-buffer buffer)
    (goto-char (point-min))
    (re-search-forward "^$" nil 'move)
    (eval-region (point) (point-max))
    (kill-buffer (current-buffer))))
(you can 'evaluate' code by going just to the right of the last parenthesis and press C-x e).

This will add some code at the end of your .emacs.

To get a list of the available packages, you can use M-x package-list-packages; ELPA will download the most recent list in a buffer (see the screenshot). Now, to install packages, move your cursor to them and press i. This will mark the packages for installation. When you're done with marking, press x, and ELPA will install the packages for you (under ~/.emacs.d/elpa/).

Now, the list of packages in ELPA is not very big yet, but it's growing. I wishfully think that ELPA is to be a really important part of the Emacs ecosystem of the future. I submitted my TexDrive package for inclusion into ELPA; hopefully many other package authors will do the same.

3 comments:

Avdi said...

I've been meaning to try out ELPA. One thing that disturbs me though is that the "standard" way to install it is with this eval-ing of remote code. That's a terrible idea from a security perspective.

djcb said...

@Avdi: well, the risks of a trojan package seem bigger than some ELPA-specific spoof; that latter risk can hardly be an obstacle if you accept the first.

Having said that, it'd be nice if TLS, signing etc. were used.

MateuszF said...

great system, I installed nav extension in about five seconds