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, say.
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
teaching emacs temporarily
To teach emacs temporarily where to find M2, press
C-u f12
(Recall that in emacs' notation for key-presses, C-u means to press u while holding down the control key.) 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.
teaching emacs permanently
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.