From: Julien C. <jul...@mo...> - 2021-05-07 00:21:15
Attachments:
save-and-go-script-or-fn-from-any-pwd.patch
|
Hi, I'm posting this patch for improving the matlab-shell-save-and-go command. I'm not sure to understand all the different parts/customization of this function but, in my case (by default) I end up at the end of it : where it tries to run the full path file using the matlab "run" command. This works only if the matlab shell is in the current file directory. Moreover, it works only with scripts (no matlab function). Here is my proposition: @@ -2166,2 +2166,4 @@ Similar to `comint-send-input'." - ;; If not changing dir, maybe we need to use 'run' command instead? - (let ((cmd (concat "run('" dir fn-name "')"))) + ;; If not changing dir, maybe we need to use addpath command before + (let ((cmd (concat "addpath('" dir "')"))) + (matlab-shell-send-command cmd)) + (let ((cmd (concat fn-name param))) Instead of using the run matlab function, first, we addpath the file directory and then, we run the file with parameters if any. This way, we can run a script or a function from within any location. I check that addpath at each time do not increase the path uselessly: matlab does nothing if it is already into the path. Regards, *Julien Claisse* |
From: Uwe B. <ou...@ma...> - 2021-05-07 14:46:36
Attachments:
smime.p7s
|
>>> "JCvM" == Julien Claisse via Matlab-emacs-discuss <mat...@li...> writes: Hi Julien > Hi, > I'm posting this patch for improving the matlab-shell-save-and-go command. > I'm not sure to understand all the different parts/customization of this > function but, in my case (by default) I end up at the end of it : where it > tries to run the full path file using the matlab "run" command. > This works only if the matlab shell is in the current file directory. > Moreover, it works only with scripts (no matlab function). I am extremely interested in this patch, because lately I have to use this function quite a bit in different directories. May I ask you to send this patch as an attachment please? Uwe |
From: Julien C. <jul...@mo...> - 2021-05-07 15:12:34
|
Sure, no problem. Happy to help. Le ven. 7 mai 2021 à 16:46, Uwe Brauer <ou...@ma...> a écrit : > >>> "JCvM" == Julien Claisse via Matlab-emacs-discuss < > mat...@li...> writes: > > Hi Julien > > > > Hi, > > I'm posting this patch for improving the matlab-shell-save-and-go > command. > > I'm not sure to understand all the different parts/customization of this > > function but, in my case (by default) I end up at the end of it : where > it > > tries to run the full path file using the matlab "run" command. > > This works only if the matlab shell is in the current file directory. > > Moreover, it works only with scripts (no matlab function). > > I am extremely interested in this patch, because lately I have to use > this function quite a bit in different directories. > > May I ask you to send this patch as an attachment please? > > Uwe > -- Cordialement, Kind regards *Julien Claisse* Software Engineer *Moduleus S.A.S,* 34 rue Pierre et Marie Curie 37100 Tours, France +33 (0)2 47 49 08 16 <+33%202%2047%2049%2008%2016> www.moduleus.com |
From: Uwe B. <ou...@ma...> - 2021-05-08 09:56:44
Attachments:
smime.p7s
|
>>> "JCvM" == Julien Claisse via Matlab-emacs-discuss <mat...@li...> writes: > Hi, > I'm posting this patch for improving the matlab-shell-save-and-go command. > I'm not sure to understand all the different parts/customization of this > function but, in my case (by default) I end up at the end of it : where it > tries to run the full path file using the matlab "run" command. > This works only if the matlab shell is in the current file directory. > Moreover, it works only with scripts (no matlab function). > Here is my proposition: > @@ -2166,2 +2166,4 @@ Similar to `comint-send-input'." > - ;; If not changing dir, maybe we need to use 'run' command instead? > - (let ((cmd (concat "run('" dir fn-name "')"))) > + ;; If not changing dir, maybe we need to use addpath command before > + (let ((cmd (concat "addpath('" dir "')"))) > + (matlab-shell-send-command cmd)) > + (let ((cmd (concat fn-name param))) > Instead of using the run matlab function, first, we addpath the file > directory and then, we run the file with parameters if any. This way, we > can run a script or a function from within any location. > I check that addpath at each time do not increase the path uselessly: > matlab does nothing if it is already into the path. I am currently testing your patch, can you tell me where I can note a difference to the unpatched matlab-shell.el? I run some tests and cannot spot a difference. An example would definitely help Uwe |
From: Julien C. <jul...@mo...> - 2021-05-10 06:58:36
Attachments:
save-and-go-for-functions.patch
|
Hi Uwe, Sorry, this is my fault : this patch does not correct the fact that matlab-shell-save-and-go can work with scripts from anywhere. It only corrects that we can now run functions with 1 or more parameters. Here is an example : 1 - Open matlab-shell 2 - mkdir test-matlab-shell-save-and-go/ 3 - Create a new file test.m under this new directory : function test(p1) disp(['hello ' num2str(p1) '!']) 4 - Do a matlab-shell-save-and-go from this file. 5 - Enter (5) in the minibuffer prompt and press enter 6 - Without the patch you get one error: >> run('/home/jc/test-matlab-shell-save-and-go/test') Not enough input arguments. Error in test (line 2) disp(['hello ' num2str(p1) '!']) Error in run (line 91) evalin('caller', strcat(script, ';')); 7 - Apply the patch, and do the same. It works : >> addpath('/home/jc/test-matlab-shell-save-and-go/') >> test(5) hello 5! Next time, I will provide an example immediately. I wrote this patch some time ago (it was residing into my init.el file) and I was remembering wrong. I put again the patch in attachment with a correct name. Let me know if you note the difference. Regards, Julien Le sam. 8 mai 2021 à 11:56, Uwe Brauer <ou...@ma...> a écrit : > >>> "JCvM" == Julien Claisse via Matlab-emacs-discuss < > mat...@li...> writes: > > > Hi, > > I'm posting this patch for improving the matlab-shell-save-and-go > command. > > I'm not sure to understand all the different parts/customization of this > > function but, in my case (by default) I end up at the end of it : where > it > > tries to run the full path file using the matlab "run" command. > > This works only if the matlab shell is in the current file directory. > > Moreover, it works only with scripts (no matlab function). > > Here is my proposition: > > @@ -2166,2 +2166,4 @@ Similar to `comint-send-input'." > > - ;; If not changing dir, maybe we need to use 'run' command instead? > > - (let ((cmd (concat "run('" dir fn-name "')"))) > > + ;; If not changing dir, maybe we need to use addpath command before > > + (let ((cmd (concat "addpath('" dir "')"))) > > + (matlab-shell-send-command cmd)) > > + (let ((cmd (concat fn-name param))) > > > Instead of using the run matlab function, first, we addpath the file > > directory and then, we run the file with parameters if any. This way, we > > can run a script or a function from within any location. > > I check that addpath at each time do not increase the path uselessly: > > matlab does nothing if it is already into the path. > > I am currently testing your patch, can you tell me where I can note a > difference to the unpatched matlab-shell.el? > > I run some tests and cannot spot a difference. An example would > definitely help > > Uwe > -- Cordialement, Kind regards *Julien Claisse* Software Engineer *Moduleus S.A.S,* 34 rue Pierre et Marie Curie 37100 Tours, France +33 (0)2 47 49 08 16 <+33%202%2047%2049%2008%2016> www.moduleus.com |
From: Uwe B. <ou...@ma...> - 2021-07-20 16:55:05
Attachments:
smime.p7s
|
>>> "JC" == Julien Claisse <jul...@mo...> writes: Hi Julien > Hi Uwe, > Sorry, this is my fault : this patch does not correct the fact that > matlab-shell-save-and-go can work with scripts from anywhere. It only > corrects that we can now run functions with 1 or more parameters. I am terrible sorry for the delay, but until now I was very busy. So the first thing after my courses finished was to merge the hairybranch written by Eric into master. Now concerning your example I can reproduce it, but it maybe because I used the merged version. > Here is an example : > 1 - Open matlab-shell > 2 - mkdir test-matlab-shell-save-and-go/ > 3 - Create a new file test.m under this new directory : > function test(p1) > disp(['hello ' num2str(p1) '!']) > 4 - Do a matlab-shell-save-and-go from this file. When I do this I see in the minibuffer what you described in 7!!! > 5 - Enter (5) in the minibuffer prompt and press enter > 6 - Without the patch you get one error: >>> run('/home/jc/test-matlab-shell-save-and-go/test') > Not enough input arguments. > Error in test (line 2) > disp(['hello ' num2str(p1) '!']) > Error in run (line 91) > evalin('caller', strcat(script, ';')); > 7 - Apply the patch, and do the same. It works : >>> addpath('/home/jc/test-matlab-shell-save-and-go/') >>> test(5) > hello 5! This is what I see. I don't recall having applied your patch, I searched the changelog and can't see anything. I also looked at your patch ,---- | | + (let ((cmd (concat "addpath('" dir "')"))) | + (matlab-shell-send-command cmd)) | + (let ((cmd (concat fn-name param))) | (matlab-shell-send-command cmd))) `---- are not applied. So may I ask you to pull the latest master and see whether you still run into a problem? Thanks and regards Uwe |