0

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:

enter image description here

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).

9
  • Please, activate Options->Enter Debugger On Error and paste the backtrace here when you get it on the file mode specification error.
    – Tobias
    Dec 9, 2016 at 16:44
  • Done, refer to the last paragraph of the question. I thought octave-mode came pre-installed with Emacs. I have Emacs 25.1.90 (the latest experimental release). I searched ELPA for the package octave-mode but I couldn't find it...
    – Josh Pinto
    Dec 9, 2016 at 16:50
  • That's an easy one. You do not have octave-mode installed. Install it if you want to use it.
    – Tobias
    Dec 9, 2016 at 16:54
  • Didn't you read my last comment? I don't know how to install it so it isn't so easy. I've searched MELPA for it. I've also got other package archives enabled (see github.com/fusion809/emacs/blob/master/.emacs for details) and still I can't find it in the package list generated by M-x package-list.
    – Josh Pinto
    Dec 9, 2016 at 16:57
  • Should be in lisp/progmodes that comes with emacs. Hm.
    – Tobias
    Dec 9, 2016 at 16:59

1 Answer 1

0

This part of your config is causing the problem. You should use something like cua-mode instead of binding keys like C-c and C-x, which conflict with commonly used prefixes in emacs. cua-mode should make some of key combinations you use work as expected, and give you a way to use proper keybindings that begin with C-c and C-x.

https://www.gnu.org/software/emacs/manual/html_node/emacs/CUA-Bindings.html

4
  • Wrong question. This question isn't about my keybindings it's about MATLAB/Octave mode!
    – Josh Pinto
    Dec 9, 2016 at 16:51
  • @BrentonHorne Note, that DoMiNeLa10 is right. You can try to comment out the lines (global-set-key (kbd "C-c") 'kill-ring-save) and (global-set-key (kbd "C-x") 'kill-region) in your config and restart emacs. You will see that the file mode specification error goes away.
    – Tobias
    Dec 9, 2016 at 17:03
  • I'll be ****ed, it worked for MATLAB. But not Octave. Octave is giving: File error: Cannot open load file, No such file or directory, octave-mode. This question is about MATLAB, should I accept his answer and create a new question specific to Octave mode?
    – Josh Pinto
    Dec 9, 2016 at 17:06
  • @BrentonHorne This is not so much about octave-mode but more about something wired going on with your installation or your setup of load-path. I've invited you to a discussion at chat.stackexchange.com/rooms/49851/…. Please, join now. I do not have too much time.
    – Tobias
    Dec 9, 2016 at 17:11

Your Answer

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

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