-
-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop xref-location support #162
Comments
Another option: Actually Embark should export EDIT: But thinking again - this won't work, since you cannot obtain the xref locations from the |
OK, I merged your PR. The only thing that worried me about the PR is that with the ugly hack I wrote in #144, @Gaeric did get a working grep export for the (setf (alist-get 'xref-location embark-exporters-alist) #'embark-consult-export-occur)) |
Yes, I am aware of that. Given that it is an ugly hack and and since it is possible to override, it is okay like this. |
Yeah, it would be nice if the |
Yes, this is what I proposed above (3.). I am also unsure and therefore I left it as is. |
More or less. I'm not sure I understand the context of this discussion, but perhaps you should define your own |
@dgutov Thank you for chiming in. Yes, if we want to modify the candidates to our liking we can always copy the upstream functions and modify it. However the concept of the Embark package is that it allows adding actions to existing commands via the completion category. Our Marginalia package goes in the same direction and adds annotations to existing commands, even if the existing command does not provide them. While all this requires a tiny bit of integration code and cooperation of the completion system, this allows a lot of code reuse. In most cases all the required information is already present in the candidate strings alone. However not in the case of the Emacs 28 I am unsure if this is a compelling enough reason to ask for a change in the |
Have you looked into reusing the "original" Xref buffers this way, then? They have a slightly different format than |
Yes, we have considered this. However if we would want to use the original xref buffers the problem remains, there is still no possibility to convert from the |
But which Well, there's also a |
I am referring to the |
If |
Let me explain the usage (setq xref-show-definitions-function 'xref-show-definitions-completing-read)
(setq xref-show-xrefs-function 'xref-show-definitions-completing-read) Use We want to convert the xref candidates to a buffer,then change those candidates. There is a command (xref-query-replace-in-results) for *xref* buffer. If we can transfrom the xref candidates to *xref* buffer, that would be great. But when we use xref-show-definitions-completing-read, we cannot generate *xref* buffer from the candidates in the minibuffer, because it converts xref-location to grep-like information, so we missed xref-location. |
I understand what you're asking for, just don't understand why.
Do you actually have to do this? |
Yes, I use |
Is creating an embark-specific |
No, it wouldn't be inconvenient. I think the point was just that adding the xref objects as text properties in But it's not really a big deal, if you don't want to modify |
If you can get by well enough with some existing code, good. Because ideally you would use some extension point which was anticipate by the package maintainer rather than plug into something that might break in the future because it's unused in the core. My minor concern with adding text properties is that it makes debugging harder (printed strings with properties are harder to read). But if someone wants to contribute it in a patch, I'll make sure to review it. There can be a more generic approach as well. diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 18fdd963fb..49e895a9d0 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -1068,6 +1068,8 @@ xref-show-definitions-completing-read
(cond
((eq action 'metadata)
'(metadata . ((category . xref-location))))
+ ((eq action 'get-original)
+ (assoc-default string collection))
(t
(complete-with-action action collection string pred)))))
(def (caar collection))) Then you could use it like this: (funcall minibuffer-completion-table "src/frame.c:(defvar tab-bar-mode)" nil 'get-original) |
Having an extra protocol for Embark or similar use cases would be great! However ideally it would be made such that no changes to existing completion tables is necessary. By modifying There is one other change which might be good - |
No changes would be required where the completion table already contains "real" elements, i.e. ones that you can use directly.
Yes, this could work too, as the default implementation of sorts. But I think it should return
I would like that, although there must be some reason for the existing behavior (and if it was explained in some of the previous discussions touching this subject, I don't remember it). You're welcome to |
Yes, that's right. So probably it would be sufficient to only return the value for alists and hashes.
Yes, but the sooner it would be changed, the better. I think it is acceptable practice to ensure that packages support the two latest versions or the Emacs version present on some widespread LTS Linux distributions. We have more possible change proposals for completing-read, we recently introduced the x-group-function extension in Consult, see https://github.com/minad/consult/wiki/Grouping-support. So if I find time for this I may also create a proposal for that. |
See the discussion in #144. The
xref-location
completion category is not robust since it works with incomplete strings. I just addedconsult-xref
which can be used as replacement for the xref show functions with preview support. My proposal is to drop the special xref to grep exporter from Embark. xref-locations are too generic. You can even define your own.xref-location
exporter from Embarkconsult-grep
category instead ofxref-location
. The candidates are always in grep format, export to grep-mode is guaranteed to work. Thegrep-mode
exporter should be moved from embark.el to embark-consult.el.consult-xref
location which attaches thexref-location
object via a text property. This would allow to write an Embark to Grep exporter by filtering for file or (file backed) buffer locations and formatting with abbreviated/relative file paths. But this step is not very important since one can always useconsult-grep
orconsult-ripgrep
instead. Furthermore you would probably dislike the incomplete export.The text was updated successfully, but these errors were encountered: