Emacs/The Emacs Lisp Package Archive

From Wikibooks, open books for an open world
Jump to navigation Jump to search

The Emacs Lisp Package Archive, ELPA, makes it easy to download and install packages for emacs. The official site of ELPA is at http://tromey.com/elpa/.

Getting started with ELPA[edit | edit source]

Installing the package manager[edit | edit source]

In Emacs 22 and above, the necessary modules are already present to install the package manager from a small bootstrap script. Simply copy and paste the following code in to a *scratch* buffer and execute it with Ctrl-J.

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

The package manager should install itself.

If you are using Emacs 21, you will need to have the wget utility available. Execute the following code:

(let ((buffer (get-buffer-create (generate-new-buffer-name " *Download*"))))
    (save-excursion
      (set-buffer buffer)
      (shell-command "wget -q -O- http://tromey.com/elpa/package-install.el"
		     (current-buffer))
      (eval-region (point-min) (point-max))
      (kill-buffer (current-buffer))))