Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: vared -h question



(Accessing previous lines entered with vared in a loop):

Peter Stephenson wrote:
> The answer should be to stick `print -s $cmd' as the first command inside
> the loop, as well as adding the -h flag to vared.  Embarassingly (at least
> in the latest 3.1.6++), that doesn't work properly because you don't get
> the most recent command in the history, though you do get the second most
> recent --- i.e. the third time round the while-loop you'll be able to
> re-edit what you entered on the first.

This doesn't look very nice to fix (heard that before?).  The basic problem
is that history isn't active, so the `current' history line is the one
before, which isn't usually used for history.  The choices I've thought of
so far include:

- Some hack-up in zleread() to add a bogus `current' history line, then
delete it at the end.  Yuck.
- Turn on the history mechanism if it isn't already.  That would in
principal get the line automatically entered into the history list, which
is logically consistent.  However, I tentatively tried inserting an
hbegin()/hend() into zleread() under these circumstances and it crashed
in remember_edits() because the entry had nulls in it, so this would need
more work.  How much more work isn't clear because the history code and the
editing code have never been well integrated and have gathered separate
encrustations.
- Let someone else fix it.

I'm still inclining to the third possibility, but I'll keep thinking about
it, too.

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx>



Messages sorted by: Reverse Date, Date, Thread, Author