From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6826 invoked from network); 23 Aug 2004 01:13:05 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 23 Aug 2004 01:13:05 -0000 Received: (qmail 9159 invoked from network); 23 Aug 2004 01:12:59 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 23 Aug 2004 01:12:59 -0000 Received: (qmail 6691 invoked by alias); 23 Aug 2004 01:12:14 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7904 Received: (qmail 6681 invoked from network); 23 Aug 2004 01:12:14 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by 130.225.247.90 with SMTP; 23 Aug 2004 01:12:14 -0000 Received: (qmail 7062 invoked from network); 23 Aug 2004 01:11:01 -0000 Received: from unknown (HELO moonbase.zanshin.com) (167.160.213.139) by a.mx.sunsite.dk with SMTP; 23 Aug 2004 01:10:58 -0000 Received: from toltec.zanshin.com (toltec.zanshin.com [64.84.47.166]) by moonbase.zanshin.com (8.12.11/8.12.11) with ESMTP id i7N1Av4a024772 for ; Sun, 22 Aug 2004 18:10:57 -0700 Date: Sun, 22 Aug 2004 18:10:57 -0700 (PDT) From: Bart Schaefer Reply-To: zsh-users@sunsite.dk To: zsh-users@sunsite.dk Subject: Re: Tip of the day: previous command output In-Reply-To: <20040822205801.GM7841@ay.vinc17.org> Message-ID: References: <20040819085812.GL22962@localhost> <20040819164250.GA21575@spiegl.de> <20040820121202.GA31466@spiegl.de> <20040820145032.GH13530@ay.vinc17.org> <20040822205801.GM7841@ay.vinc17.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=-0.0 required=6.0 tests=BAYES_44 autolearn=no version=2.63 X-Spam-Hits: -0.0 On Sun, 22 Aug 2004, Vincent Lefevre wrote: > I mean that instead of expanding to filenames, one expands > to lines from $kept (but only those that match the pattern). Aha. So, akin to the case where you've provided a prefix, but instead you've provided a pattern. This is almost exactly the same as the _insert_kept widget, so I'll just edit it to include a test on the $WIDGET name. Like so: _insert_kept() { (( $#kept )) || return 1 local action zstyle -s :completion:$curcontext insert-kept action if [[ -n $action ]] then compstate[insert]=$action fi if [[ $WIDGET = *expand* ]] then compadd -U ${(M)kept:#${~words[CURRENT]}} else compadd -a kept fi } zle -C insert-kept-result complete-word _generic zle -C expand-kept-result complete-word _generic zstyle ':completion:*-kept-result:*' completer _insert_kept This obviously isn't as sophisticated as _expand, which knows how to deal with all sorts of things besides just patterns. You might also find that the call to compadd -U needs to have some of the -i -I -P -S options thrown in to avoid obliterating parts of the word that you didn't mean to obliterate; I've shown only the most simple solution.