Emacs Init: Install Package from ELPA, MELPA
What is ELPA, MELPA
- ELPA is a package system (Emacs Lisp Package Archive). It lets you install and manage emacs packages.
- ELPA also refers to the elisp package repository, maintained by GNU emacs.
- MELPA is elisp package repository, maintained by others.
ELPA is new in Emacs 24 (Released 2012-06)
Add Package Repository
put this in your Emacs Init File:
(progn ;; load elpa package system ;; require emacs 24 (require 'package) ;; Add MELPA repository. (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (when (< emacs-major-version 27) (package-initialize)) ;; )
restart emacs.
Install a Package
If you know the name of the package you want:
- Alt+x
package-install
- type the package name, e.g. xah-fly-keys
or run the lisp code:
(package-install 'xah-fly-keys )
If you don't know the name of the package:
- Alt+x
list-packages
. - Find the package you want, move cursor to the line, press Enter to see full description.
- Put cursor on the pane, press Tab to move cursor to the “Install” button then press Enter.
- The package is now installed.
- Read the package doc to see what command to start it, if necessary. (no restart is needed)
List Packages
Alt+x list-packages
.
Key and Command for Package List
list-packages
shows result in
Major Mode
package-menu-mode
.
here's the most useful keys:
- Enter (
package-menu-describe-package
) - Describe the package under cursor.
- i (
package-menu-mark-install
) - Mark for installation.
- u (
package-menu-mark-unmark
) - Unmark.
- d (
package-menu-mark-delete
) - Mark for deletion (removal of a installed package).
- x (
package-menu-execute
) - start install/uninstall of marked items. (x for execute)
- r (
revert-buffer
) - Refresh the list from server.
(For complete list of keys,
Alt+x list-packages
,
then
Alt+x describe-mode
)
Upgrade Packages
To upgrade packages, just press U x.
package-menu-mark-upgrades
【U】- For any package that has a new version, the installed one will be marked “D” (for delete), and new one will be marked “I” (to install).
package-menu-execute
【x】- Run the marked commands on packages.
🛑 WARNING: as of 2017, package upgrade may not be reliable. It is better to upgrade one package at a time. Or, just delete the package, then install the latest.
Default Package Install Location
packages are installed at ~/.emacs.d/elpa/
.
You can go to that directory, open the package you are interested, and read the file header doc.
If you want to remove all external packages, you can delete this entire directory and restart emacs. It is harmless to do so.
Package Repositories
The source of the packages are from package servers. There are several.
- http://elpa.gnu.org/
- FSF's GNU Emacs package repository. This repository contains package copyrighted by Free Software Foundation.
- https://elpa.nongnu.org/
- Non-GNU repository maintained by FSF.
- https://melpa.org/
- MELPA (Milkypostman's Emacs Lisp Package Archive). Emacs community maintained repo. As of 2022-06-08, MELPA has most packages, and updated daily.
Helpful Variables
- package-enable-at-startup
- Variable. By default, this is t. 〔see Elisp: Boolean (true false nil)〕 .
- package-load-list
- Variable. This determines which packages should be loaded at start-up.
History of emacs package.el
The ELPA (aka package.el)
emacs package system, is started by Tom Tromey in 2007.
Marmalade repo (defunct) is started by
Nathan Weizenbaum.
MELPA is started by Donald Ephraim Curtis
(aka milkypostman)
http://milkbox.net/
Thank you guys.