views:

649

answers:

5

Is there an Emacs major mode for MATLAB and / or Octave files? For those who don't know, MATLAB files generally have a ".m" file extension.

My primary interest is GNU Emacs but XEmacs tips would also be appreciated.

A: 

Not built in in GNU Emacs 22. I found a matlab mode on the web (elisp), but it dates from circa 2000, so I don't know what kind of support you have.

To install you must get emacs to load it, then invoke the mode. You can interactively issue a load-file (With M-x load-file) to test it.

dmckee
+4  A: 

You'll be wanting http://matlab-emacs.sourceforge.net/ , I would imagine? Read the instructions there.

I used an ancestor of this years ago in XEmacs, so it certainly used to have support for it, but I believe the author is an GNUEmacs user. The guy who wrote it (Eric Ludlam) is a Mathworks employee, so it has vague official credentials.

ijw
A: 

Hi

I recently downloaded a Matlab mode for Emacs from the Matlab Central file exchange. Works just fine. Don't recall exactly where I found it, if you have trouble let me know and I will look harder.

Regards

Mark

High Performance Mark
For the purposes of a complete answer, it's definitely worth digging. Is this only available to Matlab users? If so, the Octave people are going to be annoyed.
Bob Cross
As far as I can tell anyone can download files from Matlab Central -- whether they are any use to the poor cousins who can't afford Matlab (sorry, that was smug of me) I don't know. My guess would be that since Emacs is fairly customisable a smart person could tailor matlab.el (or whatever it's called) to call Octave. Well outside my experience however.
High Performance Mark
A: 

There's a matlab.el file from Matthew Wette on The MathWorks File Exchange. The file doesn't appear to have been updated since 1997 (!), and simply says it is "for early versions of Emacs", but hopefully it will still be of use to you.

gnovice
+3  A: 

Have you tried the octave-mode that is part of the standard emacs distribution? I have found that this works well.

If you're finding it doesn't associate the .m extension, add this to your .emacs:

(setq auto-mode-alist
      (cons
       '("\\.m$" . octave-mode)
       auto-mode-alist))
rplevy
@rplevy, I feel quite dim for not thinking of this myself. Thanks very much.
Bob Cross