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

Vertico Prescient: Change how candidates are remembered. #156

Merged
merged 1 commit into from
Jan 4, 2024

Conversation

okamsn
Copy link
Contributor

@okamsn okamsn commented Dec 25, 2023

  • Fix vertico-directory does not behave as expected when used alongside vertico-prescient-mode #155, remembering candidates when entering a new directory
    with vertico-directory-enter.

  • Remember candidates on minibuffer exit as well as candidate
    insertion.

  • Remove vertico-prescient--remember.

  • Add vertico-prescient--remember-minibuffer-contents. If
    completing a file name, only remember the last component of
    the file path, since that is the actual candidate. If the candidate
    is a directory, include the trailing directory separator.

  • Add vertico-prescient--insertion-commands and
    vertico-prescient--remember-inserted-candidate for remembering
    in post-command-hook.

  • Add vertico-prescient--remember-exited-candidate and
    vertico-prescient--exit-commands for remembering in
    minibuffer-exit-hook.

  • Hook vertico-prescient--setup-remembrance into
    minibuffer-setup-hook.

@minad
Copy link

minad commented Dec 25, 2023

This looks quite solid to me. I suggest to move most of the remember code (the hooks etc) to prescient.el and then only configure the trigger commands in vertico-prescient.el, such that the generic parts are reusable and the integration packages are as thin as possible.

@leungbk
Copy link
Contributor

leungbk commented Dec 26, 2023

Thank you for the PR!

I can confirm that this fixes the unexpected behavior I pointed out in #155.

.github/workflows/ci.yml Outdated Show resolved Hide resolved
@raxod502 raxod502 mentioned this pull request Dec 30, 2023
@okamsn
Copy link
Contributor Author

okamsn commented Dec 31, 2023

This looks quite solid to me. I suggest to move most of the remember code (the hooks etc) to prescient.el and then only configure the trigger commands in vertico-prescient.el, such that the generic parts are reusable and the integration packages are as thin as possible.

I will try that. There is the new completions-sort variable, so maybe the default UI can finally support Prescient.

@okamsn okamsn marked this pull request as draft December 31, 2023 00:13
@okamsn okamsn marked this pull request as ready for review January 3, 2024 02:48
- Fix radian-software#155, remembering candidates when entering a new directory
  with `vertico-directory-enter`.
- Remember candidates on minibuffer exit as well as candidate
  insertion.

- Add Compat (https://github.com/emacs-compat/compat) as a dependency.
  It is already a dependency of Vertico.
- Add stub file `stub/compat.el`.
- Remove `vertico-prescient--remember`.
- Add `vertico-prescient--remember-minibuffer-contents`.  If
  completing a file name, only remember the last component of
  the file path, since that is the actual candidate.  If the candidate
  is a directory, include the trailing directory separator.
- Add `vertico-prescient--insertion-commands` and
  `vertico-prescient--remember-inserted-candidate` for remembering
  in `post-command-hook`.
- Add `vertico-prescient--remember-exited-candidate` and
  `vertico-prescient--exit-commands` for remembering in
  `minibuffer-exit-hook`.
- Hook `vertico-prescient--setup-remembrance` into
  `minibuffer-setup-hook`.
@okamsn
Copy link
Contributor Author

okamsn commented Jan 3, 2024

This looks quite solid to me. I suggest to move most of the remember code (the hooks etc) to prescient.el and then only configure the trigger commands in vertico-prescient.el, such that the generic parts are reusable and the integration packages are as thin as possible.

I will try that. There is the new completions-sort variable, so maybe the default UI can finally support Prescient.

For time reasons, I've decided to investigate simplifying that part later in favor of fixing this particular bug now. Does anyone want any changes to how this is written, outside of generalizing it later?

Copy link
Member

@raxod502 raxod502 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got no objections!

@okamsn okamsn merged commit 864b352 into radian-software:main Jan 4, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

vertico-directory does not behave as expected when used alongside vertico-prescient-mode
4 participants