From: Karthik C. <kar...@gm...> - 2020-12-23 10:04:21
|
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 |