From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9287 invoked by alias); 7 Sep 2010 12:02:42 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28235 Received: (qmail 2785 invoked from network); 7 Sep 2010 12:02:39 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Tue, 7 Sep 2010 13:02:31 +0100 From: Peter Stephenson To: "Zsh Hackers' List" Subject: Re: PATCH: $ZLE_LINE_ABORTED Message-ID: <20100907130231.49dcf737@pwslap01u.europe.root.pri> In-Reply-To: References: <20100907114403.0e526e9c@pwslap01u.europe.root.pri> Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.6 (GTK+ 2.18.9; i686-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-OriginalArrivalTime: 07 Sep 2010 12:02:31.0405 (UTC) FILETIME=[8CBD31D0:01CB4E84] X-Scanned-By: MailControl A-06-00-00 (www.mailcontrol.com) on 10.68.0.112 On Tue, 7 Sep 2010 13:46:55 +0200 Nikolai Weibull wrote: > On Tue, Sep 7, 2010 at 12:44, Peter Stephenson > wrote: > > Here's what I think is a useful one-line change. =C2=A0If there's an > > error in the line editor, including ^G, the line being edited gets > > copied to the variable ZLE_LINE_ABORTED. >=20 > Does this include pressing ^C at the =E2=80=9Ccorrect A to B=E2=80=9D pro= mpt? 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=3D$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=3D$ZLE_LINE_ABORTED RBUFFER=3D elif [[ -n $ZLE_LINE_EDITED ]]; then LBUFFER=3D$ZLE_LINE_EDITED RBUFFER=3D fi } zle -N zle-line-finish zle -N recover-line --=20 Peter Stephenson 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, Cambr= idge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom