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

Consult-buffer & ephemeral buffers #73

Closed
tpeacock19 opened this issue Dec 17, 2020 · 9 comments
Closed

Consult-buffer & ephemeral buffers #73

tpeacock19 opened this issue Dec 17, 2020 · 9 comments

Comments

@tpeacock19
Copy link

I believe an earlier version of consult-buffer allowed narrowing to ephemeral/uninteresting buffers whose names start with a space.

Is there a reason this functionality was taken away? And if I'm mistaken (or confusing it with the function from the selectrum-wiki) can it be included in consult-buffer.

@minad
Copy link
Owner

minad commented Dec 17, 2020

Yes, this functionality has been taken away. Unfortunately it is not possible to implement it without dynamic candidate lists. This means if we want invisible buffers to be shown too, we would have to show them right away :(

Overall, I see these possibilities:

  1. Just use switch-to-buffer if you want to switch to an hidden buffer, I do that almost never, so this is what I am using. Do you often switch to invisible buffers?
  2. Use dynamic candidates as soon as that becomes a possibility (not yet possible, since selectrum misses support for dynamic candidates in its completing-read implementation). But this would also introduce a bit of additional complexity, so I am not sure if we want that.
  3. Always show invisible buffers (Not a good idea, I guess)
  4. Add some additional keybindings to consult-buffer which starts a new switch-buffer session etc. Basically hack around not having dynamic candidate lists available. I have an idea on how to implement this quickly. Maybe I try that.

What do you think?

@tpeacock19
Copy link
Author

I don't use it too commonly, but it helps when trying to troubleshoot issues some packages face when executing external programs such as curl. I also have switch-to-buffer on a keybinding and it will probably suffice.

I doubt there will be many that need the functionality; I was just curious as to why it had gone away.

great package by the way, really appreciate your work!

@minad
Copy link
Owner

minad commented Dec 17, 2020

Thank you! I tried to implement this quickly, but it is not easy to integrate it nicely with the current mechanism I use for narrowing to files, buffers etc. So given that the buffer switching to invisible buffers is pretty rare I am more inclined to keep things as is.

@minad
Copy link
Owner

minad commented Dec 17, 2020

For reference - here is the experiment https://github.com/minad/consult/tree/narrow-ephemeral. But it is very half-baked and does not integrate nicely with the functionality of consult--read, the consult wrapper around completing-read.

@minad
Copy link
Owner

minad commented Dec 17, 2020

Ping @clemera - this could be a possible hack to emulate dynamic candidates for consult-grep/consult-rg, basically installing an after-change-functions hook, start with an empty candidate list, after a few keypresses run grep, throw keyboard-quit and restart the completing-read session with run-at-time. Not sure if we want to go that route, it is also a bit like reimplementing parts of @oantolin's action mechanism from Embark.

@minad minad closed this as completed Dec 18, 2020
@clemera
Copy link
Contributor

clemera commented Dec 18, 2020

Bypassing completions styles seems better to me to get something like this, but maybe we don't need to call the process automatically in background. Having it under control which string to pass to the process and trigger it manually on the user side would also have its benefits, I think.

@minad
Copy link
Owner

minad commented Dec 18, 2020

@clemera You mean using a different completion style to hide/unhide invisible buffers. Interesting idea. I have no idea though on how this could be implemented. But then the question is why not use a custom completion style for narrowing too? Is it possible to locally change the completion style? But I think I recall either you or @oantolin saying that they prefer not to mess with the completion style.

The question if using such a keyboard-quit mechanism is a good idea is orthogonal to the other question - but I am also not convinced that it is a good idea and if we need the dynamism for consult-grep after all.

@clemera
Copy link
Contributor

clemera commented Dec 18, 2020

I experimented with changing the completion-style locally in this Selectrum issue and it seems that could work but there is still the problem that passing a string to the completion function will often prefilter you candidates based on prefix using all-completions, I plan to experiment to override all-completions so it passes the empty string when it gets passed the string for the completion, maybe that could work well enough.

@minad
Copy link
Owner

minad commented Dec 23, 2020

@tpeacock19 @clemera I implemented support for ephemeral buffers via the predicate, see bba8ac5

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

No branches or pull requests

3 participants