From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25929 invoked by alias); 1 Apr 2015 15:39:55 -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: 20062 Received: (qmail 27301 invoked from network); 1 Apr 2015 15:39:53 -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,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=24mqCelBWpdBjINeol7+V4jfHs0xmdM+oIrvHqrW93M=; b=Kj+OV3AZd7WnsT8tASQ1zMQ80/Vcl8jo6nCZDPmQ5Q8fz+lL7kU9CWPeRKkfdAfiVN 9x4UhlGWY/mHEYFXAlQ8iEZx7Hmy8TwhdOzVTN5P04LvdYeTW+HD1Gel+LY3sFjIz0px UG3bI1GyPDE0RVQIAG5fPd0MQQiICSl1gRpvArPMQhPVy36FL0Rp8YclZMCLm3Igv/5p iv8nk6UCXR1ZPcnUNh+T8CCCkJSRduOxyPy5yQkuaz/Opf/7VQWocoWYUkFIW9E7Gkmt c1qzyJ/QTzjL2DP0/BzFrJwoHCv1FejS8RWQbuSQYW+0UMeNG/zvARWmt4Z/c525Yjro TlZw== X-Gm-Message-State: ALoCoQkH4afEBMS0IRKPW9SVQMlOWrLRAl5TxXlLEovVB3tBpQFN4jNPfmeY+4iPTdZXgowrkRBn X-Received: by 10.60.173.201 with SMTP id bm9mr5673889oec.34.1427902790798; Wed, 01 Apr 2015 08:39:50 -0700 (PDT) From: Bart Schaefer Message-Id: <150401083946.ZM30879@torch.brasslantern.com> Date: Wed, 1 Apr 2015 08:39:46 -0700 In-Reply-To: Comments: In reply to Dave Yost "accept-line question" (Apr 1, 12:36am) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: accept-line question MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii [redirecting to zsh-users as others may find this interesting] On Apr 1, 12:36am, Dave Yost wrote: } } There must be something more I have to do besides "accept-line". But what? } } I type control-a after sourcing my script, and it doesn't work as I expect. } } 0 Wed 0:29:51 yost DaveBook ~ } 238 Z% cat accept-line-test.zsh } function x1 { } BUFFER="$1" } zle -R } zle accept-line } } } } function x2 { } x1 echo\ 1 } x2 echo\ 2 } } } } zle -N xxx } } bindkey ^a xxx There is something missing here, because "zle -N xxx" creates a widget that calls the function "xxx", but you don't show a function named that. Also x2 as shown is calling itself recursively, which will eventually die of stack overflow. } The output I want is } } 0 Wed 0:30:03 yost DaveBook ~ } 240 Z% echo 1 } 1 } 0 Wed 0:30:04 yost DaveBook ~ } 241 Z% echo 2 } 2 } 0 Wed 0:30:04 yost DaveBook ~ } 242 Z% 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. 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. You'd need something like this: --- 8< --- execute-now() { zle -I eval "$BUFFER" BUFFER= zle -R } zle -N execute-now --- 8< --- Then replace any "zle accept-line" with "zle execute-now". However, *that* does not push the buffer onto the history stack, so even more may be necessary depending on what you intend to accomplish. -- Barton E. Schaefer