ELPA is the Emacs Lisp Package Archive, originally by TomTromey, now included in Emacs 24 after contributions from others.
"Our goal is to make it simple to install, use, and upgrade Emacs Lisp packages. We supply ##package.el## a simple package manager for Emacs, and a repository of pre-packed Emacs Lisp code."
package.el is a package manager included in Emacs since version 24. It includes a built-in repository of FSF sanctioned Emacs packages, also called ELPA and found at ELPA repository.
The Emacs version of
package.el supports multiple repositories. You can use the GNU ELPA plus other repositories like this:
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/") ("marmalade" . "http://marmalade-repo.org/packages/") ("melpa" . "http://melpa.milkbox.net/packages/")))
Any combination of repositories is fine. You should probably always include GNU’s core repository but it’s not required.
Package archives may also be local to your machine.
You can also do it transactionally.
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
You can also customize
M-x customize-variable [RET] package-archives [RET]
‘package-initialize’to load installed packages. This is done after loading the init file and abbrev file (if any) and before running
‘after-init-hook’(see Startup Summary). Automatic package loading is disabled if the user option package-enable-at-startup is nil.
So packages are initialized AFTER the init.el is loaded. This means you should NOT put package specific initialization into your init.el except in a few ways:
(add-to-list 'auto-mode-alist '("\\.gradle" . groovy-mode))
(add-hook 'groovy-mode-hook (lambda () (setq tab-width 4)))
(global-set-key "\M-?" (lambda () (interactive) (call-interactively 'magit-status))) (global-set-key (kbd "C-'") 'shell-switcher-switch-buffer)
(add-hook 'after-init-hook 'cycbuf-init)
Some people think that using after-init-hook seems like a last resort because it may force the load of the package you’re referring to (thus slowing down Emacs). Others point out that moving your whole initialization to after ELPA is loaded makes things easier to use.
You can do that by putting this in your init file:
(add-hook 'after-init-hook #'(lambda () (load "<real init file>")))
and moving all your normal init to the
<<real init file>>.
‘eval-after-load’ is one way of achieving fine grained configuration per-package. It falls back gracefully if the package is not present.
The following code is an example of customizing a hypothetical major mode called abcd-mode using eval-after-load:
(eval-after-load "abcd-mode" ; <-- "abcd-mode", not 'abcd-mode '(progn (setq-default abcd-basic-offset 7) ; setting some option (add-to-list 'abcd-globals-list "console") ; appending to a list option (add-hook 'abcd-mode-hook 'prepare-some-abcd-soup) ; things to do for abcd mode buffers (define-key abcd-mode-map (kbd "C-c C-c") 'play-some-abcd-song) ; add some key binding for abcd mode ))
And here is an example for a hypothetical global minor mode called broccoli mode.
(eval-after-load "broccoli-autoloads" ; <-- "broccoli-autoloads", not "broccoli" '(progn (if (require 'broccoli nil t) (progn (broccoli-mode 1) ; Turn on Broccoli global minor mode if broccoli-autoloads.el doesn't do it. (setq-default broccoli-how 'steamed) ; set some option. (add-to-list 'broccoli-additional-stuff 'salt) ; add to a list option. ) (warn "broccoli is not found."))))
To my mind one of the faults of ELPA is that the load path is not updated when new packages are installed. Here is a command that will do it for you:
(defun package-update-load-path () "Update the load path for newly installed packages." (interactive) (let ((package-dir (expand-file-name package-user-dir))) (mapc (lambda (pkg) (let ((stem (symbol-name (car pkg))) (version "") (first t) path) (mapc (lambda (num) (if first (setq first nil) (setq version (format "%s." version))) (setq version (format "%s%s" version num))) (aref (cdr pkg) 0)) (setq path (format "%s/%s-%s" package-dir stem version)) (add-to-list 'load-path path))) package-alist)))
Would this be better as some advice? Perhaps even a package that installed the advice?
ELPA policy for Emacs 24 was discussed here: http://thread.gmane.org/gmane.emacs.devel/132634/focus=132640
You can make packages work in Emacs 23, you need to add something like this to your init.el:
(require 'package) ;; Any add to list for package-archives (to add marmalade or melpa) goes here (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/")) (package-initialize)