-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
Switching buffers is based on name, not buffer object #614
Comments
I see. That's an unfortunate interaction of the buffer renaming of EXWM buffers and the Consult preview. I see these solutions:
I am not eager in using buffer objects instead of the buffer names for multiple reasons. Your use case is a rather special edge case. It would be a little bit less efficient and slightly more complicated since we would have to attach the buffer object to the buffer name which is used as completion candidate. Previewing EXWM buffers has other issues anyway if you search through the Consult issue tracker (#178, #186, #204, #537). But the most serious issue is really that strings as completion candidates are ingrained in the design. For example Embark relies on the buffer names when acting on the candidates, e.g. |
I made a little test. I created a command which creates a "volatile" buffer, where the name changes over time. I cannot switch to such a buffer using the Emacs builtin (defun make-volatile-buffer ()
(interactive)
(let ((buffer (get-buffer-create "*volatile buffer*")))
(run-at-time 1 1 (lambda ()
(with-current-buffer buffer
(rename-buffer (format-time-string "*volatile buffer %H:%M:%S*"))))))) |
Fair enough. Disabling all previewing functionality might be the simplest path forward here, as I personally don't love that behavior. Though it'll still cause problems if an EXWM window is selected, and I want to go back to it, since the completions will have the old name.
I agree that it's a very common assumption, but I believe it's a poor one — though I also get that "completion" implies completion of text. Perhaps completion frameworks aren't a great tool for buffer switching, generally. Certainly, using a property of an object as a proxy for its identity is an inherently lossy proposition, even if it works in most cases. While my situation is certainly an edge case, I think this is more likely to occur than one might think. For example,
If you open |
Okay, if you don't like preview anyway, there is nothing wrong about disabling it and we have the problem solved here. You can do that globally by setting consult-preview-key to nil or per command via consult-customize. I am afraid I don't understand what you mean by "going back" where the completion context is still alive. Are you talking about recursive minibuffers?
I kind of disagree here. Of course the strings are a lossy representation but it somehow fits well to the spirit of Emacs which is an inherently text based system. But even if we decide to move away from the text representation here, it would be a fight against the established conventions. It would be possible to use the buffer objects instead and it would also be possible to teach Embark about it, but it is just not worth the effort given that these assumptions are so deeply ingrained. We would hit edge cases all over the place.
No, previewed files won't lead to this issue (at least they shouldn't - I didn't test this right now). Consult uses its own specially named buffers for previewed files. However the issue regarding uniquify exists if you open a file manually with embark-act while keeping the minibuffer alive (embark-quit-after-action=nil). Fortunately Embark offers multiple solutions to avoid this problem. You can either use embark-quit-after-action=t or you can configure Embark to restart the minibuffer, see embark-post-action-hooks. Note that the problem is even more pronounced for Embark actions like delete-file or kill-buffer, where you usually want the minibuffer command to be restarted such that the candidate list is updated and such that no stale candidates stick around. I think it is okay to close this as wontfix. If you disable preview, the issue you are commonly observing here shouldn't occur anymore and I believe that these other potential issues we've discussed here won't occur often. I mean this whole thing is not perfect, Emacs is a messy hackable system. If you have recursive minibuffers enabled you can always do whatever, executing some random code which messes up some nested state. If it works for common workflows it is good enough. |
Looking for some thoughts about how tractable it is to solve this. The situation is rather complicated due to all the parts involved.
My setup is:
New Issue · minad/consult — LibreWolf
, and the buffer name is*librewolf: New Issue · minad/consult*
.When LibreWolf is showing an image, the title includes both the resolution and the scaling, for example
81b3ac08def00915.png (PNG Image, 549 × 2434 pixels) — Scaled (45%)
.All of the above behaviors combine to produce frustration:
RET
.81b3ac08def00915.png (PNG Image, 549 × 2434 pixels) — Scaled (39%)
.RET
, it tries to switch to a buffer named81b3ac08def00915.png (PNG Image, 549 × 2434 pixels) — Scaled (45%)
.While there are a few approaches to solving this, I think the most correct is to have Consult either switch based on the buffer object (rather than the name), or make it completely general, by having completions include a lambda to invoke the action.
Based on a cursory reading of the code, it looks like the belief that the buffer is a string name is pretty deeply embedded into Consult.
Is this a thing that seems doable and reasonable? I guess my alternatives are disabling Vertico or going back to the iswitchb setup I've been using for 20 years.
The text was updated successfully, but these errors were encountered: