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

teaching Emacs how to find M2

If you teach your shell how to find M2, then you do not have to teach Emacs how to find M2. See teaching your shell how to find M2, and come back to this section only if you fail with that. Let's assume that you have found M2 (the program), and that is located in the directory /foo/bar/bin.

Let's assume you have already set up the function key F12 to call M2. That is done with the following command in the .emacs file.

(global-set-key [ f12 ] 'M2)

Then when you press F12, M2 should start running.

Here is what you will see on your screen in the minibuffer at the bottom of the screen when you press F12 if Emacs doesn't know how to find the file M2-init.el.

Symbol's function definition is void: M2

If you see that, you are not ready for this section: see teaching Emacs how to find M2-init.el.

Here is what you will see on your screen in a buffer named *M2* if Emacs knows how to find the file M2-init.el but not how to find the program M2.

+ M2 --no-readline --print-width 189
/bin/sh: M2: command not found

Process M2 exited abnormally with code 127

Method 1: temporarily switching the path to M2

To teach Emacs temporarily where to find M2, press C-u F12 (i.e. hold Ctrl and press u, then release and press F12). You will get the M2 command line in the minibuffer at the bottom of the screen, and you can edit it. It will initially look something like this:

M2 --no-readline --print-width 189

You can change it to the right thing:

/foo/bar/bin/M2 --no-readline --print-width 189

Then press Enter and M2 should start running. That will stick for the rest of your Emacs session. Later, to return to the *M2* window from another, or to start up M2 again, just press F12.

Method 2: editing ~/.emacs

Every time Emacs starts up it reads commands from the file .emacs in your home directory. Put the following command in your .emacs file.

(setq M2-exe "/foo/bar/bin/M2")

The next time you start Emacs it will know how to find M2.


The source of this document is in Macaulay2Doc/ov_editors_emacs.m2:459:0.