How do I install a MATLAB mode in GNU Emacs?
Asked Answered
A

5

26

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.

Akvavit answered 2/9, 2009 at 13:40 Comment(0)
C
29

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))
Conjunctivitis answered 2/9, 2009 at 21:5 Comment(2)
@rplevy, I feel quite dim for not thinking of this myself. Thanks very much.Akvavit
This answer gets visited a lot, so I thought it would be useful to post this question here which has useful tips for editing MATLAB code using octave-mode. emacs.stackexchange.com/questions/15164/…Zarathustra
K
7

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.

Kicksorter answered 2/9, 2009 at 13:56 Comment(0)
B
1

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.

Bo answered 2/9, 2009 at 13:51 Comment(0)
F
1

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.

Fumarole answered 2/9, 2009 at 19:15 Comment(0)
P
0

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.

Pantheon answered 2/9, 2009 at 16:25 Comment(1)
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.Akvavit

© 2022 - 2024 — McMap. All rights reserved.