radian-software / prescient.el

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

Create `vertico-prescient-mode` and `corfu-prescient-mode`. #131

Closed okamsn closed 1 year ago

okamsn commented 1 year ago

TODO

raxod502 commented 1 year ago

This is great, thank you. I will migrate Radian to use it after merge.

okamsn commented 1 year ago

@raxod502 and @minad, do you have any thoughts on these changes? Are there other things that should be configured? For example, completion categories that should be overridden so that they use prescient, or so that they don't fail when trying to use prescient.

minad commented 1 year ago

@okamsn

Should the toggling command be bound in the Corfu map? Do they make sense there?

I think you should bind them there. Changing the filtering on the fly should work with Corfu.

Regarding the completion-styles - I would make sure that the Vertico prescient mode only applies its overrides in the minibuffer. Likewise the Corfu overrides should be applied only locally in the buffer where corfu-mode is enabled. Then the settings won't interfere.

minad commented 1 year ago

@okamsn Any update here?

okamsn commented 1 year ago

@okamsn Any update here?

@minad: Not yet. I've been busy.

minad commented 1 year ago

Corfu can be enabled in any buffer, in contrast to Vertico which is always in the mini buffer. The candidates are stored in a local variable in the current buffer.

okamsn commented 1 year ago

Corfu can be enabled in any buffer, in contrast to Vertico which is always in the mini buffer. The candidates are stored in a local variable in the current buffer.

Better that I ask, what do you think is the best way to have a toggling command's changes to the prescient.el variables only affect Corfu completion for the current completion session?

For Selectrum and Vertico, we just make the variables local to the minibuffer. With how the toggling commands are currently written, the variables are made local to buffer in which Corfu is used and the change persists after the Corfu pop-up is closed.

minad commented 1 year ago

Take a look at the Corfu source :)

The local variables holding the Corfu state are destroyed during teardown, see:

https://github.com/minad/corfu/blob/99d3a0c8a626db1ff5832b013b2e50352613dd2d/corfu.el#L1096

raxod502 commented 1 year ago

I haven't looked through in detail, since I think you know what you are doing, but I would be more than happy to offer advice if there is any point that I could help with! I think the questions on Corfu and Vertico I am not knowledgeable to answer.

okamsn commented 1 year ago

I think that's everything. Are there any final comments/requests before I merge this?

minad commented 1 year ago

@okamsn This looks great! Thanks for the cleanup, such that the code is shared between the different modes.

minad commented 1 year ago

@okamsn I went over the code and added a few comments.

minad commented 1 year ago

@okamsn Is this ready?

okamsn commented 1 year ago

@okamsn Is this ready?

I think so, unless there are any further requests/comments.

minad commented 1 year ago

Okay. Looks good to me!

minad commented 1 year ago

@okamsn Thanks! Can you please also update the Vertico migration guide accordingly?

okamsn commented 1 year ago

@okamsn Thanks! Can you please also update the Vertico migration guide accordingly?

I will do this once the package becomes available on MELPA.