From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4044 invoked from network); 5 May 2006 18:05:54 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.1 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 5 May 2006 18:05:54 -0000 Received: (qmail 38179 invoked from network); 5 May 2006 18:05:46 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 5 May 2006 18:05:46 -0000 Received: (qmail 3760 invoked by alias); 5 May 2006 18:05:23 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10221 Received: (qmail 3743 invoked from network); 5 May 2006 18:05:22 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 5 May 2006 18:05:22 -0000 Received: (qmail 34440 invoked from network); 5 May 2006 18:05:22 -0000 Received: from bes.cs.utk.edu (160.36.56.220) by a.mx.sunsite.dk with SMTP; 5 May 2006 18:05:20 -0000 Received: from localhost (localhost [127.0.0.1]) by bes.cs.utk.edu (Postfix) with ESMTP id 76647FCE2 for ; Fri, 5 May 2006 14:04:59 -0400 (EDT) Received: from bes.cs.utk.edu ([127.0.0.1]) by localhost (bes.cs.utk.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 12359-01 for ; Fri, 5 May 2006 14:04:58 -0400 (EDT) Received: from namib.cs.utk.edu (namib.cs.utk.edu [160.36.59.92]) by bes.cs.utk.edu (Postfix) with ESMTP id 56902FCD6 for ; Fri, 5 May 2006 14:04:58 -0400 (EDT) Received: by namib.cs.utk.edu (Postfix, from userid 10605) id 8022936F03; Fri, 5 May 2006 14:05:17 -0400 (EDT) Date: Fri, 5 May 2006 14:05:17 -0400 From: Chris Johnson To: zsh-users@sunsite.dk Subject: Re: print -s and History Expansion Message-ID: <20060505180517.GA31544@namib.cs.utk.edu> References: <20060502191022.GA30399@namib.cs.utk.edu> <200605022147.k42LlWC9003204@pwslaptop.csr.com> <20060504190631.GA29447@namib.cs.utk.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new with ClamAV and SpamAssasin at cs.utk.edu Peter Stephenson sent me the following 1.4K: > > commit-to-history() { > > # zsplit current command, expand result to all its quoted fields > > # ("f1" "f2" "f3"), prepend it with a command to make it written > > # to history, and then execute it. > > BUFFER=" print -s ${${(z)BUFFER}[@]}" > > zle accept-line > > } > > To avoid the extra command line execution I would use: > > commit-to-history() { > print -s ${(z)BUFFER} > BUFFER= > zle accept-line > } > > then there are no quoting problems. You still need the accept-line if > you plan on using what you've just added to the history immediately, > since otherwise the history isn't reread. However, it's now on an empty > buffer. I was able to get commit-to-history() { print -s ${(z)BUFFER} zle send-break } zle -N commit-to-history to work just fine. History expansion pulls in the split words of a just committed-to-history line just fine, and the command line stays displayed for reference. It's just like hitting ^C but adds the line to history, which is exactly what I was looking for. As far as your accept-line comment above, is the send-break widget not supposed to behave the way it is? The line is immediately available for history expansion (histverify is set): [cjohnson@namib] ~: echo one two three [cjohnson@namib] ~: echo !!:$ [cjohnson@namib] ~: echo three three -- Chris Johnson cjohnson@cs.utk.edu http://www.cs.utk.edu/~cjohnson