Documentation on downloading a major mode for editing .m files under GNU-Emacs.
This project is managed on SourceForge.
Eric Ludlam (2021). Edit .m files in Emacs (https://www.mathworks.com/matlabcentral/fileexchange/104-edit-m-files-in-emacs), MATLAB Central File Exchange. Retrieved .
@Shenhai - If it is possible to start the terminal you describe below via a command (via Emacs variable `matlab-shell-command') and switches (via `matlab-shell-command-switches') then it is possible to use any external tool inside matlab-shell. It is likely, however, that if errors and debug statements are printed differently than a regular MATLAB session, important parts of matlab-shell won't work correctly. For example, the startup banner is needed to get info needed to load the history.
Thanks for maintaining this package, I used it a lot. However now I moved to a job where normally I have to use Windows. It is not very convenient because Matlab-shell command doesn't work on Windows. I understand that it is because matlab doesn't have standalone shell functions on windows.
I just came across this extension when I use vscode https://github.com/apommel/vscode-matlab-interactive-terminal. It seems that it uses python api engine to run matlab CLI on Windows and it works quite alright on vscode. Do you think it is possible to incorporate this into Emacs?
How do I build the package on Windows?
I unpacked the file from git, and the build instructions tell to run `make', but I don't have `make' on Windows.
Which one do I need to install? Cygwin? MSYS2?
I've enjoyed using this in the past but "Emacs (21.3 onwards) comes with an alternative built in: octave mode" . Emacs 21.3 was released in 2003.
The .zip file contains a README that explains how to get the source code.
If you can't open the ZIP file, visit http://matlab-emacs.sourceforge.net/ and get the sources from GIT.
I'm not getting the .el just a zipped text file which I'm not able to open!
It is somehow set to have the Right-hand text limit at ~68 characters, which is way too few (I prefer 100). I have extensively searched the code and internet and cannot understand how fix this. Very difficult to use when it always breaks lines of code.
I like this a lot but here is a bug report:
Emacs locks up when trying to tab in a Matlab file which contains a content with the word 'for' in the comment. Ctrl-g breaks out of the loop.
Can I fold or imenu section(%%) in .m file by emacs?
Can anyone help me? Please send me a copy of file "matlab.el". There is some unknown problem for me to download from sourceforge net. I currently use old version. I want to try new.
Good stuff!! I couldn't manage without this because I'm so much faster in emacs. However, I must agree with those who say that this is currently lacking features compared to the Mathworks editor.
I got the debugger working somewhat by loading the matlab-shell and calling "dbstop". Emacs shows an arrow at the line of code I'm currently stopped at. I was wondering:
1) Can emacs display where my breakpoints are?
2) Is it possible to set/remove breakpoints from emacs instead of having to type dbstop/dbclear?
3) Is there anyway to step code with a single key in emacs? (like f-10) rather than having to type 'dbstep' every time in the matlab portion of the window?
This mode is very good, but I'm afraid it's falling behind the evolution of the Matlab language.
I'm a rabid emacs user so I still use matlab.el, but I'm also experimenting with the emacs keybindings in the Matlab desktop. On the desktop, code highlighting and indenting work correctly, and there's an up-to-date debugger interface. On the other hand, many emacs key combinations are missing -- for just cranking out code, emacs/matlab.el is faster, at least for me.
I haven't yet decided which environment is more productive overall.
I need help with this. When i try to launch matlab from emacs, it would not work. I think the load-path was not set up properly. Where can I go to edit it?
i do love this mode and use it every day. it would be wonderful to see support for object oriented programming in the indentation blocks (class, methods, properties, having functions indented inside a class definition, etc). right now as far as i can tell declaring a function resets the overall indentation, so a function inside a class kind of screws everything up.
thanks for this, it's great.
I love it, and am grateful. In the spirit of cooperative improvement, I submit:
Bug Report, v2.3.1 in Unix (OSF1 V5.1 2650 alpha; XEmacs 21.1; May 1999) or Linux(GNU Emacs 21.3.1 (i386-redhat-linux-gnu, X toolkit, Xaw3d scroll bars) of 2003-05-22 on porky.devel.redhat.com):
Strings of '%' (e.g., used as boxes or separators) cause CPU looping. ^G terminates. Need to avoid the looping in the first place.
Also: fails to indent properly after comment lines as previously reported.
I have been using this for some time now and think that it is great. It is too bad that the native matlab editor cannot do a better job with its emacs emulation, as switching between the two for debug can be tiresome. Thank you for making this available.
I have the same problem as reported by Alexey Koloydenko. The script that starts matlab (for me: /opt/matlab/bin/matlab), uses exec when starting the binary, and Emacs' start-process (which is used by comint, which is used by matlab-shell) doesn't seem to like that. Creating a script that runs
works perfectly, while
exec /opt/matlab/bin/matlab "$@"
gives the "hangup"-message. (The "$@" is just so matlab-shell can pass arguments (e.g. -nodesktop) to the program.)
(I have no idea whether this is a problem with Emacs' start-process or the Matlab binary.)
Versions 2.3.1 and 3.0.1:
For some reason, I can only get the shell to work if I create an executable file containing the appropriate command (e.g. on my machine: /usr/local/bin/matlab -nodesktop -nojvm) and refer the matlab-shell-command variable to that file. Going directly fails with either '' M-Shell hangup'' (with the default matlab-shell-command variable provided by matlab.el) or with ''Can't exec program: /usr/local/bin/matlab -nodesktop -nojvm'' with '(matlab-shell-command "/usr/local/bin/matlab -nodesktop -nojvm"). Otherwise, I have been happily using this resource for several years.
Maybe I have the problem
I went through the source code of matlab.el version 2.3.1 with 2.2.3, and found the difference between two:
>in matlab.el v2.2.3 line 3659, the code is : comint-prompt-regexp "^K?>> *"
>but in v2.3.1 or higher ,the code is :comint-prompt-regexp "^\\(K\\|EDU\\)?>> *"
>I guess it maybe the problem, so I revised the source code of the version 2.3.1,and it works! then I tried the version 2.3.2 and version 3.0.1, It works in v2.3.2,but failed in 3.0.1.
There are bugs in matlab.el version higher than 2.3.1, because it can't not work correctly in windows xp, but works correctly in linux
the problem is:when lauch matlab-shell(the matlab-shell works correctly on cmd.ext),there are infinitly "<<",then the matlabshell cann't stop,always display "<<", so the whole screen is "<<<<<<<<<<<<<<<<<<<<<<<<<<...",and the buffer size is grow larger and larger, I don't kown why, but the matlab.el verson 2.2.3 works correctly
The matlab-shell fails to work with 18.104.22.168 (R14) Service Pack 3 and GNU Emacs 21.3.1. When starting with M-x matlab-shell the result is "M-Shell hangup"! The variable in the line 82 from matlab-shell-command-swithes should be matlab-shell-command-switches -Add the notable 'c'!
Hangs after multiple comment lines if they're at the beginning of the .m file.
I like the many configuration options.
When having two or more consecutive comment lines, pressing <enter> causes Emacs to hang. Fortunately C-g can break this infinite loop.
Better than the Matlab editor IMHO.
One (tiny) bug I found: if you have a variable named 'end_something' and you have a block like so:
the indentation doesn't work properly.
Indentation does not work after a comment line.
The default indentation is 2 while in the GUI it is 4. Otherwise it is of great help! Thank you very much!
Emacs gives me an error when I try byte-compile-file:
Compiling file /home/polaris/cao/matlab/matlab.el at Mon Jan 3 17:45:47 2005
** reference to free variable matlab-eei-process
While compiling matlab-mode:
** assignment to free variable add-log-current-defun-function
While compiling toplevel forms:
!! Invalid read syntax ((")"))
For more "modern" implementations of matlab, with the Java interface, you may want to modify the following in the .el file:
(defcustom matlab-shell-command-switches ""
(defcustom matlab-shell-command-switches "-nodesktop"
the same can be directly edited in the .elc file if you have it.
First off, thanks for making this available. One fix that I think is needed: When you insert a function from the menu, the name of the function (in caps), should be right next to the percent sign. There should not be a space.
Other then that, thank you for making this available.
Make sure that you put the .el file in the
/lisp folder wherever EMACS is stored or atleast add the path in the .emacs file
Thanks so much for making this available. I've always found MATLAB's built-in editor somewhat annoying, and you've liberated us from that.
It is good for me to program on UNIX.
good work....with a little typo in the comment:
it should be :
(setq matlab-shell-command-switches '("-nojvm"))
(setq matlab-shell-command-swithes '("-nojvm"))
Thanks... for those addicted to the many tools in emacs like me, this is great! It was easy to get working, too!
Only can say: "...thanks!"
Many thanks - this is really great help!
Matlab-mode brings the power of emacs and the power of matlab-engine together to build a great software. Matlab's own GUI is a pale attempt at making something useful.
Far better than the Matlab editor!
Thanks for that emacs-mode.
It really helps a lot.
Awesome: The emacs mode is a very convenient way to use matlab
.....but I still have to come up with the
Excellent mode - works well in Gnu/X Emacs. Prompt support via mailing list.
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!