Adapt bash readline operate-and-get-next
Skip Montanaro
skip at pobox.com
Tue Aug 19 08:45:45 EDT 2014
On Tue, Aug 19, 2014 at 3:44 AM, Lele Gaifax <lele at metapensiero.it> wrote:
>> Does your position in the history disappear if you
>> operate_and_get_next(), then modify the next recalled input line?
>
> Not sure what you mean with "disappear": basically o-a-g-n "accepts" the
> current line (that is, "executes" it, and this means it gets pushed at
> the top of history), regardless you edited or not, then fetches the
> following input line from the history and presents it to you.
>
> Given these lines in the history:
>
> >>> a=10
> >>> a-=1
> >>> print(a)
> 9
Suppose you have the above, as you indicated. Ctl-P your way back to
the a=10 line. Press Ctl-O. It executes that assignment and fills the
input buffer with "a-=1". Instead of just pressing Ctl-O, type a "1"
first, changing the input buffer to "a-=11". *Now* press Ctl-O. I
assume it executes that statement. You've edited the line, however.
Does it present you with the print statement or not?
I guess I could have answered my own question using bash:
firefly% a=10
firefly% a='a'
firefly% echo $a
a
firefly% a=10
firefly% a='b'
firefly% echo $a
b
The second batch of three lines were executed from history with this
key sequence:
Ctl-P Ctl-P Ctl-P Ctl-O DEL DEL b ' Ctl-O RET
That's pretty cool. Even if I never live to see it in Python (I'm
still using 2.7), I will definitely start using it in bash. :-)
Skip
More information about the Python-list
mailing list