-
-
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
Update relevant index in consult-history #83
Conversation
This looks to complicated for my taste what you are doing here. But I agree that it is a good idea to do this. |
0798664
to
88fde66
Compare
a1a5b54
to
e04e266
Compare
@leungbk After looking at your PR again I got my doubts if this is the correct thing to do: Maybe it makes more sense to instead push the selected element to the beginning of the history, either removing the item at the old position or keeping it? This would also simplify things, since no index updating would be needed. Furthermore I wonder why the history is not updated automatically when executing the command, such that we would not have to do anything here. What do you think? For now I added the |
The closest analogue in If we look at the behavior of the If I have echo a
echo b
echo c
echo a in my history, then selecting Back when I wrote the equivalent of this PR for Counsel, I did the following to ensure that the index used by the first invocation of I can't write any equivalent here since I don't think there's a way of retrieving the This is only tangentially related to what I sought to do with this PR though, which was to make the
It's not clear to me how your suggestion of splicing the selected candidate without otherwise doing any index manipulation will give the
It is already updated in the way that you describe without this PR. To assuage your concerns about (when (memq index-variable '(eshell-history-index
comint-input-ring-index))
(setf (symbol-value index-variable) candidate-index)) Again, the What do you think? |
Oh, that's a long argument here and I must admit that I have a hard time to follow. Could you explain to me without assuming any prior knowledge on how all these histories work and on how counsel works etc, why you would want to reassign the index, if the current behavior already pushes the last selected element to the top of the history? Could you explain what the purpose of this index is after all? Under which circumstances is this index shifted? My point is that by changing the index, we are somehow destroying the reference point of the history and I feel this goes a bit against the spirit of having consult-history as a random access interface, since we also get this side-effect on top. And then you say some things that there are effects which wipe out the index reassignment of this PR. Why are we doing this then? |
e04e266
to
b65b404
Compare
I am reading again reading your very first comment in this PR:
So you want to sequentially replay the history somehow from the last selected history item? Is this the idea? I think I originally misunderstood the purpose of this PR. |
Yes, that's the sole purpose of this PR.
The latest version of this PR assuages this concern.
|
@leungbk Ok, I get this now. You select the index and then you press C-c C-x to execute the history step by step from this point. The index replay does not make much sense for the minibuffer though, therefore you removed it there? So I guess it should work like this:
Could you please add a bit more documentation to the customizable variable and the command such that it is clear what is going on and how the user can configure the behavior? But besides that I think your PR is already along these lines? |
873db15
to
8201954
Compare
Done.
Done. |
Great! Thanks! Why not do the same for the term-mode? |
I don't know how to anything in |
No, this is good enough for me. I just wanted to make sure that it is intentional. |
8201954
to
b9e1226
Compare
If the eshell history contains > echo a > echo b > echo c then after using consult-history to select 'echo a' and subsequently submitting 'echo a' to the prompt, the user should be able to press C-c C-x to retrieve 'echo b'. This PR performs the necessary reassignments.
b9e1226
to
66137ca
Compare
Are you finished here? Then I can pull this. |
Yeah, there was something I missed earlier, but it should be ready to go
now. Thanks.
…On Tue, Dec 22, 2020 at 11:33 AM Daniel Mendler ***@***.***> wrote:
Are you finished here? Then I can pull this.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#83 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AG65GOXWYM7LOSNI6XNHFU3SWDX6XANCNFSM4VERP24Q>
.
|
@leungbk Now, I found another issue - while we are not sorting, we are deleting duplicates! I am once again doubtful if this is the right thing to do, since this will totally mess up the history replay and the user will wonder in the end what is going on since the candidate view does not match the real history. Now I am not sure how to proceed. I see the following options:
Note that I pushed a few minor adjustments to this branch. |
My problem with this whole thing is that the linear history with duplicates and completing-read selection does not work well together. Assume you have a long history and you want to select the starting point of a command sequence, then you basically have to search the starting point via scrolling, if the start command appears at multiple places and you only know depending on the context if this is the real starting point you are looking for. |
I didn't address this before since I didn't think anyone would want to see duplicates. But for someone who does want to see them, something like your option 3) above seems fine to me if in the case where we keep duplicates, we also label each candidate with its index in the display to disambiguate between the duplicates we keep, similar to how |
Well, if I want replay I want for sure see the duplicates - otherwise I really don't understand the point here. But as I argued, completing-read is not the best fit to select a starting point of a list of candidates, it suffers from the same problems as |
If for a particular candidate, either
then everything works as expected. In this case, we are satisfied. In the other case, where the candidate is duplicated and you need to go back to an earlier occurrence, then your options are to
I do not see a circumstance in which this PR, if it is adjusted to allow duplicate entries for
I don't disagree that it's not the perfect interface, but in the happy case for
Since we're not doing any index adjustment for the minibuffer case, it might make sense to separate the portions relating to minibuffer history into a separate |
Yes, I agree. But this basically holds for every feature you could possibly implement as long as it doesn't degrade existing features. Therefore this is not useful criterion on which one can decide if this is worth it or not. I am not saying no here, I am just stating some objections and I would prefer if we think a bit more about it - maybe we come up with something better? Generally I would like to avoid feature creep in this project. But the project is still young, so we have to find a way and some guidelines on what makes sense and what doesn't (also see the wishlist discussions).
I would like to avoid this, since it is nice to have this context-dependent command and a single history keybinding. One could bind the minibuffer to the same command only in the minibuffer, though. But I don't see the minibuffer detection adding significantly to the complexity. |
@oantolin Do you have an opinion on the index adjustment, since the history command is originally based on your https://github.com/oantolin/completing-history? |
One option to show the relevant context for duplicates would be to offer opt-in previewing with a customizable amount of future entries to show. echo a
echo b
[...]
echo a
echo z With duplicate occurrences of echo a
echo b
# (more if the context defcustom is high) or similarly for the other occurrence of |
Sorry, no opinion at all. This is functionality I've never used, never been aware existed and never wanted. 🤷 |
@oantolin Okay, thank you! |
@minad What do you think about my suggestion above?
|
@leungbk Yes, I've seen it, but it makes things more complicated. The same with |
I would like to show the future context within the |
I would find that a bit weird, but it is certainly a possibility - I am not sure though. I don't think the additional complexity is justified tbh. This feature has to pull its weight or we shouldn't add it. |
To do this, we change the shape of
consult-mode-histories
and defineconsult--label-and-delete-dups
.This allows
C-c C-x
to work withineshell-mode
.If my Eshell history has
then after I select
echo a
with consult-history and pressRET
, then I can fetchecho b
usingC-c C-x
, without having to start a newconsult-history
session or mashingM-p
.