Installing ELPA Package System for Emacs 23

By Xah Lee. Date:

This page is a guide on installing ELPA package system package.el for emacs 23.

If you are using emacs 24, see: Emacs: Install Package with ELPA/MELPA. (type Alt+x version or in terminal emacs --version.)

To install, paste the following in a empty file:

(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))))

then call eval-buffer.

That will download the file and place it at ~/.emacs.d/elpa/package.el.

(very neat elisp trick! note to self: url-retrieve-synchronously is bundled with emacs 23. Use it like wget/curl!)

Also, it automatically adds the following in your .emacs file, so that it'll be loaded everytime you start emacs.

(when
    (load
     (expand-file-name "~/.emacs.d/elpa/package.el"))
  (package-initialize))

How to Upgrade ELPA from Emacs 23 to Emacs 24

If you have installed ELPA with emacs 23 and now just upgraded to emacs 24, here's what to do.

  1. In your emacs init file, delete any code block containing ~/.emacs.d/elpa.
  2. Quit emacs.
  3. Delete the directory ~/.emacs.d/elpa/
  4. Start emacs.
  5. Alt+x list-packages to re-install packages you want.
  6. Put (package-initialize). And move all config of your installed packages after this.

For how to use the package system, see: Emacs: Install Package with ELPA/MELPA.