From: martinoidar <mar...@gm...> - 2024-04-18 16:12:02
|
Hello, thanks for maintaining the project. Nidish N., thank you for font-lock-reference-face fix. There are two issues regarding this fix: - melpa repository (https://melpa.org/#/matlab-mode) still contains version from July 2023. It would be nice if you could upload the most recent version of the package in order to have its fixed version available via emacs package installer for those who are less proficient in git or sourceforge stuff. - I still have a tiny problem with matlab-mode in Emacs 29.1 (org 9.6.26). I simply loose syntax highlighting every time I insert for loop in matlab source block. Syntax goes to white after I add any character following '='. This is how it looks like: https://ibb.co/MDwPffV Regards, M |
From: Uwe B. <ou...@ma...> - 2024-04-18 17:45:29
Attachments:
smime.p7s
|
>>> "m" == martinoidar <mar...@gm...> writes: Hello > Hello, > thanks for maintaining the project. > Nidish N., thank you for font-lock-reference-face fix. > There are two issues regarding this fix: > - melpa repository (https://melpa.org/#/matlab-mode) still contains > version from July 2023. It would be nice if you could upload the > most recent version of the package in order to have its fixed > version available via emacs package installer for those who are less > proficient > in git or sourceforge stuff. Ok. Will try this later. BTW that reminds me to solve the GPL license issue, since we could then have the package in ELPA not only in MELPA. > - I still have a tiny problem with matlab-mode in Emacs 29.1 (org > 9.6.26). I simply loose syntax highlighting every time I insert for > loop > in matlab source block. Syntax goes to white after I add any character > following '='. This is how it looks like: > https://ibb.co/MDwPffV That is strange, I have a master version of emacs 29, which might correspond to yours, but why do you mention the org version? And now that we are in the discussion. 1. It has been proposed to move or mirror the main development to github. John Ciolfi proposed https://github.com/mathworks, but I don't have write access to this site, @John any news on your side. 2. I also would like, as we agreed, rename the main branch from «master» to «default» because that would simplify things for me. Regards Uwe -- I strongly condemn Hamas heinous despicable pogroms/atrocities on Israel I strongly condemn Putin's war of aggression against Ukraine. I support to deliver weapons to Ukraine's military. I support the EU and NATO membership of Ukraine. |
From: Uwe B. <ou...@ma...> - 2024-04-18 20:10:35
Attachments:
smime.p7s
|
>>> "m" == martinoidar <mar...@gm...> writes: > Hello, > thanks for maintaining the project. > Nidish N., thank you for font-lock-reference-face fix. > There are two issues regarding this fix: > - melpa repository (https://melpa.org/#/matlab-mode) still contains > version from July 2023. It would be nice if you could upload the > most recent version of the package in order to have its fixed > version available via emacs package installer for those who are less > proficient > in git or sourceforge stuff. > - I still have a tiny problem with matlab-mode in Emacs 29.1 (org > 9.6.26). I simply loose syntax highlighting every time I insert for > loop > in matlab source block. Syntax goes to white after I add any character > following '='. This is how it looks like: > https://ibb.co/MDwPffV Ok I did not see that link, I don't face this problem, but I realized I use the font-lock patch. That is why I merged both patches into master and pushed. MELPA should be updated soon. Regards -- I strongly condemn Hamas heinous despicable pogroms/atrocities on Israel I strongly condemn Putin's war of aggression against Ukraine. I support to deliver weapons to Ukraine's military. I support the EU and NATO membership of Ukraine. |
From: martinoidar <mar...@gm...> - 2024-04-19 11:51:41
|
>> - I still have a tiny problem with matlab-mode in Emacs 29.1 (org >> 9.6.26). I simply loose syntax highlighting every time I insert for >> loop >> in matlab source block. Syntax goes to white after I add any character >> following '='. This is how it looks like: >> https://ibb.co/MDwPffV > Ok I did not see that link, I don't face this problem, but I realized I > use the font-lock patch. > > That is why I merged both patches into master and pushed. MELPA should > be updated soon. > > Regards Everything's ok now. The confusion was caused by the fact that when I downloaded yesterday the latest snapshot from your master branch I was convinced that it included Nidish's patches (well, he had sent them almost half a year ago! :-)) and only today I realized it hadn't been true and the patches were still only in his fork. I downloaded the latest version of the package from Melpa and now I have no problems with code highlighting. BTW. in merge requests ( https://sourceforge.net/p/matlab-emacs/src/merge-requests/ ) Nidish's issues are still marked as "open". PS. I upvote the idea of migration to github. After getting used to it, the sourceforge webpage seems a bit... well... cumbersome? |
From: Uwe B. <ou...@ma...> - 2024-04-19 13:01:59
Attachments:
smime.p7s
|
> Everything's ok now. > The confusion was caused by the fact that when I downloaded > yesterday the latest snapshot from your master branch > I was convinced that it included Nidish's patches > (well, he had sent them almost half a year ago! :-)) yes. I wanted to test them, which I did and then I forgot all about it 😳 > and only today I realized it hadn't been true and the patches > were still only in his fork. > I downloaded the latest version of the package from Melpa and now > I have no problems with code highlighting. Good > BTW. in merge requests ( > https://sourceforge.net/p/matlab-emacs/src/merge-requests/ ) > Nidish's issues are still marked as "open". OK > PS. I upvote the idea of migration to github. After getting used to > it, the sourceforge webpage seems a bit... well... cumbersome? Well, right the sourceforge webpage is not very, hm modern (or user friendly) - The problem with github is there are already many either mirrors or forks, so we should be sure that users find the correct repository. That is why John proposal to have it within the mathwork groups seems logic to me, but alas, as I said, I don't have write access there. - I personally prefer gitlab over github, but this is just me (I am not a huge fan of these interfaces like issues etc, I prefer good old mailing lists, but then, I also prefer mercurial over git, but the set of mercurial users is quite small nowadays.) BTW, do you use babel to execute matlab code directly in the org file? If so, how? I use the python engine for this. It is convenient and fast but to start it, is a bit cumbersome. John told me that he is working on native (python free) solution, but it is not in master still Regards -- I strongly condemn Hamas heinous despicable pogroms/atrocities on Israel I strongly condemn Putin's war of aggression against Ukraine. I support to deliver weapons to Ukraine's military. I support the EU and NATO membership of Ukraine. |
From: martinoidar <mar...@gm...> - 2024-04-21 17:08:52
|
> - I personally prefer gitlab over github, but this is just me (I am > not a huge fan of these interfaces like issues etc, I prefer good > old mailing lists, but then, I also prefer mercurial over git, but > the set of mercurial users is quite small nowadays.) Well, I also prefer gitlab, especially after recent controversies with co-pilot (https://www.infoworld.com/article/3627319/github-copilot-is-unacceptable-and-unjust-says-free-software-foundation.html), though I'm not fervent about it... > > BTW, do you use babel to execute matlab code directly in the org file? > > If so, how? > > I use the python engine for this. It is convenient and fast but to start > it, is a bit cumbersome. John told me that he is working on native > (python free) solution, but it is not in master still > Yes, I do use org-babel and matlab. Until now, it hasn't been flawless experience but I manage to get the results back. But to be honest, I have no idea what mysterious mechanism enables me that. It's not been long since I've been using emacs, so there's still many lines in my init.el copied from here and there in a hope they will do... According to my notes I followed the instructions from here: https://gewhere.github.io/blog/2017/12/19/setup-matlab-in-emacs-and-babel-orgmode/ but nowwhen I inspect my init.el I can find only the code from the last section of above-mentioned page ("Setup MATLAB with babel orgmode"). Besides installing matlab-mode I have also manually downloaded: https://github.com/karthink/.emacs.d/blob/master/plugins/ob-octave-fix.el and included in init.el following the discussion found here: - https://www.reddit.com/r/emacs/comments/pufgce/matlab_mode/ - https://www.reddit.com/r/emacs/comments/fy98bs/orgbabels_matlab_session_output_is_malformed/ ... and that's all... org-babel and matlab somehow work together and I try not to complain much... ;) Let me now if you are interested in details and I will send you my init.el. Regards, M |
From: Uwe B. <ou...@ma...> - 2024-04-21 17:41:05
Attachments:
smime.p7s
|
> Well, I also prefer gitlab, especially after recent controversies with > co-pilot > (https://www.infoworld.com/article/3627319/github-copilot-is-unacceptable-and-unjust-says-free-software-foundation.html), > though I'm not fervent about it... > Yes, I do use org-babel and matlab. Until now, it hasn't been flawless > experience but I manage to get the results back. > But to be honest, I have no idea what mysterious mechanism enables me > that. It's not been long since I've been using emacs, so there's still > many lines in my init.el copied from here and there in a hope they > will do... > According to my notes I followed the instructions from here: > https://gewhere.github.io/blog/2017/12/19/setup-matlab-in-emacs-and-babel-orgmode/ > but nowwhen I inspect my init.el I can find only the code from the > last section of above-mentioned page ("Setup MATLAB with babel > orgmode"). > Besides installing matlab-mode I have also manually downloaded: > https://github.com/karthink/.emacs.d/blob/master/plugins/ob-octave-fix.el > and included in init.el following the discussion found here: > - https://www.reddit.com/r/emacs/comments/pufgce/matlab_mode/ > - > https://www.reddit.com/r/emacs/comments/fy98bs/orgbabels_matlab_session_output_is_malformed/ > ... and that's all... org-babel and matlab somehow work together and I > try not to complain much... ;) Thanks I will study this later. What I am most interested is 1. Execute matlab code in a org buffer (with the correct block around the matlab code. 2. Insert the result directly in the org buffer. Here in exchange is my method. 1. The python engine shipped by mathworks (warning different matlab releases require different python versions, that is why I am stuck at the moment with R2019A, which still support python 3.5. 2. ob-ipython Actually the following steps ** Python3 and matlab-kernel: HOWTO sudo apt-get install python3-setuptools sudo -H python3 -m pip install jupyter sudo apt-get remove python3-pexpect sudo -H python3 -m pip install pexpect sudo -H python3 -m pip install matlab_kernel ** Install the python API for matlab. MATLABROOT=/usr/local/MATLAB/R2019a Cd $MATLABROOT/extern/engines/python sudo -H python3 setup.py install ** Start the engine Run /usr/bin/python3 in the python prompt: import matlab.engine eng = matlab.engine.start_matlab() the eng command needs some time to run. When finished run now eng.quit() #+BEGIN_SRC emacs-lisp (setq org-confirm-babel-evaluate nil) ;don't prompt me to confirm everytime I want to evaluate a block ;;; display/update images in the buffer after I evaluate (add-hook 'org-babel-after-execute-hook 'org-display-inline-images 'append) (add-to-list 'org-src-lang-modes '("matlab" . matlab)) (setq python-shell-interpreter "python3") ;; set default headers for convenience (setq org-babel-default-header-args:matlab '((:results . "output replace") (:session . "matlab") (:kernel . "matlab") (:exports . "code") (:cache . "no") (:noweb . "no") (:hlines . "no") (:tangle . "no"))) (defalias 'org-babel-execute:matlab 'org-babel-execute:ipython) (defalias 'org-babel-prep-session:matlab 'org-babel-prep-session:ipython) (defalias 'org-babel-matlab-initiate-session 'org-babel-ipython-initiate-session) #+END_SRC #+RESULTS: : org-babel-matlab-initiate-session Then use the following example #+begin_src matlab :results output latex :exports results :eval never-export :wrap latex x = [1, 2, 3, 4, 5]; fprintf('|%d', x) #+end_src #+RESULTS: #+begin_latex |1|2|3|4|5 #+end_latex Uwe -- I strongly condemn Hamas heinous despicable pogroms/atrocities on Israel I strongly condemn Putin's war of aggression against Ukraine. I support to deliver weapons to Ukraine's military. I support the EU and NATO membership of Ukraine. |
From: martinoidar <mar...@gm...> - 2024-04-21 21:35:36
|
On 21.04.2024 19:40, Uwe Brauer wrote: > >> Well, I also prefer gitlab, especially after recent controversies with >> co-pilot >> (https://www.infoworld.com/article/3627319/github-copilot-is-unacceptable-and-unjust-says-free-software-foundation.html), >> though I'm not fervent about it... > > >> Yes, I do use org-babel and matlab. Until now, it hasn't been flawless >> experience but I manage to get the results back. >> But to be honest, I have no idea what mysterious mechanism enables me >> that. It's not been long since I've been using emacs, so there's still >> many lines in my init.el copied from here and there in a hope they >> will do... >> According to my notes I followed the instructions from here: >> https://gewhere.github.io/blog/2017/12/19/setup-matlab-in-emacs-and-babel-orgmode/ >> but nowwhen I inspect my init.el I can find only the code from the >> last section of above-mentioned page ("Setup MATLAB with babel >> orgmode"). >> Besides installing matlab-mode I have also manually downloaded: >> https://github.com/karthink/.emacs.d/blob/master/plugins/ob-octave-fix.el >> and included in init.el following the discussion found here: >> - https://www.reddit.com/r/emacs/comments/pufgce/matlab_mode/ >> - >> https://www.reddit.com/r/emacs/comments/fy98bs/orgbabels_matlab_session_output_is_malformed/ > >> ... and that's all... org-babel and matlab somehow work together and I >> try not to complain much... ;) > Thanks I will study this later. What I am most interested is > > 1. Execute matlab code in a org buffer (with the correct block around the matlab code. > > 2. Insert the result directly in the org buffer. > > Here in exchange is my method. > > 1. The python engine shipped by mathworks (warning different matlab > releases require different python versions, that is why I am > stuck at the moment with R2019A, which still support python 3.5. > > 2. ob-ipython > > Actually the following steps > > > > ** Python3 and matlab-kernel: HOWTO > sudo apt-get install python3-setuptools > sudo -H python3 -m pip install jupyter > sudo apt-get remove python3-pexpect > sudo -H python3 -m pip install pexpect > sudo -H python3 -m pip install matlab_kernel > ** Install the python API for matlab. > MATLABROOT=/usr/local/MATLAB/R2019a > Cd $MATLABROOT/extern/engines/python > sudo -H python3 setup.py install > ** Start the engine > Run > /usr/bin/python3 > in the python prompt: > import matlab.engine > eng = matlab.engine.start_matlab() > the eng command needs some time to run. > When finished run now > eng.quit() > > #+BEGIN_SRC emacs-lisp > (setq org-confirm-babel-evaluate nil) ;don't prompt me to confirm everytime I want to evaluate a block > ;;; display/update images in the buffer after I evaluate > (add-hook 'org-babel-after-execute-hook 'org-display-inline-images 'append) > > (add-to-list 'org-src-lang-modes '("matlab" . matlab)) > (setq python-shell-interpreter "python3") > ;; set default headers for convenience > (setq org-babel-default-header-args:matlab > '((:results . "output replace") > (:session . "matlab") > (:kernel . "matlab") > (:exports . "code") > (:cache . "no") > (:noweb . "no") > (:hlines . "no") > (:tangle . "no"))) > (defalias 'org-babel-execute:matlab 'org-babel-execute:ipython) > (defalias 'org-babel-prep-session:matlab 'org-babel-prep-session:ipython) > (defalias 'org-babel-matlab-initiate-session 'org-babel-ipython-initiate-session) > #+END_SRC > #+RESULTS: > : org-babel-matlab-initiate-session > Then use the following example > #+begin_src matlab :results output latex :exports results :eval never-export :wrap latex > x = [1, 2, 3, 4, 5]; > fprintf('|%d', x) > #+end_src > > #+RESULTS: > #+begin_latex > |1|2|3|4|5 > #+end_latex > > > Uwe > > Your approach is indeed cumbersome. In mine we need to: 1. Install `matlab-support` - a debian package that enables matlab integration within the system: sudo apt install matlab-support 2. In Emacs: install `matlab-mode` package 3. Download https://github.com/karthink/.emacs.d/blob/master/plugins/ob-octave-fix.el and put it somewhere in Emacs search path. 4. My init.el content with matlab/org-babel configurations: ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; enabling org-babel (org-babel-do-load-languages 'org-babel-load-languages '( (C . t) ; enable processing C, C++, and D source blocks (matlab . t) ;;(perl . t) (octave . t) (org . t) (python . t) (plantuml . t) (shell . t) )) ;; setup matlab in babel (setq org-babel-default-header-args:matlab '((:results . "output") (:session . "*MATLAB*"))) ;; octave/matlab-fix ;;;; (require 'ob-octave-fix nil t) ; This is for older approach (require 'ob-octave-fix) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; I do remember that this 'ob-octave-fix' is very important. Otherwise there are some problems... This works with Emacs 29.1 and currently Matlab 2023b. The code you provided returned nothing in my case and in order to obtain the same result I needed to tailor it a bit (Should there really be a call to 'fprintf'?): #+begin_src matlab :results output latex :exports results :eval never-export :wrap latex x = [1, 2, 3, 4, 5] ; disp(sprintf('|%d', x)) #+end_src #+RESULTS: #+begin_latex |1|2|3|4|5 #+end_latex |
From: Uwe B. <ou...@ma...> - 2024-04-22 12:52:56
Attachments:
smime.p7s
|
Hi Some comments, since it did not work as expected. > On 21.04.2024 19:40, Uwe Brauer wrote: > Your approach is indeed cumbersome. > In mine we need to: > 1. Install `matlab-support` - a debian package that enables matlab > integration within the system: > sudo apt install matlab-support installed > 2. In Emacs: install `matlab-mode` package installed > 3. Download > https://github.com/karthink/.emacs.d/blob/master/plugins/ob-octave-fix.el Installed > and put it somewhere in Emacs search path. > 4. My init.el content with matlab/org-babel configurations: > ;; > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > ;; enabling org-babel > (org-babel-do-load-languages > 'org-babel-load-languages '( > (C . t) ; enable processing C, C++, and D source blocks > (matlab . t) > ;;(perl . t) > (octave . t) > (org . t) > (python . t) > (plantuml . t) > (shell . t) > )) > ;; setup matlab in babel > (setq org-babel-default-header-args:matlab > '((:results . "output") (:session . "*MATLAB*"))) > ;; octave/matlab-fix > ;;;; (require 'ob-octave-fix nil t) ; This is for older approach > (require 'ob-octave-fix) done. Now I executed #+begin_src matlab x = [1, 2, 3, 4, 5]; fprintf('|%d', x) #+end_src And obtained in a different window: --8<---------------cut here---------------start------------->8--- NameErrorTraceback (most recent call last) <ipython-input-3-e039b5096438> in <module> 1 x = [1, 2, 3, 4, 5]; ----> 2 fprintf('|%d', x) NameError: name 'fprintf' is not defined --8<---------------cut here---------------end--------------->8--- So 1. the result is not inserted in my org buffer, 2. Morever fprintf is not defined, let me suspect this is not matlab what is excecuted but octave. Am I right? What do I miss here? Uwe -- I strongly condemn Hamas heinous despicable pogroms/atrocities on Israel I strongly condemn Putin's war of aggression against Ukraine. I support to deliver weapons to Ukraine's military. I support the EU and NATO membership of Ukraine. |
From: martinoidar <mar...@gm...> - 2024-04-22 17:35:49
|
On 22.04.2024 14:52, Uwe Brauer wrote: > Hi > > Some comments, since it did not work as expected. > > >> On 21.04.2024 19:40, Uwe Brauer wrote: >> Your approach is indeed cumbersome. >> In mine we need to: >> 1. Install `matlab-support` - a debian package that enables matlab >> integration within the system: >> sudo apt install matlab-support > installed > >> 2. In Emacs: install `matlab-mode` package > installed >> 3. Download >> https://github.com/karthink/.emacs.d/blob/master/plugins/ob-octave-fix.el > Installed > >> and put it somewhere in Emacs search path. >> 4. My init.el content with matlab/org-babel configurations: >> ;; >> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >> ;; enabling org-babel >> (org-babel-do-load-languages >> 'org-babel-load-languages '( >> (C . t) ; enable processing C, C++, and D source blocks >> (matlab . t) >> ;;(perl . t) >> (octave . t) >> (org . t) >> (python . t) >> (plantuml . t) >> (shell . t) >> )) >> ;; setup matlab in babel >> (setq org-babel-default-header-args:matlab >> '((:results . "output") (:session . "*MATLAB*"))) >> ;; octave/matlab-fix >> ;;;; (require 'ob-octave-fix nil t) ; This is for older approach >> (require 'ob-octave-fix) > done. > > > Now I executed > > #+begin_src matlab > x = [1, 2, 3, 4, 5]; > fprintf('|%d', x) > #+end_src > > And obtained in a different window: > --8<---------------cut here---------------start------------->8--- > > NameErrorTraceback (most recent call last) > <ipython-input-3-e039b5096438> in <module> > 1 x = [1, 2, 3, 4, 5]; > ----> 2 fprintf('|%d', x) > > NameError: name 'fprintf' is not defined > > --8<---------------cut here---------------end--------------->8--- > > So > > 1. the result is not inserted in my org buffer, > > 2. Morever fprintf is not defined, let me suspect this is not matlab > what is excecuted but octave. Am I right? > > What do I miss here? > > > Uwe Well... 1. After installing matlab-support you should be able to Matlab from bash by typing the command >> matlab Can you do that? a) if yes Can you evoke matlab-shell in Emacs? (M-x matlab-shell) Again, you should be able to do that after installing matlab-mode. b) if no: check what are the values of the variables: `matlab-shell-command` and `matlab-shell-command-switches` In my case they are equal: `matlab` and ("-nodesktop"), respectively, which is by default set in `matlab-shell.el` which is a part of matlab-mode package. Maybe you need to set them explicitely like here: https://swang251.github.io/2021/12/03/Matlab-in-Emacs/ ??? |
From: Uwe B. <ou...@ma...> - 2024-04-22 19:47:53
Attachments:
smime.p7s
|
> On 22.04.2024 14:52, Uwe Brauer wrote: ----> 2 fprintf('|%d', x) > Well... > 1. After installing matlab-support you should be able to Matlab from > bash by typing the command Well, I am on tcsh, but this is not the point. > Can you do that? Yes I can, but mainly because during installation Matlab asks me to set a symbolic link to /usr/local/bin So that is why which matlab Return /usr/local/bin/matlab > a) if yes > Can you evoke matlab-shell in Emacs? (M-x matlab-shell) > Again, you should be able to do that after installing matlab-mode. Of course, I am using the matlab-shell very often, but from a matlab file (.m) What I want to do is, to calculate 1. Matlab commands from an org buffer 2. And insert the result in that buffer. > b) if no: > check what are the values of the variables: > `matlab-shell-command` and `matlab-shell-command-switches` > In my case they are equal: `matlab` and ("-nodesktop"), > respectively, which is by default set in `matlab-shell.el` which is a > part of matlab-mode package. So it is in mine. Again, I use the matlab-shell very often but from .m files. I think I will start emacs -Q and load you configuration+minimal matlab conf and see what happens. I find in strange that in our case fprintf does not work. It works for me in the matlab-shell and using my (complicated) python engine solution Uwe -- I strongly condemn Hamas heinous despicable pogroms/atrocities on Israel I strongly condemn Putin's war of aggression against Ukraine. I support to deliver weapons to Ukraine's military. I support the EU and NATO membership of Ukraine. |