From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10032 invoked from network); 9 Sep 2004 21:38:37 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 9 Sep 2004 21:38:37 -0000 Received: (qmail 37469 invoked from network); 9 Sep 2004 21:38:30 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 9 Sep 2004 21:38:30 -0000 Received: (qmail 2004 invoked by alias); 9 Sep 2004 21:38:27 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20346 Received: (qmail 1988 invoked from network); 9 Sep 2004 21:38:27 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 9 Sep 2004 21:38:27 -0000 Received: (qmail 37010 invoked from network); 9 Sep 2004 21:37:28 -0000 Received: from moonbase.zanshin.com (64.84.47.139) by a.mx.sunsite.dk with SMTP; 9 Sep 2004 21:37:25 -0000 Received: from toltec.zanshin.com (toltec.zanshin.com [64.84.47.166]) by moonbase.zanshin.com (8.13.1/8.13.1) with ESMTP id i89LbKWv001012; Thu, 9 Sep 2004 14:37:21 -0700 Date: Thu, 9 Sep 2004 14:37:20 -0700 (PDT) From: Bart Schaefer Reply-To: zsh-workers@sunsite.dk To: Clint Adams cc: zsh-workers@sunsite.dk, 270632-submitter@bugs.debian.org Subject: Re: Bug#270632: zsh: Completion and spaces In-Reply-To: <20040909151552.GA21470@scowler.net> Message-ID: References: <20040908115321.GA2417@larve.net> <20040908180950.GC25987@scowler.net> <20040908194101.GD2775@larve.net> <20040908202633.GA3130@scowler.net> <20040908235639.GB6785@scowler.net> <20040909151552.GA21470@scowler.net> 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=none autolearn=no version=2.63 X-Spam-Hits: 0.0 On Thu, 9 Sep 2004, Clint Adams wrote: > ... how about this for the zsh/parameter solution? > [...] > +lastc="$history[$#history]" # Retrieve previous command That doesn't account for $NUMERIC, nor for "holes" in the history number sequence (the various "ignore" options) that can cause upwards movement to skip certain numbers. That's part of the reason that I didn't try to write this patch before ... The following is untested. Index: Functions/Zle/smart-insert-last-word --- smart-insert-last-word.~1.2.~ 2003-03-14 17:27:01.000000000 -0800 +++ smart-insert-last-word 2004-09-09 14:34:57.000000000 -0700 @@ -1,7 +1,8 @@ # smart-insert-last-word # Inspired by Christoph Lange from zsh-users/3265; # rewritten to correct multiple-call behavior after zsh-users/3270; -# modified to work with copy-earlier-word after zsh-users/5832. +# modified to work with copy-earlier-word after zsh-users/5832; +# tweaked for auto-suffix-removal behavior after zsh-users/7841. # # This function as a ZLE widget can replace insert-last-word, like so: # @@ -41,7 +42,7 @@ # (($+_ilw_hist)) || integer -g _ilw_hist _ilw_count _ilw_cursor _ilw_lcursor integer cursor=$CURSOR lcursor=$CURSOR -local lastcmd pattern numeric=$NUMERIC +local lastc lastcmd pattern numeric=$NUMERIC # Save state for repeated calls if (( HISTNO == _ilw_hist && cursor == _ilw_cursor )); then @@ -64,11 +65,19 @@ _ilw_hist=$HISTNO _ilw_count=$NUMERIC -zle .up-history || return 1 # Retrieve previous command -lastcmd=( ${${(z)BUFFER}:#\;} ) # Split into shell words -zle .down-history # Return to current command -CURSOR=$cursor # Restore cursor position -NUMERIC=${numeric:-1} # In case of fall through +if zmodload -i zsh/parameter +then + lastc=( ${(kOn)history} ) # Get all history numbers + (( $#lastc > NUMERIC )) || return 1 # Check for overflow + lastc=$history[$lastc[NUMERIC]] # Remember previous command +else + zle .up-history || return 1 # Check for overflow + lastc=$BUFFER # Remember previous command + zle .down-history # Return to current command +fi +lastcmd=( ${${(z)lastc}:#\;} ) # Split into shell words +CURSOR=$cursor # Restore cursor position +NUMERIC=${numeric:-1} # In case of fall through (( NUMERIC > $#lastcmd )) && return 1