Macaulay2 » Documentation
Packages » Macaulay2Doc » setting up Macaulay2 » using Macaulay2 with Emacs » setting up the Macaulay2 Emacs interface » teaching Emacs how to find M2-init.el
next | previous | forward | backward | up | index | toc

teaching Emacs how to find M2-init.el

Files containing Emacs source code have names of the form *.el. Macaulay2 comes with a file called M2-init.el that sets up Emacs for running M2 conveniently. It is important that Emacs be able to find that file and the three other files that come with it, by searching in the directories listed in the Emacs variable load-path.

If the Macaulay2 directory tree has been installed with the same root as the Emacs directory tree, then Emacs already knows to look in that directory for source files. For example, if Emacs and Macaulay2 are both installed in /usr, then M2-init.el is located at /usr/share/emacs/site-lisp/Macaulay2/M2-init.el.

Method 1: using setup

The simplest way to teach Emacs how to find M2-init.el is to let M2 do it for you. Start M2 in a terminal window and enter setup(). If that works, the next time you start Emacs, it should know how to find M2-init.el.

Method 2: editing ~/.emacs

To determine the precise path of the site-lisp directory Emacs is looking in, so that you can install Macaulay2 properly, use the Emacs describe-variable command, accessible with the key strokes C-h v, and ask for the description of the variable load-path.

Let's assume that you have located the Macaulay2 source code, and that M2-init.el is located at /foo/bar/share/emacs/site-lisp/Macaulay2/M2-init.el, and that you want to tell Emacs to search that directory, too. Insert the following command into the file .emacs in your home directory.

(add-to-list 'load-path "/foo/bar/share/emacs/site-lisp/Macaulay2")

The next time you start Emacs, it will look also in that directory for files, and it should find M2-init.el.


The source of this document is in /build/reproducible-path/macaulay2-1.25.05+ds/M2/Macaulay2/packages/Macaulay2Doc/ov_editors_emacs.m2:459:0.