|
From: Julien C. <jul...@mo...> - 2021-05-10 06:58:36
|
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
|