Reputation: 35
So I downloaded an .el file, I put it on the ~/.emacs.d/elpa/
folder, but it won't appear on the M-x list-packages
. How do I make it appear there or how can I install this file/package?
Upvotes: 1
Views: 1061
Reputation: 41618
There are two ways of installing an Emacs package: either type M-x list-packages
and install it from the list, letting Emacs download it for you, or download the package yourself and install it with M-x package-install-file
.
In the first case, note that there are several different package archives. The default value for the variable package-archives
only contains GNU ELPA, but most people want to add MELPA to that list since it has more packages. To do that, you need to add the following to your .emacs
file (copied from the MELPA web page):
(require 'package) ;; You might already have this line
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize) ;; You might already have this line
After that, typing M-x list-packages
should list more packages than you'll ever need :)
There are two types of packages: single-file packages and multi-file packages. The former can be downloaded as a single .el
file, while the latter are distributed as tarballs (.tar
). Both types can be installed with M-x package-install-file
.
Note that not every .el
file can be installed as a package. The comments at the beginning of the file need to follow a certain convention, documented in the Simple packages node of the Emacs Lisp reference manual.
That leaves the possibility that the .el
file you've downloaded is not installable as a package. In that case, you should put it in some other directory (~/.emacs.d/elpa
is meant for installed packages only), add that directory to the load-path
variable, and require
the package. If you have foo.el
and put it in ~/path/to/foo
, it would look something like this:
(add-to-list 'load-path "~/path/to/foo")
(require 'foo)
Upvotes: 2
Reputation: 189679
An .el
file is not a package. Installing it via ELPA is probably vastly preferrable to manually downloading a static .el
file; perhaps the maintainer has a home page with ELPA (or Marmalade, etc) instructions.
In particular, a package will receive updates as they are made available, so you will not be forever stuck on an increasingly obsolete, unmanaged version (though quiet, fully automatic updates are not yet available or feasible, AFAICT).
But if you have to get by with just the file you already downloaded, you can put it pretty much anywhere you like, as long as that directory is included in the load-path
. Manually mucking with the elpa
directory is a bad idea, though; put it somewhere else.
Look for comments near the top of the file for any additional instructions; any autoloads, for example, will probably have to be configured separately, and usually completely manually.
This used to be how you always did things in older versions of Emacs, so you should find that the Internet is still practically bulging with guides and tutorials which explain the finer details of this mechanism, if this answer alone isn't sufficient.
Upvotes: 0