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

sorting function and strings #2763

Closed
seblemaguer opened this issue Dec 16, 2020 · 3 comments
Closed

sorting function and strings #2763

seblemaguer opened this issue Dec 16, 2020 · 3 comments

Comments

@seblemaguer
Copy link

Hello,

I am currently facing the issue described in radian-software/prescient.el#73

As it causes me a lot of trouble lately, I would like to try to fix this. However, before I go further, I would like to know what is your approach concerning the items: should I consider that items passed to the sorting function should be strings or can be anything?

Thanks

@basil-conto
Copy link
Collaborator

basil-conto commented Dec 16, 2020

Unfortunately, third-party completion "frontends" (including Ivy) seem to define their own notions of sorting.

The standard means of sorting completion candidates are the metadata display-sort-function and cycle-sort-function (see (info "(elisp) Programmed Completion")), each of which accepts a list of completion strings. But I don't even know how well Ivy handles these, let alone other completion frontends.

Ivy provides two user options for customising sorting: ivy-sort-functions-alist and ivy-sort-matches-functions-alist. Sorting functions in the former take two arguments (as with the built-in sort function) and return nil or non-nil depending on which argument should come first. Functions in the latter take a string and a list of candidates containing that string and return the list of candidates in the desired order.

Functions in ivy-sort-functions-alist have to support the different types of completion collections they might be used for. For example, the default Ivy sort function ivy-string< is like string< but handles both strings and cons cells (in the case of alist collections) as arguments.

I don't know what Prescient does, so without a backtrace of the error you run into, there's not much more I can say. HTH.

@seblemaguer
Copy link
Author

I see. Thanks for the answer. I have a look to see if I can get something minimal which makes sense as I am not sure that the current backtrace will be useful.

@seblemaguer
Copy link
Author

seblemaguer commented Dec 30, 2020

I switched to something else. So I won't have time to deal with this issue. I close it for now but if someone else wants to solve it I am interested in the solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants