The most common method of installing packages of Emacs Lisp since Emacs 24 has been ELPA packages.

Additional package archives such as MELPA exist to supplement what is in GnuELPA.

Adding a package source

By default, Emacs 24 or later is set up with the GnuELPA package archive. If you need to add more sources, include Emacs code like this to your InitFile:

(require 'package)
(add-to-list 'package-archives '("melpa" . ""))

Alternatively, you can use the Customize interface with the command ‘M-x customize-variable package-archives’ .

The value will depend on the package source you want to add. See ELPA and MELPA for more information.

Installing packages

Type M-x list-packages to open the package list. Press ‘i’ to mark for installation, ‘u’ to unmark, and ‘x’ to perform the installation. Press ‘RET’ to read more about installing and using each package.

If you don’t see the package listed there, you may need to add another package source to your package-archives variable. See the section on adding a package source.

You may want to start by installing the paradox package. This will allow you to use the command paradox-list-packages, which among other things gives the ability to sort package list by GitHub popularity. Starting with the most popular packages is a good way to find the most useful and effective ones.

If you move to a different system and you would like to quickly install all of your previously installed packages, look into ‘M-x package-install-selected-packages’. If you use UsePackage, the :ensure t property will tell Emacs to install a package if it hasn’t already been installed.

Shortlisting Packages

If you are looking for a package or a feature, it is more likely that it is already in MELPA. As on April 2019, MELPA has upwards of 4000 packages. So, start your search for a package in that repository. Alternately, you can shortlist packages right within Emacs using the `tablist` package. See How I shortlist add-ons for my Emacs: Introducing `tablist` for a nice tutorial on how you can do this.

Working with network proxies

If you are behind a firewall that requires the use of a proxy, you may need to configure HTTP or HTTPS proxies in order to list or install packages. Here is sample code from Stack Overflow. Replace the proxy information with whatever your network requires.

    (setq url-proxy-services
       '(("no_proxy" . "^\\(localhost\\|10.*\\)")
         ("http" . "")
         ("https" . "")))
    (setq url-http-proxy-basic-auth-storage
        (list (list ""
                    (cons "Input your LDAP UID !"
                          (base64-encode-string "LOGIN:PASSWORD")))))

Using and configuring packages

Many packages come with instructions on installation and use. These can be viewed in the package manager by pressing ‘RET’ on the package line.

UsePackage can make it easier for you to organize your package-related configuration. For more information, see its homepage:

For more inspiration and examples, look into the source of the Emacs starter configurations such as the ones found here.

Installing individual Emacs Lisp files

Some Emacs Lisp libraries or configuration snippets not available as packages. To install them, see LoadPath.

Configuring packages

The autoloads for installed packages will automatically be loaded after your InitFile has finished processing, so common commands will be available without any additional configuration. You can also use Customize to change the settings for your installed files.

If you need to configure other settings in your InitFile and you’re running into undefined functions or variables, you can use (package-initialize) to set up the load-paths and autoloads for installed packages. Then you can use (require 'package-name) to fully load the package, (with-eval-after-load "package-name" ...) or (eval-after-load 'package-name ...) to run code after a package is loaded, or something like the UsePackage macro to organize your package-related configuration.

Error: file not found while loading a package

While installing a package ‘foo’, you may get an error like:

file-error "" "Not found"

In this case, you may have to update some internal variable corresponding to the cached list of packages with either:

M-x package-refresh-contents

or, from within M-x list-packages, press ‘U’ to update the list.

As this update process might take a while, it shouldn’t really be part of the init file for every time you fire up Emacs.