1

I am trying to use the matlab-mode package with use-package.

in my init.el:

(use-package matlab-mode
  :ensure t
  :config
  (add-to-list
   'auto-mode-alist
   '("\\.m\\'" . matlab-mode))
  (setq matlab-indent-function t)
  (setq matlab-shell-command "matlab"))

This seems to work - the package is downloaded and installed if necessary, the mode is automatically enabled in .m files, but everytime I launch Emacs I get the warning Error (use-package): Cannot load matlab-mode. Can anybody tell me why this happens?

1
  • Aware that this is an old post, is this still giving out an error? My call for matlab-mode is similar to yours and it works just fine, i.e., calling matlab-mode instead of matlab.
    – Ajned
    Jul 24, 2021 at 6:27

1 Answer 1

1

The package name is matlab-mode but the provided feature is matlab. Have a look at the very end of that source code file.

According to use-package Manual you have to get that right.

So your use-package declaration should look like this:

(use-package matlab
  :ensure matlab-mode
  :config
  (add-to-list
   'auto-mode-alist
   '("\\.m\\'" . matlab-mode))
  (setq matlab-indent-function t)
  (setq matlab-shell-command "matlab"))
2
  • use-package is not a valid command in emacs 25 Apr 5 at 14:40
  • use-package on Emacs before version 29, is a package which can be installed via GNU ELPA and MELPA.
    – jue
    Sep 9 at 8:10

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.