Skip to content
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

Support affixation-function metadata #240

Closed
minad opened this issue Nov 28, 2020 · 8 comments
Closed

Support affixation-function metadata #240

minad opened this issue Nov 28, 2020 · 8 comments

Comments

@minad
Copy link
Contributor

minad commented Nov 28, 2020

In emacs 28 there is affixation-function which allows prefix/suffix annotations it seems. See emacs-mirror/emacs@3b74059 and minad/consult#5.

@clemera @raxod502 If you are interested I can provide a patch for selectrum. This could be helpful for consult. But I have to think, the problem is again the alist lookup for duplicate candidates. Maybe properties are allowed for the annotation-function/affixation-function (It is different from having the annotation on the return value, where the return value might not originate from the candidate set if the user wrote it by hand). Then the affixation-function could simply return the associated properties. This would result in a bit of an unnecessary going back and forth but if it works...

@clemera
Copy link
Collaborator

clemera commented Nov 28, 2020

Maybe properties are allowed for the annotation-function/affixation-function (It is different from having the annotation on the return value, where the return value might not originate from the candidate set if the user wrote it by hand). Then the affixation-function could simply return the associated properties. This would result in a bit of an unnecessary going back and forth but if it works...

Not sure what you mean by that. How can you use the affixation-function to return properties?

@minad
Copy link
Contributor Author

minad commented Nov 28, 2020

The affixation-function is passed a list of the candidates. If these candidates are allowed to contain properties, these can be accessed and then returned as suffix/prefix strings.

@okamsn
Copy link
Contributor

okamsn commented Nov 28, 2020

I've missed a lot of the conversation surrounding this, but why would you use the annotations to get properties instead of just using completing-read to return the properties, which I think is allowed in Emacs 28?

@clemera
Copy link
Collaborator

clemera commented Nov 28, 2020

@minad Hm, how can this can be used to improve the situation for returning propertized strings, I would assume the selected candidate is still returned from completing-read without properties?

@clemera
Copy link
Collaborator

clemera commented Nov 28, 2020

@okamsn As far as I understood it this will only work partially because the properties are only added to the part you completed within the minibuffer and if you type the string manually you won't get any properties.

@minad
Copy link
Contributor Author

minad commented Nov 28, 2020

@okamsn

I've missed a lot of the conversation surrounding this, but why would you use the annotations to get properties instead of just using completing-read to return the properties, which I think is allowed in Emacs 28?

the problem is if there are duplicate candidates with different properties. this happens for example for the swiper-like consult-line. two different lines with the same text could then get two different line numbers.
Edit: Maybe I misunderstood what you wrote here since you are also thinking about returning properties. Returning properties seems to be never an option, due to what clemera wrote.

@clemera

Hm, how can this can be used to improve the situation for returning propertized strings, I would assume the selected candidate is still returned from completing-read without properties?
As far as I understood it this will only work partially because the properties are only added to the part you completed within the minibuffer and if you type the string manually you won't get any properties.

This issue has nothing to do with what is returned from completing read. The goal here is only to associate prefixes and suffixes with the candidates. I am doing this right now using the 'display hack.

@clemera
Copy link
Collaborator

clemera commented Nov 28, 2020

@minad

This issue has nothing to do with what is returned from completing read. The goal here is only to associate prefixes and suffixes with the candidates. I am doing this right now using the 'display hack.

Okay, I misunderstood your initial comment I get it now.

@clemera
Copy link
Collaborator

clemera commented Dec 14, 2020

Added in #271

@clemera clemera closed this as completed Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants