radian-software / prescient.el

☄️ Simple but effective sorting and filtering for Emacs.
MIT License
603 stars 25 forks source link

Add support for a `prescient.el` completion style. #125

Closed okamsn closed 2 years ago

okamsn commented 2 years ago

This is still a WIP due to surrounding features, but it seems to work well enough. I'm making the PR now in case people want to point things out.


This completion style can optionally modify a completion table's metadata to use prescient.el sorting, including prescient-sort-full-matches-first.

Logic:

  1. Use triggers prescient-all-completions or prescient-try-completion.
  2. These use prescient-filter to filter candidates.
  3. That function stores the regexps used and whether case is ignored as text properties on all candidates in the post-filtering list of candidates.
  4. Highlighting is done back in prescient-all-completions, but not in prescient-try-completion.
  5. Emacs adjust the metadata in completion--nth-completion?
  6. Sorting is then applied?

Since the built-in flex completion style modifies the sorting metadata to a function using completion input, this approach should be fine.

okamsn commented 2 years ago

Related things to do:

Questions to answer:

In general:

okamsn commented 2 years ago

@raxod502, do you have any thoughts on these things?

@minad, since this further enables https://github.com/minad/vertico/issues/237, would you please give this a once-over to see if anything is off? I haven't noticed anything yet, but I'm sure that there are cases I haven't considered.

minad commented 2 years ago

I didn't try yet, but I have a few comments.

raxod502 commented 2 years ago

This looks wonderful, thank you.

okamsn commented 2 years ago

I think all of the kinks have been worked out now. @minad and @raxod502, is there anything you want addressed/changed before I merge this?

minad commented 2 years ago

Looks good!

raxod502 commented 2 years ago

Nope, go ahead!