You can configure matlab-emacs using the “matlab” or “matlab-shell” customization groups:
Emacs -> Options -> Customize Emacs -> Specific Group
The *.m file extension is used by MATLAB and by Objective-C. When matlab-mode is installed and
you visit a *.m file, if it contains MATLAB code, otherwise Objective-C mode. The default in Emacs
for *.m files is Objective-C, thus when visiting a new empty *.m file, Emacs will enter
Objective-C mode. To change the mode, you can run
M-x matlab-mode
If you’d like to always enter matlab-mode, run
M-x customize-variable RET matlab-mode-for-new-mfiles RET
By default when you run
M-x matlab-shell >> edit file.m
file.m will open in emacs using ‘emacsclient -n’. matlab-shell achieve this behavior by instructing MATLAB to use ‘emacsclient -n’ as the external text editor.
You can customize this by setting `matlab-shell-emacsclient-command’ in the matlab-shell customization group. You can change this command to what’s appropriate. If you set it to the empty string, ‘edit file.m’ will use the default MATLAB editor setting.
The default MATLAB editor setting is controlled in the MATLAB preferences, (e.g. R2018a Home tab, Environment section, Preferences) where you can select which editor you want to edit a text file. MATLAB Editor or an external text editor. If you always want to use Emacs as your matlab editor even when running MATLAB outside of emacs, select Text editor and set it to the appropriate ‘emacsclient -n’ command.
There can be several reasons for this. One reason would be if you are using syntax highlighting from a different package (such as tree-sitter) which is over-riding the font-lock provided by matlab-mode.
In this case, add the following hook to your config:
(add-hook 'matlab-sections-mode-hook
(lambda () (interactive)
(font-lock-add-keywords
nil
`((,matlab-sections-section-break-regexp
1 'matlab-sections-section-break-face prepend)))
(font-lock-flush)))Ensure that this is included after matlab-mode as well as your syntax highlighter are initialized in your config.