How to install a Emacs plugin (many times it's a .el file) on Windows platform?

PluginsEmacsInstallation

Plugins Problem Overview


I'm new to Emacs. I found many emacs plugins are released as an .el file. I'm not sure how to install them. Can I just put them in my emacs installation directory?

Plugins Solutions


Solution 1 - Plugins

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 - Plugins

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 - Plugins

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:

  1. Create a directory called ~/.emacs.d/site-lisp.

  2. Install any single elisp files in the ~/.emacs.d/site-lisp directory.

  3. Install any packages that consist of multiple elisp files in a subdirectory under your ~/.emacs.d/site-lisp directory.

  4. 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.

Solution 4 - Plugins

Some supplementary information: MATLAB.el comes from http://matlab-emacs.sourceforge.net/

On windows, use the load path that looks like this:

(add-to-list 'load-path' "C:\\Dropbox\\Portable\\emacs\\matlab-emacs")

If you want FULL MATLAB functionality you should use:

;;MATLAB Mode:
(add-to-list 'load-path' "C:\\Dropbox\\Portable\\emacs\\matlab-emacs")
(require 'matlab-load)

if you just want to edit text files:

;;MATLAB Mode:
(add-to-list 'load-path' "C:\\Dropbox\\Portable\\emacs\\matlab-emacs")
(autoload 'matlab-mode "matlab" "Enter MATLAB mode." t)
(setq auto-mode-alist (cons '("\\.m\\'" . matlab-mode) auto-mode-alist))
(autoload 'matlab-shell "matlab" "Interactive MATLAB mode." t)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJust a learnerView Question on Stackoverflow
Solution 1 - PluginsloudandclearView Answer on Stackoverflow
Solution 2 - PluginsphilsView Answer on Stackoverflow
Solution 3 - PluginszevView Answer on Stackoverflow
Solution 4 - PluginsGerardView Answer on Stackoverflow