branch: externals/matlab-mode commit 6d1ae88fb92a1c85352f2e7ffbff22466be45dcb Author: John Ciolfi <john.ciolfi...@gmail.com> Commit: John Ciolfi <john.ciolfi...@gmail.com>
Move faq from README.org into doc/faq.org --- README.org | 51 ++----------------------------- doc/faq.org | 71 ++++++++++++++++++++++++++++++++++++++++++++ doc/matlab-code-sections.org | 5 ++++ 3 files changed, 78 insertions(+), 49 deletions(-) diff --git a/README.org b/README.org index 9da905bb52..1bef6883ac 100644 --- a/README.org +++ b/README.org @@ -127,56 +127,9 @@ GPL3, https://www.gnu.org/licenses/gpl-3.0.en.html (see [[file:License.txt][Lice * FAQ -** How do I customize matlab-mode? +See [[file:doc/faq.org][doc/faq.org]] -You can configure matlab-emacs using the "matlab" or "matlab-shell" customization groups: - -: Emacs -> Options -> Customize Emacs -> Specific Group - -** How do I customize "edit file.m" behavior? - -By default when you run - - #+begin_example - M-x matlab-shell - - >> edit file.m - #+end_example - -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. - -** The code-sections are not highlighted properly. What do I do? - -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: -#+begin_src emacs-lisp - (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))) -#+end_src -Ensure that this is included after matlab-mode as well as your syntax -highlighter are initialized in your config. - -** Mailing list? +* Mailing list https://sourceforge.net/projects/matlab-emacs/ diff --git a/doc/faq.org b/doc/faq.org new file mode 100644 index 0000000000..6c1fcca292 --- /dev/null +++ b/doc/faq.org @@ -0,0 +1,71 @@ +# File: doc/faq.org + +#+startup: showall +#+options: toc:nil + +# Copyright 2025 Free Software Foundation, Inc. + +* Q: How do I customize matlab-mode? + +You can configure matlab-emacs using the "matlab" or "matlab-shell" customization groups: + +: Emacs -> Options -> Customize Emacs -> Specific Group + +* Q: How do I always enter matlab-mode for new ~*.m~ files? + +The ~*.m~ file extension is used by MATLAB and by [[https://en.wikipedia.org/wiki/Objective-C][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 + +* Q: How do I customize "edit file.m" behavior? + +By default when you run + + #+begin_example + M-x matlab-shell + + >> edit file.m + #+end_example + +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. + +* Q: The code-sections are not highlighted properly. What do I do? + +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: + +#+begin_src emacs-lisp + (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))) +#+end_src + +Ensure that this is included after matlab-mode as well as your syntax +highlighter are initialized in your config. + diff --git a/doc/matlab-code-sections.org b/doc/matlab-code-sections.org index 8524367862..891a8cb08a 100644 --- a/doc/matlab-code-sections.org +++ b/doc/matlab-code-sections.org @@ -59,6 +59,11 @@ MATLAB Command Window: The sections are run asynchronously. After sending the emacsrunregion command to MATLAB, control is returned to Emacs. In MATLAB, you'll see the ">>" prompt reappear when emacsrunregion is complete. +** Tryout MATLAB code section support + +You can use [[file:examples/matlab-sections/tryout_matlabsection.m][examples/matlab-sections/tryout_matlabsection.m]] to tryout MATLAB code section support +in Emacs. + ** Customizations If you'd like to use super (aka Windows) key bindings instead of the above key bindings, you can