-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
Create occur buffer in background on minibuffer exit #85
Comments
It would also be the perfect reason to why I wouldn't want to implement a |
Does |
It works 🥳 But it is not particularily useful this way since you will always get these buffers opening. The idea is more to have some kind of hidden buffer and only a single one for the last minibuffer session. This buffer could then be renamed and made visible by some |
Oh, and the slowdown is annoying if you implement it that way, since the marginalia annotators are executed always. In order to support this properly, only the un-annotated candidate list should be stored and then copied to an occur buffer and annotated by |
The occur buffer could be requested in grid view, which runs no annotator, and then be put in the correct initial view for the type when resurrected. |
We could also just store the information needed to make the buffer and not actually make it until it is time to ressurect. That's slightly more work, but probably better. |
Right!
This is what I would like! I would prefer the most efficient implementation, since this will be executed every time and in almost all cases it will be executed unnecessarily. If the resurrect feature would result in any noticeable slowdown, I probably wouldn't want to have this. |
How about the name |
Also, instead of storing the candidates and later making an occur buffer, we could store the minibuffer input and rerun the command. That feels more like what Ivy resume does. |
The version we discussed first would be an embark-occur after the fact, the last thing I proposed would be Embark-become after the fact, becoming the same command again. |
Maybe it even makes sense to have both. |
I like to have a different name for faster completion when typing it. Furthermore I think more distinct names are better.
Okay, this works too, and maybe this is even better, since you can always get an occur buffer later. This is basically ivy-resume for free? I would then vote to have this! If we are going with embark-occur, we could then simply name it embark-resume. |
Good point. |
Hm, this sounds more difficult as a command could prompt you multiple times, how would that be handled? |
I think it is more important to handle the common case of one completion. Does the default action even work if you have multiple completions? |
By ignoring the issue! This is what |
This is exactly how I would have "solved" this too! 👍 |
|
Yes, and by doing exactly the same we get |
Not multiple completions sessions but |
We could also consider solving this for real, recording the sequence of completing-read selections and injecting them in order. It wouldn't be difficult to do this I guess. But this discussion is orthogonal to the |
Good. I'll implement the cheap version later today. I think I'll call it |
Sounds great, thank you! |
This probably needs a little refinement to make it convenient: - Maybe keep a ring of the last 10 commands and inputs? - This records every command that uses the minibuffer, including, for example M-x. Maybe some commands should be skipped.
That was easy. It works, but maybe it needs a little design work.
Play around with it, let me know what you think. |
When repeating a session where you accepted the candidate the input isn't restored but the last submitted candidate. Is the idea of saving the candidates and restoring an occur buffer from it abandoned? I liked the idea that you just would need to switch to the buffer (no additional keybinding to remember). If it is to slow maybe the buffer could be created via an idle timer so it would be hard to notice and the exit wouldn't be slowed down. When the minibuffer session gets restored there might also be the problem that there is additional state (filtering method) that isn't restored which was the reason for the Selectrum issue I linked to. Maybe we could also combine both and the session could be restored from the occur buffer? Maybe this could even be a general feature for occur buffers?
That sounds cool, could be useful from time to time.
Not sure about that, the purpose for me would be to automatically remember the last thing I did and go back to it. |
One minor nit: When Emacs has just started, the "last-command-and-input" is nil and the current implementation tries to
I think there are two sensible fixes: ;; either emit a verbose message and exit:
(unless embark--last-command-and-input
(user-error "No last command"))
(pcase-let ...)
;; or silently do nothing by e.g. replacing pcase-let:
(when-let ((cmd (car embark--last-command-and-input))
(input (cdr embark--last-command-and-input)))
...) |
Yes, this would be better! @oantolin Any chance to make this work? This certainly needs some special casing! Using just the selected candidate is clearly not what is needed for a proper
No, I wouldn't like this. This sounds like an ugly hack for something simple (instead only the candidates should be stored quickly as a list). But I am in favor of abandoning this idea and instead focus on
Somehow I have the feeling that this is starting to overlap with the input history functionality, radian-software/selectrum#185 and minad/consult#137. I think we should get back to the drawing board instead of rushing to a solution. Maybe better to revert 622f6ea for now? Maybe this whole history management should go into Embark? |
Wow, differing timezones means there's lots of stuff for me to read now! 😄 |
Damn, I didn't even notice! Technically the candidate is the last input, depending on how you exit. For example,
I just meant that if you do @kljohann I noticed the issue with |
@minad Looks like a good path to take, just saving the input in post-command-hook is a great idea, and this works for selectrum, too :) I'm also for removing |
I see, could be nice to have it as an configureable option |
Yes, a separate package sounds better. (And I like the name
Yes, I'd say it is yet another type of history.
Agreed! I will remove
Agreed! |
Agreed. The injection is really is not much code at all, see |
I have not tried running the chronicle prototype, but having read it, does it really record the last input? You save the minibuffer contents in a post command hook, doesn't that hook also run after |
This is what I use in consult and it seems to work with icomplete and selectrum. I trust it based on that, but I am not 100% sure if there are not some edge cases. |
But it's tricky then, it depends on the fact that when you press |
Well, no, maybe that is what happens, and it doesn't so weird... |
No idea tbh, I also find it weird. I found this by experimentation. I cannot give you a sound answer, sorry! Maybe it really is broken and should be replaced by something better in consult too! |
Also, I didn't know |
@clemera @oantolin Regarding the history package, we seem to agree? So the plan is the following:
|
No, I just ran some experiments and I think it's a good solution. What actually seems to happen is that the post command hook does not run at all for the command that exits the minibuffer (the one bound to |
I agree with all steps in this plan. And I do like the name |
I like uchronia now since it is less generic than chronicle and we are basically moving back in the history and rewrite it 🤣 But besides that it looks like we have a plan. |
This reverts commit 622f6ea. The embark-repeat command was an experiment that failed because "minibuffer contents during the minibuffer exit hook" is not a good definition of "last input", since pressing RET can modify the minibuffer contents to match the selected candidate. As discussed in #85, we have decided to remove this experiment in favor of a better behaved and more featureful solution that will be made available as a separate package.
embark-repeat has been reverted. |
Uchronia is a neologism, but it sounds like a proper word. https://en.wikipedia.org/wiki/Alternate_history We could also go with ucronia but I would somehow miss the h then, since words like chronik, chronos etc are more familiar to me. Wikipedia:
|
I like the suggested names another option that came to mind: DeLorean |
I did not know ucronía was a Spanish word! It means "a reconstruction of history based on hypothetical data". You know, what? I like Plus, as you say, it's less generic than |
I think DeLorean should be reserved for something more sophisticated 🤣 |
This is exactly what I thought! |
I've made a small uchronia mode here: https://github.com/minad/uchronia/blob/main/uchronia.el. It works well, but I am still not 100% convinced that this is the right thing since it is very small, because of the split etc. Sorry for being so undecided... Now there is an alternative I would like to consider:
Basically I just propose a downstripped uchronia without the possibility to toggle between input/normal histories. And I think at this point it is just so small that I would rather put it into consult/embark itself! EDIT:
|
I don't remember exactly, I think it was considered because we thought both can be useful and it is convenient to toggle to the behaviour you are interested in. The candidate history is useful if you are looking for a candidate, the input history if you are looking for search results you previously had or want to do the same search (the candidate set might have changed). |
@clemera Yes, I agree that it is not totally useless. But still - I don't think the tradeoffs are really worth it. By Emacs standards, there is one history per command and my proposal is to just allow to define it as either input or candidate. I don't like the text property solution, I rather introduced separate variables now in (https://github.com/minad/uchronia/blob/4cf9d72cf673352080fe835324d8f35e2b9ee43f/uchronia.el). I am worried that the text property solution could potentially break other things. But maybe if I would embrace the text property solution, I would feel more convinced than I am now, since then we would at least not get the history variable duplication. But I argue that having only one history type covers like 99% of the use cases. You can always obtain the selected candidate again, by repeating with the input history and then making the selection. And then having a changed set of candidates - I guess this is such a rare use case. In Consult I also only have one history type per command and so do all Emacs commands. Do other packages also provide the functionality to toggle between the history types? All in all I am thinking if I would like to use such a toggler, and from my current feeling, I don't think I would. So it wouldn't pass this kind of check and I don't want to implement functionality of which I am not somehow convinced. Have you been in a situation where you would have wanted that functionality? I have not, but this is always easy to say since with the given restrictions it may also not have occurred to me that I could want something like this. |
The history commands don't care about the text properties but I agree that you never know in Emacs land, maybe someone relies on the fact the history doesn't has text properties by default but if this becomes relevant you could also remove it then. If you only allow input history for a command you are also dependent on the filtering method used, when you switch the framework or default completion you might still want to be able to access previous candidates. |
@clemera I will try the text property method, maybe I am more satisfied then since it may feel more "low cost", not introducing these auxiliary |
When discussing selectrum-repeat it occurred to me that it may be nice to have an automatic occur buffer created on minibuffer exit which would basically replace the functionality of such a command. This way you could always go back to your last results. What do you think?
The text was updated successfully, but these errors were encountered: