How to install a Emacs plugin (many times it's a .el file) on Windows platform?
Solution 1:
After placing it, say myplugin.el
to your ~/.emacs.d/
directory, add the following in your .emacs
file:
(add-to-list 'load-path "~/.emacs.d/")
(load "myplugin.el")
Also, in many cases you would need the following instead of the second line:
(require 'myplugin)
In any case, you should consult the documentation of the package you are trying to install on which one you should use.
If you are unsure where your ~
directory is, you may see it by typing C-x d ~/
and pressing Enter
.
Solution 2:
As already stated, you'll need the location of the file to be in Emacs' load path.
Read the comments at the top of the file to see if it has any particular installation or usage instructions. Authors often provide this information, and there isn't one single correct way to do it, so it's sensible to look.
Failing that, if the file contains a (provide 'some-name)
line (typically at the end of the file), then you would be expected to use (require 'some-name)
to load it.
You may also wish to byte-compile the library for speed (but that's a different question).
Solution 3:
Many times, an emacs plugin will consist of a directory of elisp files that need to be accessible from the load path. A simple way to ensure that all individual elisp files as well as subdirectories of elisp files are included in the load path and accessible is to do something similar to the following:
- Create a directory called ~/.emacs.d/site-lisp.
- Install any single elisp files in the ~/.emacs.d/site-lisp directory.
- Install any packages that consist of multiple elisp files in a subdirectory under your ~/.emacs.d/site-lisp directory.
-
Add the following code to your ~/.emacs file to ensure that Emacs "sees" all the elisp files that you have installed:
(add-to-list 'load-path "~/.emacs.d/site-lisp") (progn (cd "~/.emacs.d/site-lisp") (normal-top-level-add-subdirs-to-load-path))
This will ensure that all elisp files that are located either in either the ~/.emacs.d/site-lisp directory or in a subdirectory under that directory are accessible.