From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2808 invoked by alias); 2 Apr 2015 21:50:58 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20071 Received: (qmail 12848 invoked from network); 2 Apr 2015 21:50:45 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:subject:mime-version:content-type:in-reply-to:date:cc :sendlaterdate:message-id:references:to; bh=xSZFX7pKpRw9e38S4jSIraYBK/KgeckbpTQpcxaZaMw=; b=IxImxiE0aKOhKaYt/ZyhCUmM/SMiKxdB6UJhJZJ9Xs501mJ5+XZlapMZjKMAA6kTLh lg019P/4TTiQ+lvD+BkPKs21LruN3R3JIqJDamRHh2g6P9iyj10Ru1PX4crnJn4Xvc1F D9Mz2UC9E1BlNxiTxSxAsmkoW/rctIDRp2owoNiyQIYNf651UEana1P0qfeGY3p1VGVR Bhl1QoyE08ctwpSrVSzJxFkjl8jWxpm9zkcrAIk+yd6bs/ABvuhcfQJeXjX0Z+kvGw4W XNmurLV5iwVdH5GLrVO2U6K5krrKP5fl6BJehaHzTbekFQCvA2VyoFjyLL9PLDfgGmBh f84w== X-Received: by 10.70.48.68 with SMTP id j4mr2443907pdn.5.1428011441772; Thu, 02 Apr 2015 14:50:41 -0700 (PDT) Sender: Dave Yost From: Dave Yost X-Google-Original-From: Dave Yost Subject: Re: accept-line question Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_BF9BB963-27FF-4A52-87BB-C8D042ED43AA" In-Reply-To: Date: Thu, 2 Apr 2015 14:50:33 -0700 Cc: zsh-users@zsh.org Sendlaterdate: Thu, 2 Apr 2015 14:50:33 -0700 Message-Id: <81DADC6E-8DFD-4FB4-9E5D-F3F4CF1EDC07@yost.com> References: To: Bart Schaefer X-Mailer: Apple Mail (2.2070.6) --Apple-Mail=_BF9BB963-27FF-4A52-87BB-C8D042ED43AA Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 That works. I do want the executed command to be inserted into history. I searched the manual in vain for a way to do that. Any chance you could = illuminate further? Thanks Dave > Bart Schaefer wrote: >=20 > That's now how it works; accept-line in x1 does not run the command = and > then resume ZLE inside the x2 function, and even if it did it would = not > reprint the prompt in that way. >=20 > All "accept-line" does is assert that the buffer is now in its final > state, so that after ZLE finishes, the regular shell parser should = read > that line as the input. However, ZLE does not finish until the = current > active widget has also finished, so if accept-line is run again it can > still change the previously-accepted buffer. >=20 > You'd need something like this: >=20 > --- 8< --- > execute-now() { > zle -I > eval "$BUFFER" > BUFFER=3D > zle -R > } >=20 > zle -N execute-now > --- 8< --- >=20 > Then replace any "zle accept-line" with "zle execute-now". >=20 > However, *that* does not push the buffer onto the history stack, so = even > more may be necessary depending on what you intend to accomplish. >=20 > --=20 > Barton E. Schaefer >=20 >=20 >> On 2015-04-02, at 10:12 AM, Dave Yost wrote: >>=20 >> Sorry, that email was flawed. Let me try again. >>=20 >> Below, after sourcing a script, I type ^a then ^b. >> The ^a works as expected, but not the ^b >>=20 >> There must be something more I have to do besides =E2=80=9Caccept-line=E2= =80=9D. But what? >>=20 >> 0 Thu 9:59:38 yost DaveBook ~ >> 206 Z% cat accept-line-test.zsh=20 >> function xxx { >> BUFFER=3D"$1" >> zle -R >> zle accept-line >> } >>=20 >> function x1 { >> xxx echo\ 1 >> } >>=20 >> function x2 { >> xxx echo\ 2 >> xxx echo\ 3 >> } >>=20 >> zle -N x1 >> zle -N x2 >>=20 >> bindkey ^a x1 >> bindkey ^b x2 >> 0 Thu 9:59:47 yost DaveBook ~ >> 207 Z% source accept-line-test.zsh >> 0 Thu 9:59:54 yost DaveBook ~ >> 208 Z% echo 1 >> 1 >> 0 Thu 9:59:55 yost DaveBook ~ >> 209 Z% echo 3 >> 3 >> 0 Thu 9:59:59 yost DaveBook ~ >> 210 Z%=20 >>=20 >> The output I want from ^b is >>=20 >> 0 Wed 0:30:03 yost DaveBook ~ >> 240 Z% echo 2 >> 2 >> 0 Wed 0:30:04 yost DaveBook ~ >> 241 Z% echo 3 >> 3 >> 0 Wed 0:30:04 yost DaveBook ~ >> 242 Z%=20 >>=20 >> Extra credit: >>=20 >> Is there a way to write a function x3 that calls x2, such that I can = issue x3 from the command line get the result above instead of the = result below? >>=20 >> 0 Thu 10:04:32 yost DaveBook ~ >> 216 Z% x2 >> xxx:zle:3: widgets can only be called when ZLE is active >> xxx:zle:3: widgets can only be called when ZLE is active >> 1 Thu 10:05:55 yost DaveBook ~ >> 217 Z%=20 >>=20 >> Thanks >>=20 >=20 --Apple-Mail=_BF9BB963-27FF-4A52-87BB-C8D042ED43AA--