next | previous | forward | backward | up | top | index | toc | home
Macaulay2 > getting started > teaching emacs how to find M2-init.el

teaching emacs how to find M2-init.el

Files containing emacs source code have names of the form *.el. Macaulay 2 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 you are lucky, then the Macaulay 2 directory tree has been installed with the same root as the emacs directory tree. For example, if emacs and Macaulay 2 are both installed in /usr, then M2-init.el is located at /usr/share/emacs/site-lisp/M2-init.el, and emacs already knows to look in that directory for source files.

The simplest way to teach emacs how to find M2-init.el is to let M2 do it for you. Run M2, and then, in response to Macaulay2's input prompt, enter setup(). If that works, the next time you start emacs, it should know how to find M2-init.el (see setup). If that doesn't work, read onward.

To determine the precise path of the site-lisp directory emacs is looking in, so that you can install Macaulay 2 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 Macaulay 2 source code, and that M2-init.el is located at /foo/bar/share/emacs/site-lisp/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.

    (setq load-path 
          (append
           '( "/foo/bar/share/emacs/site-lisp" )
           load-path))
The next time you start emacs, emacs will look also in that directory for files, and it should find M2-init.el.