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

Try to use the appropriate flx cache #2817

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

basil-conto
Copy link
Collaborator

  • ivy.el: Avoid registering eval-after-load hooks or unconditionally loading flx at load time.
    (ivy--flx-featurep): Turn variable into "thunk" function that only tries loading flx once when actually needed. All uses changed.
    (ivy-flx-cache): New escape hatch variable affording users control over the default flx cache used.
    (ivy--flx-cache): Turn variable into function that chooses between types of flx cache subject to ivy--completing-fname-p and ivy-flx-cache. All uses changed.
    (ivy-flx-limit): Improve docstring style.
    (ivy-toggle-fuzzy): Quote function symbols as such.

Fixes #2816.
Cc: @marcsaegesser

* ivy.el: Avoid registering eval-after-load hooks or unconditionally
loading flx at load time.
(ivy--flx-featurep): Turn variable into "thunk" function that only
tries loading flx once when actually needed.  All uses changed.
(ivy-flx-cache): New escape hatch variable affording users control
over the default flx cache used.
(ivy--flx-cache): Turn variable into function that chooses between
types of flx cache subject to ivy--completing-fname-p and
ivy-flx-cache.  All uses changed.
(ivy-flx-limit): Improve docstring style.
(ivy-toggle-fuzzy): Quote function symbols as such.

Fixes abo-abo#2816.
@marcsaegesser
Copy link

I did a little experimenting with this and one thing I noticed was that the ivy--completing-fname-p doesn't always detect file operations. For example find-file would use the filename cache but projectile-find-file would use the string cache. Setting ivy-flx-cache to 'file or 'string seemed to use the appropriate cache.

I'll try to play with this more tomorrow.

@basil-conto
Copy link
Collaborator Author

basil-conto commented Feb 27, 2021

For example find-file would use the filename cache but projectile-find-file would use the string cache

That's arguably a limitation of projectile-find-file for not specifying a category property like the built-in project-find-file does, but even then the current ivy--completing-fname-p is too naive because the category of project-find-file is actually project-file, not file.

So several parts of Ivy need improving for this to work more smoothly:

  • A standard way of querying or caching completion metadata. Currently ivy-update-candidates and ivy--completing-fname-p are two places where this is done in an ad-hoc way. It would be nice if ivy--minibuffer-metadata were used in a more reliable way.
  • A way to specify which completion categories constitute file name completion and when.
  • A way to specify which callers or collections (such as projectile-find-file) perform file name completion, even if they don't specify a category (although personally I would prefer to see those places patched for better integration with Emacs completion).

@marcsaegesser
Copy link

That all makes sense and if we could get that kind of functionality it would be great. Especially if there was consistency across all the other packages.

As for this particular PR. I played with it more this morning and the 'file and 'string cache settings seem to work just like I would expect. Using 'file recovers the flx-ido behavior that I was missing. The 'auto setting can be confusing for all the reasons you mentioned above.

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

Successfully merging this pull request may close these issues.

Possibly use flx-make-filename-cache rather than flx-make-string-cache
2 participants