-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
Using consult-completing-read-multiple
breaks magit-completing-read-multiple*
#4437
Comments
The issue should be pretty easy to resolve, consult-crm does not call split-string breaking the input retrieval hack of magit. Instead the return value should be used and concatenated. |
Maybe @jakanakaevangeli can help with this? |
Magit uses crm for reading git revision ranges such as
"master@{1}..master develop", where "master", "master" and "develop" are
completion candidates, "@{1}.." and " " are separators and order is
important. This is fundamentally incompatible with consult's crm
function which works somewhat like a check-box to select a list of
candidates.
I brainstormed two ideas in case they are useful:
A simple solution could be to expose a consult-inhibit-consult-crm
variable which magit-crm* could bind to t. Though we would probably have
to convert consult-crm from :override to :around advice for this to
work.
A more complex but IMO more complete solution could be for magit to
expose a variable such as magit-crm*-avoid-crm. Users of consult-crm
would set it to t. In this case, instead of calling
completing-read-multiple, magit-crm* would use completing-read with a
dynamic completion table similar to #'crm--collection-fn.
|
Okay, so the point here for Magit is that the separators are preserved additionally to the candidates and their order? Order of selection itself is preserved by I think it is kind of obvious to offer such a crm implementation as Consult does. There is also crm-custom, which calls cr in a loop. On the other hand the magit use of crm seems to be a pretty severe abuse. The correct way to implement the desired functionality in magit with compliant completion UIs like default completion, Icomplete, Vertico etc is to implement its own programmable completion table, which performs the desired completion of the revisions with the separators in between. If there is interest in adding such a feature here, I can try to contribute a patch. It would be even interesting to see how such a completion table would look. It is not trivial though, messing with all the completion boundaries etc.
I think it would be easier to locally remove the
Agree. The solutions in my order of preference:
Regarding 4., the consult opt out mechanism: Such a mechanism may indeed be necessary since consult-crm works only correctly if the completion table passed to consult-crm is static. You cannot pass the file completion table to consult-crm for example. However one can also not pass the file completion table to the default crm implementation (throws an error), so it seems to me that dynamic tables are simply not used in conjunction with crm. The point is that dynamic completion tables passed to crm corresponds to recursive completion boundaries, I think this is simply not supported by the completion machinery. So given this, I believe that consult crm is mostly sufficient. Of course this does not include API abuses as in the magit case. |
Hmm, I think 1. is overkill. I would probably go with 3. or 5. for simplicity for now. Note that consult-crm is pretty new and experimental. @iyefrat You could use something like this for now or decide to not use consult-crm if there are more scenarios where something breaks. Unfortunately not having something like consult-crm breaks use cases as the one in bibtex-actions. (defun opt-out-of-consult-crm (&rest args)
(if (advice-member-p #'consult-completing-read-multiple #'completing-read-multiple)
(unwind-protect
(progn
(advice-remove #'completing-read-multiple #'consult-completing-read-multiple)
(apply args))
(advice-add #'completing-read-multiple :override #'consult-completing-read-multiple))
(apply args)))
(advice-add #'magit-completing-read-multiple* :around #'opt-out-of-consult-crm) |
I do agree that Magit's "the separators are relevant data too" trick is abuse but the alternatives are not great either or as you say "overkill". But I am perfectly willing to cooperate on this. Right now I am a little busy though. The "unbind the advice" approach sounds reasonable to me. I'm gonna add that now. |
Okay, I think the unbind advice is the lowest effort for now.
I think in the longer term, a proper completion table may be the way to go. And the good thing is - such a completion table already exists, it is called crm--collection-fn. For example this works as expected with Vertico: (let ((crm-completion-table '("first" "second" "third")))
(completing-read "CRM: " #'crm--collection-fn)) This way you reuse the underlying crm infrastructure and you still don't abuse the API. I believe at some point you also had something like this, basically a replica of the default EDIT1: Actually it wasn't long ago c10e10c |
Our NO-SPLIT hack is not compatible with the advice `consult' overrides `completing-read-multiple' with, so fall back to the original function. See #4437.
I was just gonna post that. 😀
So yeah, this was actually done so that we would automatically benefit from changes made by completion frameworks. Of course there is also the risk of things automatically breaking as a result as we have just seen, but then we just have to find a fix. |
By the way, consults crm interface is really nice. |
Okay then... football. 🍿 ⚽ |
Thanks! Have fun! |
Thanks for the fix! Just checking, did you leave this issue open on purpose? |
I am usually quick to close issues and then once I don't ... |
@tarsius |
Thanks for the heads up! |
This reverts commit aa1b887. The `consult-completing-read-multiple' has been deprecated in Consult 0.18. If it is still used, then it disables itself on first use and arranges for `completing-read-multiple' to be used. See #4437 (comment).
Done. |
This issue was originally reported in minad/consult#358, but was found to be caused
magit-completing-read-multiple*
breaking the CRM abstraction by @minad, please read his comment here for more details.Steps to reproduce:
emacs -Q
, install the newest versions of Consult and Magit(advice-add #'completing-read-multiple :override #'consult-completing-read-multiple)
magit-status
l o
to open the log of another branchRET
twice to selectThe text was updated successfully, but these errors were encountered: