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

Re: PATCH: $ZLE_LINE_ABORTED



On Tue, 7 Sep 2010 13:46:55 +0200
Nikolai Weibull <now@xxxxxxxx> wrote:
> On Tue, Sep 7, 2010 at 12:44, Peter Stephenson
> <Peter.Stephenson@xxxxxxx> wrote:
> > Here's what I think is a useful one-line change. ÂIf there's an
> > error in the line editor, including ^G, the line being edited gets
> > copied to the variable ZLE_LINE_ABORTED.
> 
> Does this include pressing ^C at the âcorrect A to Bâ prompt?

No, that's all done after the line manager has exited.  It's a nuisance the
line doesn't appear in the history (or anywhere else), but it's an entirely
different problem.  Could save the last successfully edited line (whatever
happens to it later) in yet another variable...  Oh, actually, you can do
that yourself...  The following seems to handle both cases.  It would be
more logical to unset ZLE_LINE_ABORTED in zle-line-init.  This works for
the spelling correction part even without the last patch.

zle-line-finish() {
   typeset -g ZLE_LINE_EDITED=$BUFFER
   # This is only called on a successful exit, so we don't need
   # the last aborted line any more...
   unset ZLE_LINE_ABORTED
}
recover-line() {
   if [[ -n $ZLE_LINE_ABORTED ]]; then
     LBUFFER=$ZLE_LINE_ABORTED
     RBUFFER=
   elif [[ -n $ZLE_LINE_EDITED ]]; then
     LBUFFER=$ZLE_LINE_EDITED
     RBUFFER=
   fi
}
zle -N zle-line-finish
zle -N recover-line

-- 
Peter Stephenson <pws@xxxxxxx>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom



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