How to get a MATLAB mode in (X)emacs

1. You first need to copy the file matlab.el somewhere on your machine. Hold down shift and save :).

2. Call that 'somewhere on your machine' your_path for now; whenever I mention your_path you should understand the full path to that location, as printed by 'pwd'.

3. Edit/Create a .emacs file in your home directory and add the following lines:


(autoload 'matlab-mode "/afs/cs.cmu.edu/user/cdima/.emacs_addons/matlab.el" "Enter Matlab mode." t)
(setq auto-mode-alist (cons '("\\.m\\'" . matlab-mode) auto-mode-alist))
(autoload 'matlab-shell "/afs/cs.cmu.edu/user/cdima/.emacs_addons/matlab.el" "Interactive Matlab mode." t)

As you can see, my directory is called /afs/cs.cmu.edu/user/cdima/.emacs_addons/ . You should replace this with whatever your_path is.

4. Essentially, you're done. If you care, you can compile the list code in matlab.el to matlab.elc as described in the readme.txt that comes from Mathworks. It should load faster but with the machines available nowadays it works perfectly well without compilation; in case you do compile, depending on what versions of emacs/xemacs you are using you may or may not run into some problems.

5. Test it by running emacs/xemacs and trying to switch to matlab-mode or matlab-shell. If you type M-x matlab- and try a self-completion, you should get a very very long list of options. You might want to spend some time trying various features.


Cristian S Dima
Last modified: Tue Sep 12 11:34:27 EDT 2000