From: Jonathan S. <jon...@gm...> - 2020-11-18 15:03:53
|
I've been working with matlab-mode and matlab-shell for the last few days, and I'm really digging it so far. The only two things I can't get to work properly are completion - neither in shell, nor in .m files - and jumping to function definitions, and I would really appreciate some help with these. when I hit TAB in shell, my text turns into >> emacsdocomplete('EEG.(cond') and when I hit RETURN I get (the appropriate): emacs_completions_output = java.lang.String[]: 'cond' 'condeig' but it's not integrated into the shell properly, i.e. I can't choose which of the above I want, I have to re-type the command along with the chosen completion. In .m files I just get nothing except for the word completion for words already in the buffer - which I've configured myself. I've read somewhere that the completion is meant to be related to CEDET somehow but I couldn't make out much more (I'm working on Doom Emacs, and I seen to have CEDET installed, and can run matlab-cedet-setup, which does nothing as far as I can tell). As to function definitions - I don't even know where to start.. I've read that ctags now supports matlab, but I don't know where (if) the actual .m files for the built-in functions reside in the install dir. Ideally I'd love to be able to stand on a function name and be able to get the "help funcName" output in another buffer or something (this works from the shell). Thanks a lot! |
From: Eric L. <eri...@gm...> - 2020-11-25 16:03:32
|
Hi Jonathan, As new version of MATLAB come out, the text that comes out for errors, completions, and all sorts of things change which can break the shell. What version of MATLAB are you using, and which version of the matlab mode code are you using? We made a bunch of updates last winter to ML shell which you can get from the git repository: https://sourceforge.net/p/matlab-emacs/src/ci/master/tree/ There are also a few extra fixes on the 'usage1' branch which haven't been merged into the main branch yet. That all said, I don't recall big changes needed for completion lately. :( Eric On 11/18/20 10:03 AM, Jonathan Sahar wrote: > > I've been working with matlab-mode and matlab-shell for the last few > days, and I'm really digging it so far. The only two things I can't > get to work properly are completion - neither in shell, nor in .m > files - and jumping to function definitions, and I would really > appreciate some help with these. when I hit TAB in shell, my text > turns into > > |>> emacsdocomplete('EEG.(cond') | > > and when I hit RETURN I get (the appropriate): > > |emacs_completions_output = java.lang.String[]: 'cond' 'condeig' | > > but it's not integrated into the shell properly, i.e. I can't choose > which of the above I want, I have to re-type the command along with > the chosen completion. In .m files I just get nothing except for the > word completion for words already in the buffer - which I've > configured myself. > > I've read somewhere that the completion is meant to be related to > CEDET somehow but I couldn't make out much more (I'm working on Doom > Emacs, and I seen to have CEDET installed, and can run > matlab-cedet-setup, which does nothing as far as I can tell). > > As to function definitions - I don't even know where to start.. I've > read that ctags now supports matlab, but I don't know where (if) the > actual .m files for the built-in functions reside in the install dir. > > Ideally I'd love to be able to stand on a function name and be able to > get the "help funcName" output in another buffer or something (this > works from the shell). > > Thanks a lot! > |
From: Jonathan S. <jon...@gm...> - 2020-11-25 16:42:14
|
Hi Eric, thanks for your reply! I'm running version '9.4.0.949201 (R2018a) Update 6'. I've installed matlab-mode through Doom emacs' (package! ...) directive, but I've looked at the changelog locally and on sourceforge, and the latest commit is the same one... Best, Jonathan On Wed, 25 Nov 2020 at 18:03, Eric Ludlam <eri...@gm...> wrote: > Hi Jonathan, > > As new version of MATLAB come out, the text that comes out for errors, > completions, and all sorts of things change which can break the shell. > > What version of MATLAB are you using, and which version of the matlab > mode code are you using? > > We made a bunch of updates last winter to ML shell which you can get > from the git repository: > > https://sourceforge.net/p/matlab-emacs/src/ci/master/tree/ > > There are also a few extra fixes on the 'usage1' branch which haven't > been merged into the main branch yet. > > That all said, I don't recall big changes needed for completion lately. :( > > Eric > > > On 11/18/20 10:03 AM, Jonathan Sahar wrote: > > > > I've been working with matlab-mode and matlab-shell for the last few > > days, and I'm really digging it so far. The only two things I can't > > get to work properly are completion - neither in shell, nor in .m > > files - and jumping to function definitions, and I would really > > appreciate some help with these. when I hit TAB in shell, my text > > turns into > > > > |>> emacsdocomplete('EEG.(cond') | > > > > and when I hit RETURN I get (the appropriate): > > > > |emacs_completions_output = java.lang.String[]: 'cond' 'condeig' | > > > > but it's not integrated into the shell properly, i.e. I can't choose > > which of the above I want, I have to re-type the command along with > > the chosen completion. In .m files I just get nothing except for the > > word completion for words already in the buffer - which I've > > configured myself. > > > > I've read somewhere that the completion is meant to be related to > > CEDET somehow but I couldn't make out much more (I'm working on Doom > > Emacs, and I seen to have CEDET installed, and can run > > matlab-cedet-setup, which does nothing as far as I can tell). > > > > As to function definitions - I don't even know where to start.. I've > > read that ctags now supports matlab, but I don't know where (if) the > > actual .m files for the built-in functions reside in the install dir. > > > > Ideally I'd love to be able to stand on a function name and be able to > > get the "help funcName" output in another buffer or something (this > > works from the shell). > > > > Thanks a lot! > > > > |
From: Eric L. <eri...@gm...> - 2020-11-26 17:01:48
Attachments:
matlab-complete.el.patch
|
Hi Jonathan, I happened to have MATLAB 18a installed and was able to test using matlab.el, and matlab-shell.el from git, but could not replicate a completion problem. Sorry. Is it special to the "EEG" data structure, or does this occur everywhere? You had some other questions too. Matlab mode does support CEDET, but you do not need to use CEDET in order to use matlab mode. MATLAB mode without support packages supports a bunch of different completion features, but most are pretty simple. If you enable CEDET with the data base and have matlab-shell running, it will try to use the shell to find files on your path, but it doesn't use the shell for completions. That code is pretty old and I don't think those bits were every plugged together. I did a little hacking and put together the attached patch that enables completion via MATLAB shell in MATLAB buffers. It is rather primitive as it only does global symbols and knows nothing about the local context, but perhaps it can serve as inspiration for putting something more complete together. Lastly, in a MATLAB buffer, you can type: M-x matlab-shell-describe-command RET on a symbol and it should do vaguely what you were asking for below. Eric On 11/25/20 11:41 AM, Jonathan Sahar wrote: > Hi Eric, thanks for your reply! > > I'm running version '9.4.0.949201 (R2018a) Update 6'. > I've installed matlab-mode through Doom emacs' (package! ...) > directive, but I've looked at the changelog locally and on > sourceforge, and the latest commit is the same one... > > Best, > Jonathan > > > > > On Wed, 25 Nov 2020 at 18:03, Eric Ludlam <eri...@gm... > <mailto:eri...@gm...>> wrote: > > Hi Jonathan, > > As new version of MATLAB come out, the text that comes out for > errors, > completions, and all sorts of things change which can break the shell. > > What version of MATLAB are you using, and which version of the matlab > mode code are you using? > > We made a bunch of updates last winter to ML shell which you can get > from the git repository: > > https://sourceforge.net/p/matlab-emacs/src/ci/master/tree/ > > There are also a few extra fixes on the 'usage1' branch which haven't > been merged into the main branch yet. > > That all said, I don't recall big changes needed for completion > lately. :( > > Eric > > > On 11/18/20 10:03 AM, Jonathan Sahar wrote: > > > > I've been working with matlab-mode and matlab-shell for the last > few > > days, and I'm really digging it so far. The only two things I can't > > get to work properly are completion - neither in shell, nor in .m > > files - and jumping to function definitions, and I would really > > appreciate some help with these. when I hit TAB in shell, my text > > turns into > > > > |>> emacsdocomplete('EEG.(cond') | > > > > and when I hit RETURN I get (the appropriate): > > > > |emacs_completions_output = java.lang.String[]: 'cond' 'condeig' | > > > > but it's not integrated into the shell properly, i.e. I can't > choose > > which of the above I want, I have to re-type the command along with > > the chosen completion. In .m files I just get nothing except for > the > > word completion for words already in the buffer - which I've > > configured myself. > > > > I've read somewhere that the completion is meant to be related to > > CEDET somehow but I couldn't make out much more (I'm working on > Doom > > Emacs, and I seen to have CEDET installed, and can run > > matlab-cedet-setup, which does nothing as far as I can tell). > > > > As to function definitions - I don't even know where to start.. > I've > > read that ctags now supports matlab, but I don't know where (if) > the > > actual .m files for the built-in functions reside in the install > dir. > > > > Ideally I'd love to be able to stand on a function name and be > able to > > get the "help funcName" output in another buffer or something (this > > works from the shell). > > > > Thanks a lot! > > > |
From: Jonathan S. <jon...@gm...> - 2020-11-27 05:45:03
|
Hi Eric, Thanks so much for taking the time to test it! It's not unique to that sturct. Is there anything that I need/can configure on terms of the completion engine? I'm using company for most other things, maybe there's some conflict, or some missing configuration? Thank you for the patch! I'll try it out, and I'll using Matlab mode from the git source as well. Do you have a pointers for setting up jump-to-function functionally? Thanks again for all the help and information, it's really appreciated. Jonathan On Thu, 26 Nov 2020, 19:01 Eric Ludlam, <eri...@gm...> wrote: > Hi Jonathan, > > I happened to have MATLAB 18a installed and was able to test using > matlab.el, and matlab-shell.el from git, but could not replicate a > completion problem. Sorry. Is it special to the "EEG" data structure, > or does this occur everywhere? > > You had some other questions too. > > Matlab mode does support CEDET, but you do not need to use CEDET in > order to use matlab mode. MATLAB mode without support packages supports > a bunch of different completion features, but most are pretty simple. > If you enable CEDET with the data base and have matlab-shell running, it > will try to use the shell to find files on your path, but it doesn't use > the shell for completions. That code is pretty old and I don't think > those bits were every plugged together. > > I did a little hacking and put together the attached patch that enables > completion via MATLAB shell in MATLAB buffers. It is rather primitive > as it only does global symbols and knows nothing about the local > context, but perhaps it can serve as inspiration for putting something > more complete together. > > Lastly, in a MATLAB buffer, you can type: > > M-x matlab-shell-describe-command RET > > on a symbol and it should do vaguely what you were asking for below. > > Eric > > On 11/25/20 11:41 AM, Jonathan Sahar wrote: > > Hi Eric, thanks for your reply! > > > > I'm running version '9.4.0.949201 (R2018a) Update 6'. > > I've installed matlab-mode through Doom emacs' (package! ...) > > directive, but I've looked at the changelog locally and on > > sourceforge, and the latest commit is the same one... > > > > Best, > > Jonathan > > > > > > > > > > On Wed, 25 Nov 2020 at 18:03, Eric Ludlam <eri...@gm... > > <mailto:eri...@gm...>> wrote: > > > > Hi Jonathan, > > > > As new version of MATLAB come out, the text that comes out for > > errors, > > completions, and all sorts of things change which can break the > shell. > > > > What version of MATLAB are you using, and which version of the matlab > > mode code are you using? > > > > We made a bunch of updates last winter to ML shell which you can get > > from the git repository: > > > > https://sourceforge.net/p/matlab-emacs/src/ci/master/tree/ > > > > There are also a few extra fixes on the 'usage1' branch which haven't > > been merged into the main branch yet. > > > > That all said, I don't recall big changes needed for completion > > lately. :( > > > > Eric > > > > > > On 11/18/20 10:03 AM, Jonathan Sahar wrote: > > > > > > I've been working with matlab-mode and matlab-shell for the last > > few > > > days, and I'm really digging it so far. The only two things I can't > > > get to work properly are completion - neither in shell, nor in .m > > > files - and jumping to function definitions, and I would really > > > appreciate some help with these. when I hit TAB in shell, my text > > > turns into > > > > > > |>> emacsdocomplete('EEG.(cond') | > > > > > > and when I hit RETURN I get (the appropriate): > > > > > > |emacs_completions_output = java.lang.String[]: 'cond' 'condeig' | > > > > > > but it's not integrated into the shell properly, i.e. I can't > > choose > > > which of the above I want, I have to re-type the command along with > > > the chosen completion. In .m files I just get nothing except for > > the > > > word completion for words already in the buffer - which I've > > > configured myself. > > > > > > I've read somewhere that the completion is meant to be related to > > > CEDET somehow but I couldn't make out much more (I'm working on > > Doom > > > Emacs, and I seen to have CEDET installed, and can run > > > matlab-cedet-setup, which does nothing as far as I can tell). > > > > > > As to function definitions - I don't even know where to start.. > > I've > > > read that ctags now supports matlab, but I don't know where (if) > > the > > > actual .m files for the built-in functions reside in the install > > dir. > > > > > > Ideally I'd love to be able to stand on a function name and be > > able to > > > get the "help funcName" output in another buffer or something (this > > > works from the shell). > > > > > > Thanks a lot! > > > > > > > |
From: Eric L. <eri...@gm...> - 2020-11-28 20:08:51
|
Hi, The existing matlab completion stuff should work with company .. or at least there is code in there referencing company completion engine. I was never a fan so I don't use that particular package. In the MATLAB menu, you will find a "Locate MATLAB function" option which is similar to jump-to functionality like etags. Newer emacsen now how 'xref' as a bit of infrastructure and keybinding but matlab mode doesn't plug into it yet. In theory matlab mode could hook matlab-shell-locate-fcn into xref but I haven't researched how to do that yet. Eric On 11/27/20 12:44 AM, Jonathan Sahar wrote: > Hi Eric, > > Thanks so much for taking the time to test it! > It's not unique to that sturct. > Is there anything that I need/can configure on terms of the completion > engine? I'm using company for most other things, maybe there's some > conflict, or some missing configuration? > > Thank you for the patch! I'll try it out, and I'll using Matlab mode > from the git source as well. > > Do you have a pointers for setting up jump-to-function functionally? > > Thanks again for all the help and information, it's really appreciated. > > Jonathan > > On Thu, 26 Nov 2020, 19:01 Eric Ludlam, <eri...@gm... > <mailto:eri...@gm...>> wrote: > > Hi Jonathan, > > I happened to have MATLAB 18a installed and was able to test using > matlab.el, and matlab-shell.el from git, but could not replicate a > completion problem. Sorry. Is it special to the "EEG" data > structure, > or does this occur everywhere? > > You had some other questions too. > > Matlab mode does support CEDET, but you do not need to use CEDET in > order to use matlab mode. MATLAB mode without support packages > supports > a bunch of different completion features, but most are pretty > simple. > If you enable CEDET with the data base and have matlab-shell > running, it > will try to use the shell to find files on your path, but it > doesn't use > the shell for completions. That code is pretty old and I don't think > those bits were every plugged together. > > I did a little hacking and put together the attached patch that > enables > completion via MATLAB shell in MATLAB buffers. It is rather > primitive > as it only does global symbols and knows nothing about the local > context, but perhaps it can serve as inspiration for putting > something > more complete together. > > Lastly, in a MATLAB buffer, you can type: > > M-x matlab-shell-describe-command RET > > on a symbol and it should do vaguely what you were asking for below. > > Eric > > On 11/25/20 11:41 AM, Jonathan Sahar wrote: > > Hi Eric, thanks for your reply! > > > > I'm running version '9.4.0.949201 (R2018a) Update 6'. > > I've installed matlab-mode through Doom emacs' (package! ...) > > directive, but I've looked at the changelog locally and on > > sourceforge, and the latest commit is the same one... > > > > Best, > > Jonathan > > > > > > > > > > On Wed, 25 Nov 2020 at 18:03, Eric Ludlam <eri...@gm... > <mailto:eri...@gm...> > > <mailto:eri...@gm... <mailto:eri...@gm...>>> wrote: > > > > Hi Jonathan, > > > > As new version of MATLAB come out, the text that comes out for > > errors, > > completions, and all sorts of things change which can break > the shell. > > > > What version of MATLAB are you using, and which version of > the matlab > > mode code are you using? > > > > We made a bunch of updates last winter to ML shell which you > can get > > from the git repository: > > > > https://sourceforge.net/p/matlab-emacs/src/ci/master/tree/ > > > > There are also a few extra fixes on the 'usage1' branch > which haven't > > been merged into the main branch yet. > > > > That all said, I don't recall big changes needed for completion > > lately. :( > > > > Eric > > > > > > On 11/18/20 10:03 AM, Jonathan Sahar wrote: > > > > > > I've been working with matlab-mode and matlab-shell for > the last > > few > > > days, and I'm really digging it so far. The only two > things I can't > > > get to work properly are completion - neither in shell, > nor in .m > > > files - and jumping to function definitions, and I would > really > > > appreciate some help with these. when I hit TAB in shell, > my text > > > turns into > > > > > > |>> emacsdocomplete('EEG.(cond') | > > > > > > and when I hit RETURN I get (the appropriate): > > > > > > |emacs_completions_output = java.lang.String[]: 'cond' > 'condeig' | > > > > > > but it's not integrated into the shell properly, i.e. I can't > > choose > > > which of the above I want, I have to re-type the command > along with > > > the chosen completion. In .m files I just get nothing > except for > > the > > > word completion for words already in the buffer - which I've > > > configured myself. > > > > > > I've read somewhere that the completion is meant to be > related to > > > CEDET somehow but I couldn't make out much more (I'm > working on > > Doom > > > Emacs, and I seen to have CEDET installed, and can run > > > matlab-cedet-setup, which does nothing as far as I can tell). > > > > > > As to function definitions - I don't even know where to > start.. > > I've > > > read that ctags now supports matlab, but I don't know > where (if) > > the > > > actual .m files for the built-in functions reside in the > install > > dir. > > > > > > Ideally I'd love to be able to stand on a function name and be > > able to > > > get the "help funcName" output in another buffer or > something (this > > > works from the shell). > > > > > > Thanks a lot! > > > > > > |
From: Karthik C. <kar...@gm...> - 2020-11-29 07:56:13
Attachments:
matlab-shell-xref.patch
|
Hi Jonathan and Eric, Jon, to get help on the function at point you can do something like this: (defun matlab-shell-help-at-point () (interactive) (let ((fcn (matlab-read-word-at-point))) (if (and fcn (not (equal fcn ""))) (matlab-shell-describe-command fcn)))) (define-key matlab-mode-map (kbd "C-h .") #'matlab-shell-help-at-point) Matlab-mode works with company out of the box for me. Can you describe the error(s) you are getting? For jump-to-function you have two options (three including Eric's suggestion): 1. Install dumb-jump from MELPA. Then hitting 'M-.' on a function name should take you to the definition. Note that this only works for functions that are defined in m files in the same directory or project. 2. Patch matlab-shell.el with the attached patch, then put (add-hook 'xref-backend-functions #'matlab-shell-xref-activate) In your init file somewhere. This should enable xref support for Matlab shell. This should work for all functions that MATLAB shell knows about, including built-in ones. Eric, I'm working on better completion in matlab-mode buffers using matlab-shell with your patch as a starting point. I should have something decent in a few days. Could you take a look at the xref integration? I tested it on matlab built-ins, user functions and variables, and tried to make sure it failed gracefully when it couldn't find a definition. More testing is probably required. Thanks, Karthik |
From: Karthik C. <kar...@gm...> - 2020-11-29 08:31:29
Attachments:
matlab-shell-xref.patch
|
Hi, Please ignore the patch in my previous email, it failed on some edge cases. This one should work better and only use matlab-shell for jumping to definitions when xref is invoked from matlab-mode or matlab-shell-mode. Karthik |
From: Uwe B. <ou...@ma...> - 2020-11-29 10:22:45
Attachments:
smime.p7s
|
>>> "KC" == Karthik Chikmagalur <kar...@gm...> writes: Hello > Hi, > Please ignore the patch in my previous email, it failed on some edge > cases. This one should work better and only use matlab-shell for > jumping to definitions when xref is invoked from matlab-mode or > matlab-shell-mode. Sorry for jumping into the discussion only by now. What is the state of art of these patches. Shall I apply them to sourceforge/github? I had no time to test them myself I shall try to do that in the afternoon. BTW, there is another subject that I wanted to discuss, it concerns ELPA/MELPA. I shall open another thread for this. Regards Uwe |
From: Eric L. <eri...@gm...> - 2020-11-29 14:27:31
|
Hi Uwe, There are a bunch of old misc fixes over in the usage1 branch that we should probably merge into master. The save-and-go work I was doing never became as robust as I wanted, but it should be transparent if no one tries to activate the feature. It also includes my patch for completion I posted yesterday. Doing the merge will let us retire usage1. We can start a new branch for some of this completion and xref work that has come up on the mailing list. Eric On 11/29/20 3:45 AM, Uwe Brauer wrote: >>>> "KC" == Karthik Chikmagalur <kar...@gm...> writes: > Hello > > >> Hi, >> Please ignore the patch in my previous email, it failed on some edge >> cases. This one should work better and only use matlab-shell for >> jumping to definitions when xref is invoked from matlab-mode or >> matlab-shell-mode. > Sorry for jumping into the discussion only by now. What is the state of > art of these patches. Shall I apply them to sourceforge/github? > > I had no time to test them myself I shall try to do that in the > afternoon. > > BTW, there is another subject that I wanted to discuss, it concerns > ELPA/MELPA. I shall open another thread for this. > > Regards > > Uwe |
From: Uwe B. <ou...@ma...> - 2020-11-29 15:24:54
Attachments:
smime.p7s
|
>>> "EL" == Eric Ludlam <eri...@gm...> writes: Hi Eric, > Hi Uwe, > There are a bunch of old misc fixes over in the usage1 branch that we > should probably merge into master. The save-and-go work I was doing > never became as robust as I wanted, but it should be transparent if no > one tries to activate the feature. It also includes my patch for > completion I posted yesterday. > Doing the merge will let us retire usage1. Ok so I merge the usage1 branch into the master branch? This has nothing to do with the patches that were discussed in the last days. I try to do that as soon as possible Uwe |
From: Uwe B. <ou...@ma...> - 2020-11-29 15:45:53
Attachments:
smime.p7s
|
>>> "EL" == Eric Ludlam <eri...@gm...> writes: > Hi Uwe, > There are a bunch of old misc fixes over in the usage1 branch that we > should probably merge into master. The save-and-go work I was doing > never became as robust as I wanted, but it should be transparent if no > one tries to activate the feature. It also includes my patch for > completion I posted yesterday. > Doing the merge will let us retire usage1. The last commit on that branch seems to be c22998376b623f79b196cc30273d1ae5c8218e16 which is of today. I merge that one into master, ok? |
From: Eric L. <eri...@gm...> - 2020-11-29 23:25:13
|
On 11/29/20 10:45 AM, Uwe Brauer wrote: >>>> "EL" == Eric Ludlam <eri...@gm...> writes: >> Hi Uwe, >> There are a bunch of old misc fixes over in the usage1 branch that we >> should probably merge into master. The save-and-go work I was doing >> never became as robust as I wanted, but it should be transparent if no >> one tries to activate the feature. It also includes my patch for >> completion I posted yesterday. >> Doing the merge will let us retire usage1. > > The last commit on that branch seems to be > c22998376b623f79b196cc30273d1ae5c8218e16 > which is of today. > I merge that one into master, ok? > Yes, I put in some patches from John into usage1 that fixes some hangs, and also a first cut at a piece of the completion using the shell patch I posted a bit earlier. We've been using a majority of those patches deployed at MW for a while, so they should be good to go. If the completion bit seems too risky, feel free to leave it out. Thanks, Eric |
From: Uwe B. <ou...@ma...> - 2020-11-30 07:53:49
Attachments:
smime.p7s
|
>>> "EL" == Eric Ludlam <eri...@gm...> writes: > On 11/29/20 10:45 AM, Uwe Brauer wrote: >>>>> "EL" == Eric Ludlam <eri...@gm...> writes: >>> Hi Uwe, >>> There are a bunch of old misc fixes over in the usage1 branch that we >>> should probably merge into master. The save-and-go work I was doing >>> never became as robust as I wanted, but it should be transparent if no >>> one tries to activate the feature. It also includes my patch for >>> completion I posted yesterday. >>> Doing the merge will let us retire usage1. >> >> The last commit on that branch seems to be >> c22998376b623f79b196cc30273d1ae5c8218e16 >> which is of today. >> I merge that one into master, ok? >> > Yes, I put in some patches from John into usage1 that fixes some > hangs, and also a first cut at a piece of the completion using the > shell patch I posted a bit earlier. > We've been using a majority of those patches deployed at MW for a > while, so they should be good to go. If the completion bit seems too > risky, feel free to leave it out. I compiled, is it ok to test it for one day before pushing? Is there anything specific I should test? Sorry I did not pay too much attention to the completion issue as I should have. Uwe |
From: John C. <ci...@ma...> - 2020-11-30 14:00:28
|
Hi Uwe, Some items to test: * The handling of *.m files. matlab.el used to contain: (add-to-list 'auto-mode-alist '("\\.m$" . matlab-mode)) which overrides the Emacs default of associating *.m files with objc-mode. This setting means it isn't possible to edit in objc-mode for *.m objective-c files and matlab-mode for *.m matlab files in the same session. I switched it to use (add-to-list 'magic-mode-alist '(matlab-is-matlab-file . matlab-mode)) this way Linux distributions can setup Emacs such that it will work correctly when the content of a *.m file is matlab and in the same emacs session when the content of a *.m is objective-c. After deploying the latest updates to matlab-mode, I wonder if you could ping the Linux distributions, e.g. Debian to make the above change? * The tab completion capability in *.m files when matlab-shell is running * Improved block comments %{ %} * Handling of events and arguments keyword "blocks" * When leaving matlab-mode, mlint is turned off, e.g. change a file in matlab-mode to text-mode (not common). * Most of the other changes are bug fixes, e.g. comment fill, hanlding of "..." at EOF, mlint handling when mlint path is invalid, etc. Thanks John ________________________________ From: Uwe Brauer <ou...@ma...> Sent: Monday, November 30, 2020 2:53 AM To: Eric Ludlam <eri...@gm...> Cc: mat...@li... <mat...@li...> Subject: Re: [Matlab-emacs-discuss] completion and goto-function in matlab-mode (Doom emacs) >>> "EL" == Eric Ludlam <eri...@gm...> writes: > On 11/29/20 10:45 AM, Uwe Brauer wrote: >>>>> "EL" == Eric Ludlam <eri...@gm...> writes: >>> Hi Uwe, >>> There are a bunch of old misc fixes over in the usage1 branch that we >>> should probably merge into master. The save-and-go work I was doing >>> never became as robust as I wanted, but it should be transparent if no >>> one tries to activate the feature. It also includes my patch for >>> completion I posted yesterday. >>> Doing the merge will let us retire usage1. >> >> The last commit on that branch seems to be >> c22998376b623f79b196cc30273d1ae5c8218e16 >> which is of today. >> I merge that one into master, ok? >> > Yes, I put in some patches from John into usage1 that fixes some > hangs, and also a first cut at a piece of the completion using the > shell patch I posted a bit earlier. > We've been using a majority of those patches deployed at MW for a > while, so they should be good to go. If the completion bit seems too > risky, feel free to leave it out. I compiled, is it ok to test it for one day before pushing? Is there anything specific I should test? Sorry I did not pay too much attention to the completion issue as I should have. Uwe |
From: Eric L. <eri...@gm...> - 2020-11-30 19:17:57
|
On 11/30/20 2:53 AM, Uwe Brauer wrote: >> We've been using a majority of those patches deployed at MW for a >> while, so they should be good to go. If the completion bit seems too >> risky, feel free to leave it out. > I compiled, is it ok to test it for one day before pushing? > > Is there anything specific I should test? Sorry I did not pay too much > attention to the completion issue as I should have. John found a bug in the M-TAB behavior when matlab-shell hasn't been loaded into Emacs yet. I pushed a tiny fix for that. I am not in a big rush on when the merge happens. John has a few interesting changes on that branch and I see he sent a list of things to try. I added tests in the test directory for most of my changes, so if the build in the tests directory works, all should be good on my end. Eric |
From: Uwe B. <ou...@ma...> - 2020-11-30 16:29:46
Attachments:
smime.p7s
|
>>> "JC" == John Ciolfi <ci...@ma...> writes: Hi John > Hi Uwe, > Some items to test: > * The handling of *.m files. matlab.el used to contain: > (add-to-list 'auto-mode-alist '("\\.m$" . matlab-mode)) > which overrides the Emacs default of associating *.m files with > objc-mode. This setting means it isn't possible to edit in objc-mode > for *.m objective-c files and matlab-mode for *.m matlab files in the > same session. Ah right I vaguely remember this, but forgot all about it. > I switched it to use > (add-to-list 'magic-mode-alist '(matlab-is-matlab-file . matlab-mode)) > this way Linux distributions can setup Emacs such that it will work > correctly when the content of a *.m file is matlab and in the same > emacs session when the content of a *.m is objective-c. > After deploying the latest updates to matlab-mode, I wonder if you > could ping the Linux distributions, e.g. Debian to make the above > change? I am not sure I understand, (I am on Ubuntu, which for most cases follows Debian). Do you want me to contact precisely whom? The person responsible for the emacs deb pkg? Or the package emacs-goodies-el? Frankely with respect to (X)Emacs debian was a mess and I am not sure that it has improved very much, they tend to have a deb package for a lot of emacs lisp package but almost all of them were hopelessly outdated. That is why I think the (X)emacs package is such a great achievement. Because it is relatively recent, which reminds me once I push, I should take of the MELPA package too. So you please tell me what you have in mind. > * The tab completion capability in *.m files when matlab-shell is running Well not for me. That it is interesting. ,---- | TAB (translated from <tab>) runs the command indent-for-tab-command | (found in global-map), which is an interactive compiled Lisp function | in ‘indent.el’. `---- I have local matlab binding but not for tab, instead I have (local-set-key [(super tab)] 'indent-for-tab-command)) I would like to investigate that a bit further for me ,---- | C-M-i runs the command matlab-complete-symbol (found in | matlab-mode-map), which is an interactive Lisp function in | ‘matlab-complete.el’. | `---- But that function is a bit of an disappointment, yes f-->for but for example ode4 does not give you ode45 While in the matlab-shell tab works reasonably well. I'd like to understand that mechanism a bit better. > * Improved block comments %{ %} > * Handling of events and arguments keyword "blocks" > * When leaving matlab-mode, mlint is turned off, e.g. change a file in matlab-mode to text-mode (not common). > * Most of the other changes are bug fixes, e.g. comment fill, hanlding of "..." at EOF, mlint handling when mlint path is invalid, etc. Ok. Regards Uwe |
From: Eric L. <eri...@gm...> - 2020-12-22 02:52:50
|
Hi Karthik, I finally had a moment to look at this. Sorry for the delay. The way xref works is unfamiliar to me, as I haven't used some of the techniques it depends on, so I have questions but don't feel like I can provide any useful feedback. I did look at the elisp backend which it advertised as the prime example. That one is quite large compared to your patch. Do you think the below would expand out to be much larger? I'm considering if xref support would move into it's own file or not. I also note that the elisp version doesn't use require for xref, and your patch depends on the feature existing when the code loads. I think it does so via: (declare-function xref-make "xref" (summary location)) Will that work here too? In other news I pushed a 'shellcomplete' branch that has a `completion-at-point' version of matlab completion, which should enable a range of tools to work with MATLAB now. I ended up mixing the shell completion with bits of the old local completion to get something pretty good. Thanks Eric On 11/29/20 3:31 AM, Karthik Chikmagalur wrote: > Hi, > > Please ignore the patch in my previous email, it failed on some edge cases. This one should work better and only use matlab-shell for jumping to definitions when xref is invoked from matlab-mode or matlab-shell-mode. > > Karthik > > > > > Karthik Chikmagalur <kar...@gm...> writes: > >> Hi Jonathan and Eric, >> >> Jon, to get help on the function at point you can do something like this: >> >> (defun matlab-shell-help-at-point () >> (interactive) >> (let ((fcn (matlab-read-word-at-point))) >> (if (and fcn (not (equal fcn ""))) >> (matlab-shell-describe-command fcn)))) >> (define-key matlab-mode-map (kbd "C-h .") #'matlab-shell-help-at-point) >> >> Matlab-mode works with company out of the box for me. Can you describe the error(s) you are getting? >> >> For jump-to-function you have two options (three including Eric's suggestion): >> >> 1. Install dumb-jump from MELPA. Then hitting 'M-.' on a function name should take you to the definition. Note that this only works for functions that are defined in m files in the same directory or project. >> >> 2. Patch matlab-shell.el with the attached patch, then put >> >> (add-hook 'xref-backend-functions #'matlab-shell-xref-activate) >> >> In your init file somewhere. This should enable xref support for Matlab shell. This should work for all functions that MATLAB shell knows about, including built-in ones. >> >> Eric, I'm working on better completion in matlab-mode buffers using matlab-shell with your patch as a starting point. I should have something decent in a few days. Could you take a look at the xref integration? I tested it on matlab built-ins, user functions and variables, and tried to make sure it failed gracefully when it couldn't find a definition. More testing is probably required. >> >> Thanks, >> Karthik >> >> diff -u /home/karthik/.local/share/git/matlab-emacs-src/matlab-shell.el /home/karthik/.local/share/git/matlab-emacs-src/matlab-shell-new.el >> --- /home/karthik/.local/share/git/matlab-emacs-src/matlab-shell.el 2020-11-28 23:04:08.875674271 -0800 >> +++ /home/karthik/.local/share/git/matlab-emacs-src/matlab-shell-new.el 2020-11-28 23:44:32.755934812 -0800 >> @@ -1536,6 +1536,33 @@ >> (substring output 0 (match-beginning 0))))))) >> >> >> +;;; MATLAB Shell integration with xref ======================================== >> +(when (featurep 'xref) >> + (cl-defmethod xref-backend-identifier-at-point ((_backend (eql matlab-shell))) >> + (let ((ident (matlab-read-word-at-point))) >> + (and (not (equal ident "")) ident))) >> + >> + (cl-defmethod xref-backend-definitions ((_backend (eql matlab-shell)) prompt) >> + (let* ((file-and-flag (matlab-shell-which-fcn prompt)) >> + (built-in-p (cdr file-and-flag)) >> + (file (if built-in-p >> + (replace-regexp-in-string "/@[^/]+" "" (car file-and-flag)) >> + (car file-and-flag)))) >> + (message file) >> + (if (file-exists-p file) >> + (list (xref-make prompt >> + (xref-make-file-location >> + file >> + 1 0)))))) >> + >> + (cl-defmethod xref-backend-apropos ((_backend (eql matlab-shell)) pattern) >> + (xref-backend-definitions 'matlab-shell pattern)) >> + >> + (defun matlab-shell-xref-activate () >> + "Function to activate xref backend. >> +Add this function to `xref-backend-functions' for matlab shell to use xref to find function and variable definitions." >> + (and (matlab-shell-buffer-barf-not-running) >> + 'matlab-shell))) >> >> ;;; MATLAB Shell Commands ===================================================== >> ;; >> >> Diff finished. Sat Nov 28 23:44:47 2020 >> . >> >> Eric Ludlam <eri...@gm...> writes: >> >>> Hi, >>> >>> The existing matlab completion stuff should work with company .. or at >>> least there is code in there referencing company completion engine. I >>> was never a fan so I don't use that particular package. >>> >>> In the MATLAB menu, you will find a "Locate MATLAB function" option >>> which is similar to jump-to functionality like etags. >>> >>> Newer emacsen now how 'xref' as a bit of infrastructure and keybinding >>> but matlab mode doesn't plug into it yet. In theory matlab mode could >>> hook matlab-shell-locate-fcn into xref but I haven't researched how to >>> do that yet. >>> >>> Eric >>> >>> On 11/27/20 12:44 AM, Jonathan Sahar wrote: >>>> Hi Eric, >>>> >>>> Thanks so much for taking the time to test it! >>>> It's not unique to that sturct. >>>> Is there anything that I need/can configure on terms of the completion >>>> engine? I'm using company for most other things, maybe there's some >>>> conflict, or some missing configuration? >>>> >>>> Thank you for the patch! I'll try it out, and I'll using Matlab mode >>>> from the git source as well. >>>> >>>> Do you have a pointers for setting up jump-to-function functionally? >>>> >>>> Thanks again for all the help and information, it's really appreciated. >>>> >>>> Jonathan >>>> >>>> On Thu, 26 Nov 2020, 19:01 Eric Ludlam, <eri...@gm... >>>> <mailto:eri...@gm...>> wrote: >>>> >>>> Hi Jonathan, >>>> >>>> I happened to have MATLAB 18a installed and was able to test using >>>> matlab.el, and matlab-shell.el from git, but could not replicate a >>>> completion problem. Sorry. Is it special to the "EEG" data >>>> structure, >>>> or does this occur everywhere? >>>> >>>> You had some other questions too. >>>> >>>> Matlab mode does support CEDET, but you do not need to use CEDET in >>>> order to use matlab mode. MATLAB mode without support packages >>>> supports >>>> a bunch of different completion features, but most are pretty >>>> simple. >>>> If you enable CEDET with the data base and have matlab-shell >>>> running, it >>>> will try to use the shell to find files on your path, but it >>>> doesn't use >>>> the shell for completions. That code is pretty old and I don't think >>>> those bits were every plugged together. >>>> >>>> I did a little hacking and put together the attached patch that >>>> enables >>>> completion via MATLAB shell in MATLAB buffers. It is rather >>>> primitive >>>> as it only does global symbols and knows nothing about the local >>>> context, but perhaps it can serve as inspiration for putting >>>> something >>>> more complete together. >>>> >>>> Lastly, in a MATLAB buffer, you can type: >>>> >>>> M-x matlab-shell-describe-command RET >>>> >>>> on a symbol and it should do vaguely what you were asking for below. >>>> >>>> Eric >>>> >>>> On 11/25/20 11:41 AM, Jonathan Sahar wrote: >>>> > Hi Eric, thanks for your reply! >>>> > >>>> > I'm running version '9.4.0.949201 (R2018a) Update 6'. >>>> > I've installed matlab-mode through Doom emacs' (package! ...) >>>> > directive, but I've looked at the changelog locally and on >>>> > sourceforge, and the latest commit is the same one... >>>> > >>>> > Best, >>>> > Jonathan >>>> > >>>> > >>>> > >>>> > >>>> > On Wed, 25 Nov 2020 at 18:03, Eric Ludlam <eri...@gm... >>>> <mailto:eri...@gm...> >>>> > <mailto:eri...@gm... <mailto:eri...@gm...>>> wrote: >>>> > >>>> > Hi Jonathan, >>>> > >>>> > As new version of MATLAB come out, the text that comes out for >>>> > errors, >>>> > completions, and all sorts of things change which can break >>>> the shell. >>>> > >>>> > What version of MATLAB are you using, and which version of >>>> the matlab >>>> > mode code are you using? >>>> > >>>> > We made a bunch of updates last winter to ML shell which you >>>> can get >>>> > from the git repository: >>>> > >>>> > https://sourceforge.net/p/matlab-emacs/src/ci/master/tree/ >>>> > >>>> > There are also a few extra fixes on the 'usage1' branch >>>> which haven't >>>> > been merged into the main branch yet. >>>> > >>>> > That all said, I don't recall big changes needed for completion >>>> > lately. :( >>>> > >>>> > Eric >>>> > >>>> > >>>> > On 11/18/20 10:03 AM, Jonathan Sahar wrote: >>>> > > >>>> > > I've been working with matlab-mode and matlab-shell for >>>> the last >>>> > few >>>> > > days, and I'm really digging it so far. The only two >>>> things I can't >>>> > > get to work properly are completion - neither in shell, >>>> nor in .m >>>> > > files - and jumping to function definitions, and I would >>>> really >>>> > > appreciate some help with these. when I hit TAB in shell, >>>> my text >>>> > > turns into >>>> > > >>>> > > |>> emacsdocomplete('EEG.(cond') | >>>> > > >>>> > > and when I hit RETURN I get (the appropriate): >>>> > > >>>> > > |emacs_completions_output = java.lang.String[]: 'cond' >>>> 'condeig' | >>>> > > >>>> > > but it's not integrated into the shell properly, i.e. I can't >>>> > choose >>>> > > which of the above I want, I have to re-type the command >>>> along with >>>> > > the chosen completion. In .m files I just get nothing >>>> except for >>>> > the >>>> > > word completion for words already in the buffer - which I've >>>> > > configured myself. >>>> > > >>>> > > I've read somewhere that the completion is meant to be >>>> related to >>>> > > CEDET somehow but I couldn't make out much more (I'm >>>> working on >>>> > Doom >>>> > > Emacs, and I seen to have CEDET installed, and can run >>>> > > matlab-cedet-setup, which does nothing as far as I can tell). >>>> > > >>>> > > As to function definitions - I don't even know where to >>>> start.. >>>> > I've >>>> > > read that ctags now supports matlab, but I don't know >>>> where (if) >>>> > the >>>> > > actual .m files for the built-in functions reside in the >>>> install >>>> > dir. >>>> > > >>>> > > Ideally I'd love to be able to stand on a function name and be >>>> > able to >>>> > > get the "help funcName" output in another buffer or >>>> something (this >>>> > > works from the shell). >>>> > > >>>> > > Thanks a lot! >>>> > > >>>> > >>>> >>> >>> >>> _______________________________________________ >>> Matlab-emacs-discuss mailing list >>> Mat...@li... >>> https://lists.sourceforge.net/lists/listinfo/matlab-emacs-discuss |
From: Karthik C. <kar...@gm...> - 2020-12-23 10:04:21
Attachments:
matlab-xref.el
|
Hi Eric, > I did look at the elisp backend which it advertised as the prime > example. That one is quite large compared to your patch. Do you > think the below would expand out to be much larger? I'm considering > if xref support would move into it's own file or not. The xref support for MATLAB in my patch is very short (relatively) because - I wrote it as a wrapper around `matlab-shell-which-fcn', which does the heavy lifing of finding the function in question. Matlab-shell already has support for jumping to definitions so I reused it. The downside is that matlab-shell needs to be running for xref support to work. This is not ideal, but the alternative is to write code to find function definitions from scratch. - Only jump to definition is implemented. Two other xref functions: `xref-backend-apropos' and `xref-find-references', are not implemented at all. I want to look into adding these, but I'm not sure right now how to go about it. > I also note that the elisp version doesn't use require for xref, and > your patch depends on the feature existing when the code loads. I > think it does so via: > > (declare-function xref-make "xref" (summary location)) > > Will that work here too? I think `declare-function' keeps the byte-compiler from complaining and doesn't do much else. This should help here, though, and checking if xref is loaded should be unnecessary. In summary, a slightly modified version of this patch can be included as preliminary xref support for matlab-mode. It can be its own file if it's expected to be expanded in the future with `xref-find-references' and other functionality, and prehaps written in a way as to not require matlab-shell to be running. Attached is a patch (as a separate file) with some minor modifications from last time. For it to be integrated into matlab-mode, one other piece of configuration is needed: (add-hook 'xref-backend-definitions #'matlab-shell-xref-activate) This needs to be added in the matlab-mode major mode definition in `define-derived-mode matlab-mode' in matlab.el. Karthik |
From: Eric L. <eri...@gm...> - 2021-01-17 17:41:55
|
Hi Karthik, Thanks for the update and explanation. I finally had some time to sit with your code, try it out in a few situations, and teach myself how xref works. I haven't had much opportunity to learn all the new stuff in eieio that it uses, so that was nice. I created matlab-xref.el on the shellcomplete branch which includes a tweaked version of your code. I included an xref engine that will do local symbol lookups for local functions and the like. Combined, with the shell version, you can get to most places quickly. I think this is a pretty good start. I've already found it changed the way I do navigation. Very nice. Eric On 12/23/20 5:04 AM, Karthik Chikmagalur wrote: > Hi Eric, > >> I did look at the elisp backend which it advertised as the prime >> example. That one is quite large compared to your patch. Do you >> think the below would expand out to be much larger? I'm considering >> if xref support would move into it's own file or not. > The xref support for MATLAB in my patch is very short (relatively) > because > > - I wrote it as a wrapper around `matlab-shell-which-fcn', which does > the heavy lifing of finding the function in question. Matlab-shell > already has support for jumping to definitions so I reused it. The > downside is that matlab-shell needs to be running for xref support to > work. This is not ideal, but the alternative is to write code to find > function definitions from scratch. > > - Only jump to definition is implemented. Two other xref functions: > `xref-backend-apropos' and `xref-find-references', are not implemented > at all. I want to look into adding these, but I'm not sure right now > how to go about it. > >> I also note that the elisp version doesn't use require for xref, and >> your patch depends on the feature existing when the code loads. I >> think it does so via: >> >> (declare-function xref-make "xref" (summary location)) >> >> Will that work here too? > I think `declare-function' keeps the byte-compiler from complaining and > doesn't do much else. This should help here, though, and checking if > xref is loaded should be unnecessary. > > In summary, a slightly modified version of this patch can be included as > preliminary xref support for matlab-mode. It can be its own file if it's > expected to be expanded in the future with `xref-find-references' and > other functionality, and prehaps written in a way as to not require > matlab-shell to be running. > > Attached is a patch (as a separate file) with some minor modifications > from last time. For it to be integrated into matlab-mode, one other > piece of configuration is needed: > > (add-hook 'xref-backend-definitions #'matlab-shell-xref-activate) > > This needs to be added in the matlab-mode major mode definition in > `define-derived-mode matlab-mode' in matlab.el. > > Karthik > |
From: Eric L. <eri...@gm...> - 2021-01-17 19:20:44
|
Hi Jonathan, I tried using: M-x matlab-shell RET M-x company-mode RET then @ matlab prompt: >> fo M-x company-matlab-shell RET to simulate what you have in your stack trace below. I get a yellow popup with completions I expect in it. I can pick one and it then inserts the completion correctly. I tried this in Emacs 26.3 as installed by Ubuntu, and also 28.0.50 as downloaded from git yesterday morning. I tend to run my Emacs as stock as possible so I don't accidentally create dependencies on random tools, so I'm not familiar with a more complex company mode setup. Due to the nature of using MATLAB Shell, I recommend looking at the value of `comint-prompt-read-only' to see if that might be involved. It is nil by default in my Emacsen, and matlab-shell doesn't set it because I do a lot of fiddling with the buffer in the background. If it were t, I would imagine a range of other things not working either though. That's pretty much all I can think of. Sorry I can't be more helpful. :( Eric On 1/6/21 5:50 AM, Jonathan Sahar wrote: > Hi, > I'm still getting the same error message with the updated version of > the repository... > the stack trace I get is: > ``` > Debugger entered--Lisp error: (error "Company: backend > company-matlab-shell error \"Text is read-only\" with args (prefix)") > signal(error ("Company: backend company-matlab-shell error \"Text is > read-only\" with args (prefix)")) > error("Company: backend %s error \"%s\" with args %s" > company-matlab-shell "Text is read-only" (prefix)) > company-call-backend-raw(prefix) > apply(company-call-backend-raw prefix) > company--force-sync(company-call-backend-raw (prefix) > company-matlab-shell) > company-call-backend(prefix) > company--begin-new() > company--perform() > company-auto-begin() > company-manual-begin() > #f(compiled-function (backend &optional callback) "Start a > completion at point using BACKEND." (interactive #f(compiled-function > () #<bytecode 0x27b2831>)) #<bytecode 0x36c7e49>)(company-matlab-shell) > apply(#f(compiled-function (backend &optional callback) "Start a > completion at point using BACKEND." (interactive #f(compiled-function > () #<bytecode 0x29caa1d>)) #<bytecode 0x36c7e49>) company-matlab-shell) > company-begin-backend(company-matlab-shell) > company-matlab-shell(interactive) > funcall-interactively(company-matlab-shell interactive) > ``` > > and the output in the console is: > > ``` > >> emacsdocomplete('all') > > emacs_completions_output = > > java.lang.String[]: > > 'all' > 'allchild' > 'allElectrodes' > 'allfeasible' > 'allMuPADNotebooks' > > ``` > > which is the same output that I get by running M-x > matlab-complete-symbol, if that helps to make sense of things. > > Thanks, > Jonathan |
From: Haik S. <hai...@ku...> - 2021-01-17 19:53:12
|
Dear Jonathan, I am running Doom Emacs and had the same issue. The problem is that the temporary output should be removed, but the lines in the shell-buffer have a special read-only mode. The work-around is to set `inhibit-read-only`. So what solved it: (defadvice! inhibit-real-only-a (oldfun &rest r) "Temporary remove read-only lines in shell buffer" :around#'matlab-shell-collect-command-output (let ((inhibit-read-only t)) (apply oldfun r))) Best regards, Haik 17.01.2021 20:20 Eric Ludlam <eri...@gm...> kirjutas: > Hi Jonathan, > > I tried using: > > M-x matlab-shell RET > M-x company-mode RET > > then @ matlab prompt: > > >> fo > > M-x company-matlab-shell RET > > to simulate what you have in your stack trace below. I get a > yellow > popup with completions I expect in it. I can pick one and it > then > inserts the completion correctly. > > I tried this in Emacs 26.3 as installed by Ubuntu, and also > 28.0.50 as > downloaded from git yesterday morning. > > I tend to run my Emacs as stock as possible so I don't > accidentally > create dependencies on random tools, so I'm not familiar with a > more > complex company mode setup. > > Due to the nature of using MATLAB Shell, I recommend looking at > the > value of `comint-prompt-read-only' to see if that might be > involved. It > is nil by default in my Emacsen, and matlab-shell doesn't set it > because > I do a lot of fiddling with the buffer in the background. If it > were t, > I would imagine a range of other things not working either > though. > > That's pretty much all I can think of. Sorry I can't be more > helpful. :( > Eric > > On 1/6/21 5:50 AM, Jonathan Sahar wrote: >> Hi, >> I'm still getting the same error message with the updated >> version of >> the repository... >> the stack trace I get is: >> ``` >> Debugger entered--Lisp error: (error "Company: backend >> company-matlab-shell error \"Text is read-only\" with args >> (prefix)") >> signal(error ("Company: backend company-matlab-shell error >> \"Text is >> read-only\" with args (prefix)")) >> error("Company: backend %s error \"%s\" with args %s" >> company-matlab-shell "Text is read-only" (prefix)) >> company-call-backend-raw(prefix) >> apply(company-call-backend-raw prefix) >> company--force-sync(company-call-backend-raw (prefix) >> company-matlab-shell) >> company-call-backend(prefix) >> company--begin-new() >> company--perform() >> company-auto-begin() >> company-manual-begin() >> #f(compiled-function (backend &optional callback) "Start a >> completion at point using BACKEND." (interactive >> #f(compiled-function >> () #<bytecode 0x27b2831>)) #<bytecode >> 0x36c7e49>)(company-matlab-shell) >> apply(#f(compiled-function (backend &optional callback) >> "Start a >> completion at point using BACKEND." (interactive >> #f(compiled-function >> () #<bytecode 0x29caa1d>)) #<bytecode 0x36c7e49>) >> company-matlab-shell) >> company-begin-backend(company-matlab-shell) >> company-matlab-shell(interactive) >> funcall-interactively(company-matlab-shell interactive) >> ``` >> >> and the output in the console is: >> >> ``` >> >> emacsdocomplete('all') >> >> emacs_completions_output = >> >> java.lang.String[]: >> >> 'all' >> 'allchild' >> 'allElectrodes' >> 'allfeasible' >> 'allMuPADNotebooks' >> >> ``` >> >> which is the same output that I get by running M-x >> matlab-complete-symbol, if that helps to make sense of things. >> >> Thanks, >> Jonathan > > > > _______________________________________________ > Matlab-emacs-discuss mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matlab-emacs-discuss |
From: Eric L. <eri...@gm...> - 2021-01-17 20:22:44
|
Thanks Haik. That implies a patch like this will fix the issue... ? Do you know what is being set to read-only and why? A better patch might disable whatever that is since other code may need something similar, and it would be better to fix the source than add little patches like this around. Eric -- diff --git a/matlab-shell.el b/matlab-shell.el index b2943d8..0357119 100644 --- a/matlab-shell.el +++ b/matlab-shell.el @@ -1686,7 +1686,8 @@ This uses the lookfor command to find viable commands." It's output is returned as a string with no face properties. The text output of the command is removed from the MATLAB buffer so there will be no indication that it ran." - (let ((msbn (matlab-shell-buffer-barf-not-running)) + (let ((inhibit-read-only t) + (msbn (matlab-shell-buffer-barf-not-running)) (matlab-shell-suppress-prompt-hooks t)) ;; We are unable to use save-excursion to save point position because we are ;; manipulating the *MATLAB* buffer by erasing the current text typed at the On 1/17/21 2:35 PM, Haik Silm wrote: > Dear Jonathan, > > I am running Doom Emacs and had the same issue. The problem is that > the temporary output should be removed, but the lines in the > shell-buffer have a special read-only mode. The work-around is to set > `inhibit-read-only`. > > So what solved it: > > (defadvice! inhibit-real-only-a (oldfun &rest r) > "Temporary remove read-only lines in shell buffer" > :around#'matlab-shell-collect-command-output > (let ((inhibit-read-only t)) (apply oldfun r))) > > Best regards, > Haik > > 17.01.2021 20:20 Eric Ludlam <eri...@gm...> kirjutas: >> Hi Jonathan, >> >> I tried using: >> >> M-x matlab-shell RET >> M-x company-mode RET >> >> then @ matlab prompt: >> >> >> fo >> >> M-x company-matlab-shell RET >> >> to simulate what you have in your stack trace below. I get a yellow >> popup with completions I expect in it. I can pick one and it then >> inserts the completion correctly. >> >> I tried this in Emacs 26.3 as installed by Ubuntu, and also 28.0.50 as >> downloaded from git yesterday morning. >> >> I tend to run my Emacs as stock as possible so I don't accidentally >> create dependencies on random tools, so I'm not familiar with a more >> complex company mode setup. >> >> Due to the nature of using MATLAB Shell, I recommend looking at the >> value of `comint-prompt-read-only' to see if that might be involved. It >> is nil by default in my Emacsen, and matlab-shell doesn't set it because >> I do a lot of fiddling with the buffer in the background. If it were t, >> I would imagine a range of other things not working either though. >> >> That's pretty much all I can think of. Sorry I can't be more >> helpful. :( >> Eric >> >> On 1/6/21 5:50 AM, Jonathan Sahar wrote: >>> Hi, >>> I'm still getting the same error message with the updated version of >>> the repository... >>> the stack trace I get is: >>> ``` >>> Debugger entered--Lisp error: (error "Company: backend >>> company-matlab-shell error \"Text is read-only\" with args (prefix)") >>> signal(error ("Company: backend company-matlab-shell error \"Text is >>> read-only\" with args (prefix)")) >>> error("Company: backend %s error \"%s\" with args %s" >>> company-matlab-shell "Text is read-only" (prefix)) >>> company-call-backend-raw(prefix) >>> apply(company-call-backend-raw prefix) >>> company--force-sync(company-call-backend-raw (prefix) >>> company-matlab-shell) >>> company-call-backend(prefix) >>> company--begin-new() >>> company--perform() >>> company-auto-begin() >>> company-manual-begin() >>> #f(compiled-function (backend &optional callback) "Start a >>> completion at point using BACKEND." (interactive #f(compiled-function >>> () #<bytecode 0x27b2831>)) #<bytecode 0x36c7e49>)(company-matlab-shell) >>> apply(#f(compiled-function (backend &optional callback) "Start a >>> completion at point using BACKEND." (interactive #f(compiled-function >>> () #<bytecode 0x29caa1d>)) #<bytecode 0x36c7e49>) company-matlab-shell) >>> company-begin-backend(company-matlab-shell) >>> company-matlab-shell(interactive) >>> funcall-interactively(company-matlab-shell interactive) >>> ``` >>> >>> and the output in the console is: >>> >>> ``` >>> >> emacsdocomplete('all') >>> >>> emacs_completions_output = >>> >>> java.lang.String[]: >>> >>> 'all' >>> 'allchild' >>> 'allElectrodes' >>> 'allfeasible' >>> 'allMuPADNotebooks' >>> >>> ``` >>> >>> which is the same output that I get by running M-x >>> matlab-complete-symbol, if that helps to make sense of things. >>> >>> Thanks, >>> Jonathan >> >> >> >> _______________________________________________ >> Matlab-emacs-discuss mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matlab-emacs-discuss |
From: Jonathan S. <jon...@gm...> - 2021-01-18 09:39:17
|
Thanks Haik! It works!! On Sun, 17 Jan 2021 at 21:35, Haik Silm <hai...@ku...> wrote: > Dear Jonathan, > > I am running Doom Emacs and had the same issue. The problem is > that the temporary output should be removed, but the lines in the > shell-buffer have a special read-only mode. The work-around is to > set `inhibit-read-only`. > > So what solved it: > > (defadvice! inhibit-real-only-a (oldfun &rest r) > "Temporary remove read-only lines in shell buffer" > :around#'matlab-shell-collect-command-output > (let ((inhibit-read-only t)) (apply oldfun r))) > > Best regards, > Haik > > 17.01.2021 20:20 Eric Ludlam <eri...@gm...> kirjutas: > > Hi Jonathan, > > > > I tried using: > > > > M-x matlab-shell RET > > M-x company-mode RET > > > > then @ matlab prompt: > > > > >> fo > > > > M-x company-matlab-shell RET > > > > to simulate what you have in your stack trace below. I get a > > yellow > > popup with completions I expect in it. I can pick one and it > > then > > inserts the completion correctly. > > > > I tried this in Emacs 26.3 as installed by Ubuntu, and also > > 28.0.50 as > > downloaded from git yesterday morning. > > > > I tend to run my Emacs as stock as possible so I don't > > accidentally > > create dependencies on random tools, so I'm not familiar with a > > more > > complex company mode setup. > > > > Due to the nature of using MATLAB Shell, I recommend looking at > > the > > value of `comint-prompt-read-only' to see if that might be > > involved. It > > is nil by default in my Emacsen, and matlab-shell doesn't set it > > because > > I do a lot of fiddling with the buffer in the background. If it > > were t, > > I would imagine a range of other things not working either > > though. > > > > That's pretty much all I can think of. Sorry I can't be more > > helpful. :( > > Eric > > > > On 1/6/21 5:50 AM, Jonathan Sahar wrote: > >> Hi, > >> I'm still getting the same error message with the updated > >> version of > >> the repository... > >> the stack trace I get is: > >> ``` > >> Debugger entered--Lisp error: (error "Company: backend > >> company-matlab-shell error \"Text is read-only\" with args > >> (prefix)") > >> signal(error ("Company: backend company-matlab-shell error > >> \"Text is > >> read-only\" with args (prefix)")) > >> error("Company: backend %s error \"%s\" with args %s" > >> company-matlab-shell "Text is read-only" (prefix)) > >> company-call-backend-raw(prefix) > >> apply(company-call-backend-raw prefix) > >> company--force-sync(company-call-backend-raw (prefix) > >> company-matlab-shell) > >> company-call-backend(prefix) > >> company--begin-new() > >> company--perform() > >> company-auto-begin() > >> company-manual-begin() > >> #f(compiled-function (backend &optional callback) "Start a > >> completion at point using BACKEND." (interactive > >> #f(compiled-function > >> () #<bytecode 0x27b2831>)) #<bytecode > >> 0x36c7e49>)(company-matlab-shell) > >> apply(#f(compiled-function (backend &optional callback) > >> "Start a > >> completion at point using BACKEND." (interactive > >> #f(compiled-function > >> () #<bytecode 0x29caa1d>)) #<bytecode 0x36c7e49>) > >> company-matlab-shell) > >> company-begin-backend(company-matlab-shell) > >> company-matlab-shell(interactive) > >> funcall-interactively(company-matlab-shell interactive) > >> ``` > >> > >> and the output in the console is: > >> > >> ``` > >> >> emacsdocomplete('all') > >> > >> emacs_completions_output = > >> > >> java.lang.String[]: > >> > >> 'all' > >> 'allchild' > >> 'allElectrodes' > >> 'allfeasible' > >> 'allMuPADNotebooks' > >> > >> ``` > >> > >> which is the same output that I get by running M-x > >> matlab-complete-symbol, if that helps to make sense of things. > >> > >> Thanks, > >> Jonathan > > > > > > > > _______________________________________________ > > Matlab-emacs-discuss mailing list > > Mat...@li... > > https://lists.sourceforge.net/lists/listinfo/matlab-emacs-discuss > |
From: Karthik C. <kar...@gm...> - 2021-01-18 04:53:53
|
Hi Eric, The `matlab-local-xref` backend is quite useful, thank you for taking the time to go through it. I did notice something in this function: (defun matlab-shell-xref-activate () "Function to activate xref backend. Add this function to `xref-backend-functions' for matlab shell to use xref to find function and variable definitions." (and (member major-mode '(matlab-mode matlab-shell-mode org-mode)) (matlab-shell-active-p) 'matlab-shell)) The test for major-mode is unnecessary since the xref backend is only loaded when matlab-mode is activated. Even if you decide to leave it in the reference to `org-mode' is completely superfluous. This is some debug code that I forgot to take out before I submitted the patch. (The same applies to the function `matlab-local-xref-activate'.) So we just need (defun matlab-shell-xref-activate () "Function to activate xref backend. Add this function to `xref-backend-functions' for matlab shell to use xref to find function and variable definitions." (and (matlab-shell-active-p) 'matlab-shell)) Karthik Eric Ludlam <eri...@gm...> writes: > Hi Karthik, > > Thanks for the update and explanation. > > I finally had some time to sit with your code, try it out in a few > situations, and teach myself how xref works. I haven't had much > opportunity to learn all the new stuff in eieio that it uses, so that > was nice. > > I created matlab-xref.el on the shellcomplete branch which includes a > tweaked version of your code. > I included an xref engine that will do local symbol lookups for local > functions and the like. Combined, with the shell version, you can get > to most places quickly. > > I think this is a pretty good start. I've already found it changed the > way I do navigation. Very nice. > > Eric > > > On 12/23/20 5:04 AM, Karthik Chikmagalur wrote: >> Hi Eric, >> >>> I did look at the elisp backend which it advertised as the prime >>> example. That one is quite large compared to your patch. Do you >>> think the below would expand out to be much larger? I'm considering >>> if xref support would move into it's own file or not. >> The xref support for MATLAB in my patch is very short (relatively) >> because >> >> - I wrote it as a wrapper around `matlab-shell-which-fcn', which does >> the heavy lifing of finding the function in question. Matlab-shell >> already has support for jumping to definitions so I reused it. The >> downside is that matlab-shell needs to be running for xref support to >> work. This is not ideal, but the alternative is to write code to find >> function definitions from scratch. >> >> - Only jump to definition is implemented. Two other xref functions: >> `xref-backend-apropos' and `xref-find-references', are not implemented >> at all. I want to look into adding these, but I'm not sure right now >> how to go about it. >> >>> I also note that the elisp version doesn't use require for xref, and >>> your patch depends on the feature existing when the code loads. I >>> think it does so via: >>> >>> (declare-function xref-make "xref" (summary location)) >>> >>> Will that work here too? >> I think `declare-function' keeps the byte-compiler from complaining and >> doesn't do much else. This should help here, though, and checking if >> xref is loaded should be unnecessary. >> >> In summary, a slightly modified version of this patch can be included as >> preliminary xref support for matlab-mode. It can be its own file if it's >> expected to be expanded in the future with `xref-find-references' and >> other functionality, and prehaps written in a way as to not require >> matlab-shell to be running. >> >> Attached is a patch (as a separate file) with some minor modifications >> from last time. For it to be integrated into matlab-mode, one other >> piece of configuration is needed: >> >> (add-hook 'xref-backend-definitions #'matlab-shell-xref-activate) >> >> This needs to be added in the matlab-mode major mode definition in >> `define-derived-mode matlab-mode' in matlab.el. >> >> Karthik >> |