0

I'd like to use the octave mode for emacs. There is no octave-mode package in MELPA, but EmacsWiki (https://www.emacswiki.org/emacs/OctaveMode) and the emacs manual seem to suggest that it is built-in for v21 and higher (I have v28). However, simply opening a .m file does not activate it.

Even adding the following to .emacs does not work:

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

The error is: File mode specification error: (file-missing Cannot open load file No such file or directory octave-mod), which does not make sense if the package is built-in. Am I missing something?

3
  • 1
    The file is octave.elc, so try (require 'octave). You can use locate-library to see if the library exists and what it is called (it allows completion with TAB). The autoload probably indicates that there is no entry for .m files in auto-mode-alist; try adding it with (add-to-list 'auto-mode-alist '("\\.m$" . octave-mode)) and see if that works.
    – NickD
    Mar 29, 2023 at 13:39
  • 1
    The require shouldn't be necessary, octave-mode is autoloaded by default. So just evaluate the add-to-list form from @NickD's comment, before opening the .m file. Mar 29, 2023 at 13:43
  • Yes - the require is a debugging step: if that succeeds, then the library exists. The next step then would be to see why the autoload did not work: checking auto-mode-alist to see if it contains that entry would do that. Strictly speaking, neither step should be necessary: auto-mode-alist should include the entry and the library should be autoloaded. Thanks for clarifying!'
    – NickD
    Mar 29, 2023 at 14:01

1 Answer 1

0

Adding (add-to-list 'auto-mode-alist '("\\.m$" . octave-mode)) to .emacs as suggested in the comments, has solved the problem!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.