I have installed the matlab-mode-20160902.459
package from MELPA and whenever I open an m file (i.e., a file with the file extension .m
which is the file extension of most MATLAB/GNU Octave scripts) I get an error message shown in the below screenshot:
Here is my present ~/.emacs
file. As you can see on line 129 I have added the line:
(add-to-list 'auto-mode-alist '("\\.m$" . matlab-mode))
to hopefully autoload matlab-mode
whenever I open an m file. I really have no idea how to fix this error as I haven't pressed C-x when I opened this file... If relevant I opened my m files using the Emacs directory browser shown in the screenshot.
Is it perhaps that this ~/.emacs
line that sets .m
files to be handled by matlab-mode
conflicts with the default handling of .m
files as Objective C files? Regardless of the cause a solution would be wonderful. I don't ever code in objective C (I am a loyal Linux user with no interest in iOS or macOS development), but I do code in GNU Octave / MATLAB, so setting m files as being associated with matlab-mode
would be ideal.
EDIT:
I have tried using octave-mod
instead by adding:
(setq auto-mode-alist
(cons '("\\.m$" . octave-mode) auto-mode-alist))
(add-hook 'octave-mode-hook
(lambda ()
(abbrev-mode 1)
(auto-fill-mode 1)
(if (eq window-system 'x)
(font-lock-mode 1))))
to my ~/.emacs
file (in accordance with this guide). That gave the same error when opening an ~/.emacs
file (and yes I did remove the matlab-mode
line before I added these lines to make it a fair test of whether it works).
I have seen this question at StackOverflow but neither upvoted answer (which presently are this and this) worked for me: they both returned the same error whenever I opened an m file and neither caused syntax-highlighting of the m file to occur.
The backtrace generated by going to Options→Enter Debugger on Error was, when I opened the m file /home/fusion809/GitHub/mine/scripts/GNU_Octave/first.m
:
Debugger entered--Lisp error: (file-error "Cannot open load file" "No such file or directory" "octave-mode")
octave-mode()
set-auto-mode-0(octave-mode nil)
set-auto-mode()
normal-mode(t)
after-find-file(nil t)
find-file-noselect-1(#<buffer first.m> "~/GitHub/mine/scripts/GNU_Octave/first.m" nil nil "~/GitHub/mine/scripts/GNU_Octave/first.m" (21370145 2052))
find-file-noselect("/home/fusion809/GitHub/mine/scripts/GNU_Octave/first.m" nil nil nil)
find-file-other-window("/home/fusion809/GitHub/mine/scripts/GNU_Octave/first.m")
dired-mouse-find-file-other-window((mouse-2 (#<window 3 on GNU_Octave> 419 (546 . 123) 39532480 nil 419 (60 . 6) nil (6 . 15) (9 . 18))))
funcall-interactively(dired-mouse-find-file-other-window (mouse-2 (#<window 3 on GNU_Octave> 419 (546 . 123) 39532480 nil 419 (60 . 6) nil (6 . 15) (9 . 18))))
call-interactively(dired-mouse-find-file-other-window nil nil)
command-execute(dired-mouse-find-file-other-window)
With MATLAB mode (instead of Octave mode as in the last backtrace) I get the backtrace http://paste2.org/wDE8VcbV (too long to paste here).
Options->Enter Debugger On Error
and paste the backtrace here when you get it on the file mode specification error.octave-mode
came pre-installed with Emacs. I have Emacs 25.1.90 (the latest experimental release). I searched ELPA for the packageoctave-mode
but I couldn't find it...octave-mode
installed. Install it if you want to use it.M-x package-list
.lisp/progmodes
that comes with emacs. Hm.