From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29574 invoked by alias); 23 Aug 2015 21:45:54 -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: 20460 Received: (qmail 14409 invoked from network); 23 Aug 2015 21:45:52 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 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:cc:mime-version:content-type; bh=46kI97T/DMJ4UR45YO5niIkFNIyBD+nF9or/24+HbpA=; b=ABN6PMv5ganVsy0b7hVsMj7vAfGtfdnOZH9j7HyiKbLjC6L4UIrKy2iXKmED7ZluBb IdILp5gwI3PItifSZMOwFJdYjVzR4NXbAAIA9/YMOCz2Hlr+nkebFzvDA+b6vaPphPFh xiBa5hMPHXJv/xVVTwFcFW0qk/SI9xh5VlDbXdJCN44YVyAWdyriTMPPaLJNXyzHldvG VpvAW/HywxiVyO1L8hTWkZMm4uQnvtkGS/OZjvRlhDMBkOn87cNxjgzv3VZI11TjmtF/ JIADeILQ8vJ5h54dlGOvsHt5/UOIUTxIx4nKCDnH51oxZjhWP04pdga3dYEQ8EbetNHc ETqg== X-Gm-Message-State: ALoCoQn5U77q58UVXticcwFngZ82VippEMb5f4bwX49h8T83IE/TD8qo53hVKyv4klTuUOH6jeAm X-Received: by 10.60.76.4 with SMTP id g4mr17851707oew.81.1440366349905; Sun, 23 Aug 2015 14:45:49 -0700 (PDT) From: Bart Schaefer Message-Id: <150823144546.ZM8190@torch.brasslantern.com> Date: Sun, 23 Aug 2015 14:45:46 -0700 In-Reply-To: <40b4e87d.4fe9a6ca.55da2e85.b4319@prokonto.pl> Comments: In reply to rooom "ZLE: missing edit-buffer widget" (Aug 23, 10:35pm) References: <6ac3d5e6.2de49d01.55d4fc3c.9415a@prokonto.pl> <150819213302.ZM28036@torch.brasslantern.com> <794c2899.3f499b8c.55d5d132.18267@prokonto.pl> <40b4e87d.4fe9a6ca.55da2e85.b4319@prokonto.pl> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: ZLE: missing edit-buffer widget Cc: rooom MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Aug 23, 10:35pm, rooom wrote: } } I'm looking for widget "edit-line" or "edit-buffer" which move entire } command line into editor buffer regardless if it is single line or } multi-line construct. Look at the edit-command-line function in the distribution (probably findable with print -R $^fpath/edit-command-line(N) ) You want to do what that does, except skip invoking the editor on a file. So something like: print -Rz - "$PREBUFFER$BUFFER" zle send-break This is exactly what push-line-or-edit does except that if there is only one line of input it skips the send-break. (push-line-or-edit was implemented before user-defined widgets were available.) You could also write a little wrapper that's just a no-op if there is only one line: edit-if-multi-line () { if [[ -n "$PREBUFFER" ]]; then zle .push-line-or-edit fi return 0 } } For some reason the simple definition doesn't work: } } push-input-get-line () { } zle .push-input } zle .get-line } } You've discovered the reason push-line-or-edit exists. In a multi- line construct, the stuff entered at previous prompts (the value of $PREBUFFER) has already passed through both the editor and the shell parser and is only awaiting the completion of the parse to be run as shell input. In order to get it back and undo the parser state, push-input has to abort the whole parser loop, so get-line never has a chance to be executed.