InstallingPackages

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

Additional package archives such as MELPA or MarmaladeRepo exist to supplement what is in ELPA.

Adding a package source

By default, Emacs 24 or later is set up with the ELPA 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" . "http://melpa.org/packages/"))

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 MELPA or MarmaladeRepo 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.

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" . "proxy.com:8080")
         ("https" . "proxy.com:8080")))
    (setq url-http-proxy-basic-auth-storage
        (list (list "proxy.com:8080"
                    (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: https://github.com/jwiegley/use-package

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.


CategoryPackaging