From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9571 invoked by alias); 7 Sep 2010 14:44:37 -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: 28237 Received: (qmail 18837 invoked from network); 7 Sep 2010 14:44:35 -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 15:44:18 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: PATCH: $ZLE_LINE_ABORTED Message-ID: <20100907154418.479be919@pwslap01u.europe.root.pri> In-Reply-To: References: <20100907114403.0e526e9c@pwslap01u.europe.root.pri> <20100907130231.49dcf737@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=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 07 Sep 2010 14:44:19.0172 (UTC) FILETIME=[2704E240:01CB4E9B] X-Scanned-By: MailControl A-10-90-03 (www.mailcontrol.com) on 10.71.0.123 On Tue, 07 Sep 2010 10:31:41 -0400 Greg Klanderman wrote: > Cool, I was just wanting something like this the other day.. is there > a way to capture the line when exiting zle with C-c as well? Hmm... I'm wondering if I put it in the right place. sendbreak can abort other things than the full line edit, and I already claimed that "this parameter is set by the line editor when an error occurs", which as you spotted isn't necessarily true. Index: Doc/Zsh/params.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/params.yo,v retrieving revision 1.60 diff -p -u -r1.60 params.yo --- Doc/Zsh/params.yo 14 Jun 2010 11:58:26 -0000 1.60 +++ Doc/Zsh/params.yo 7 Sep 2010 14:42:46 -0000 @@ -1448,6 +1448,13 @@ item(tt(ZDOTDIR))( The directory to search for shell startup files (.zshrc, etc), if not tt($HOME). ) +vindex(ZLE_LINE_ABORTED) +item(tt(ZLE_LINE_ABORTED))( +This parameter is set by the line editor when an error occurs. It +contains the line that was being edited at the point of the error. +`tt(print -zr -- $ZLE_LINE_ABORTED)' can be used to recover the line. +Only the most recent line of this kind is remembered. +) vindex(ZLE_REMOVE_SUFFIX_CHARS) vindex(ZLE_SPACE_SUFFIX_CHARS) xitem(tt(ZLE_REMOVE_SUFFIX_CHARS)) Index: Doc/Zsh/zle.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/zle.yo,v retrieving revision 1.87 diff -p -u -r1.87 zle.yo --- Doc/Zsh/zle.yo 6 Sep 2010 08:50:05 -0000 1.87 +++ Doc/Zsh/zle.yo 7 Sep 2010 14:42:46 -0000 @@ -2057,7 +2057,8 @@ tindex(send-break) item(tt(send-break) (^G ESC-^G) (unbound) (unbound))( Abort the current editor function, e.g. tt(execute-named-command), or the editor itself, e.g. if you are in tt(vared). Otherwise abort the parsing of -the current line. +the current line; in this case the aborted line is available in the shell +variable tt(ZLE_LINE_ABORTED). ) tindex(run-help) item(tt(run-help) (ESC-H ESC-h) (unbound) (unbound))( Index: Src/Zle/zle_main.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v retrieving revision 1.124 diff -p -u -r1.124 zle_main.c --- Src/Zle/zle_main.c 31 Jul 2010 19:36:54 -0000 1.124 +++ Src/Zle/zle_main.c 7 Sep 2010 14:42:46 -0000 @@ -1226,6 +1226,9 @@ zleread(char **lp, char **rp, int flags, zlecore(); + if (errflag) + setsparam("ZLE_LINE_ABORTED", zlegetline(NULL, NULL)); + if (done && !exit_pending && !errflag && (initthingy = rthingy_nocreate("zle-line-finish"))) { int saverrflag = errflag; -- 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, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom