Enable Octave mode in Emacs

Emacs Octave Support is already packaged in Emacs 22 and 23.

To begin using Octave mode for all `.m’ files you visit, add the following lines to a file loaded by Emacs at startup time, typically your `~/.emacs’ file:

(autoload 'octave-mode "octave-mod" nil t)
(setq auto-mode-alist
(cons '("\\.m$" . octave-mode) auto-mode-alist))

Finally, to turn on the abbrevs, auto-fill and font-lock features automatically, also add the following lines to one of the Emacs startup files:

(add-hook 'octave-mode-hook
(lambda ()
(abbrev-mode 1)
(auto-fill-mode 1)
(if (eq window-system 'x)
(font-lock-mode 1))))


3 Responses

  1. I had to alter the line:

    (cons ‘(”\\.m$” . octave-mode) auto-mode-alist))


    (append ‘((“\\.m$” . octave-mode)) auto-mode-alist))

    to get it to load octave mode properly.


    • I had a problem when I upgraded to Ubuntu 16.04. I had an error message saying it could not find “octave-mode” Now it works. Thanks.

  2. First of all this is a wonderful blog ! Now on to the question itself.

    Is there a way to set Octave mode manually ? Since I sometimes work with MATLAB .m files and at other times with Octave .m files I don’t want to set the Octave mode automatically for .m files.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: