Maxima mode for Emacs

(Please note: This page is not 'official', but 'user-contributed documentation'!)
Using Maxima from the UNIX command line allows only very basic editing. Fortunately, there is an Emacs-mode available, which makes life a lot easier.
It provides: Here are screenshots:

Figure 1: Running a maxima process in Emacs

Figure 2: Using Emacs to evaluate a part of a text file

Figure 3: Syntax-highlighting for Maxima code

Installation (with root access)

Note: In the meantime, there have been significant changes in the maxima mode for emacs. I haven't checked the contents of this page with the latest version. Read the head of the 'maxima.el' file for up-to-date instructions.
'maxima.el' has to be copied into the Emacs site-lisp folder.
On my machine, this is /usr/share/emacs/site-lisp or /usr/local/lib/emacs/xx.xx/site-lisp, where xx.xx is the version number.
If you can't find it, cd /; find . -name "site-lisp" will find it for you (burning a lot of CPU-time in the process).

Unpack the file with
gzip -dc MaximaMode_For_Emacs_tar.gz | tar -xvf  - and move the contents into the mentioned folder.

Then you'll have to modify your .emacs file (in your home directory, do cd ~; emacs .emacs)
Append the following lines:
(autoload 'maxima-mode "maxima" "Maxima editing mode" t)
(autoload 'maxima "maxima" "Running Maxima interactively" t)
You'll find them at the beginning of maxima.el, so just copy and paste them (remove ; at start of line).
Then set the path, where your Maxima-installation keeps its documentation:
(setq maxima-info-dir "/usr/local/lib/maxima-5.5/info")
(replace the path with the location of your Maxima-installation)

I use syntax highlighting by default, so there is another line
(global-font-lock-mode t)
in my .emacs file.

You'll have to restart Emacs at this point (or load the files by hand).

Installation (without root access)

Without root access, you can't put files into the site-lisp folder. Instead, copy the two .el-files into any folder and add the following lines to your .emacs file:
(load-file "/home/yourname/yourfolder/maxima.el")
(load-file "/home/yourname/yourfolder/maxima-font-lock.el")
Otherwise, same as 'installation with root access'.

Starting Maxima interactive mode

Start Emacs.
(Note: C-M-a means: press <Ctrl>,<Alt> and <a> at the same time.
C-c ; means: press <Ctrl> and <c> at the same time, release them, press <;>.
<Alt> is also known as the <Meta>-key, that's where the M comes from.

Press M-x maxima, press <Enter>

Now the window should look almost like the screenshot in figure 1.
Type 3+4; <Return> to test it, Maxima replies '7'.

<Ctrl> and <Cursor-up> at the same time recalls the last command (<Ctrl-Cursor-down> does the opposite).
To turn on syntax highlighting (coloured text, as seen in the screenshots), click on 'Help' - 'Options' - 'Global Font Lock'.

Working with Maxima on a text file

Note: If you encounter problems, restarting Emacs may help, especially if both modes got mixed up.
Start Emacs.
Type M-x maxima-mode
Now the window will show a *scratch*-buffer.

Enter 3+4;
and press C-M-l. This evaluates the current line.
C-M-f will evaluate a complete expression (i.e. everything between two ; or $ characters).
Note: Delete the 'This buffer is for notes you don't want to save...', or put a '$' or ';' in the line before 3+4;
C-M-r will evaluate the selection, C-M-b the complete buffer.
There is a 'Maxima' menu entry, where you will find commands to kill and restart Maxima.
Note: This may help if you are getting strange error messages in the output window.

Key shortcuts

C-M-l Evaluate current line
C-M-r Evaluate current selection
C-M-b Evaluate whole buffer
C-c ; Insert short comment
C-c : Insert long comment
C-c C-a Move to the beginning of the current command ('form')
C-c C-e Move to the end of the current form

More information

Have a look at maxima.el - the 'official' documentation is in there.

Latest version

I downloaded the file It appeared in sci.math.symbolic on 20 March 2001.
The Maxima homepage is here
This page is hosted at SourceForge