From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8196 invoked from network); 27 Jan 2003 01:31:29 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 27 Jan 2003 01:31:29 -0000 Received: (qmail 16029 invoked by alias); 27 Jan 2003 01:31:20 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 18143 Received: (qmail 16022 invoked from network); 27 Jan 2003 01:31:20 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 27 Jan 2003 01:31:20 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [4.46.181.248] by sunsite.dk (MessageWall 1.0.8) with SMTP; 27 Jan 2003 1:31:19 -0000 Received: (from schaefer@localhost) by candle.brasslantern.com (8.11.6/8.11.6) id h0R1VKs24304 for zsh-workers@sunsite.dk; Sun, 26 Jan 2003 17:31:20 -0800 From: "Bart Schaefer" Message-Id: <1030127013119.ZM24303@candle.brasslantern.com> Date: Mon, 27 Jan 2003 01:31:19 +0000 X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.dk Subject: PATCH: Assorted Doc and Functions/Zle stuff MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Patch for several things, some of which I've had sitting around for quite a while: - Fix typo in compsys example documentation - Alphabetize widget entries in contrib.yo and put their index entries in the Editor Functions index (rather than the Functions index) - Make copy-earlier-word and smart-insert-last-word play together better (see users/5832) - Fix for toggle mode of predict-on (users/5828) diff -ru -x CVS ../zsh-forge/current/Doc/Zsh/compsys.yo ./Doc/Zsh/compsys.yo --- ../zsh-forge/current/Doc/Zsh/compsys.yo Sat Aug 17 09:53:37 2002 +++ ./Doc/Zsh/compsys.yo Wed Oct 2 01:35:51 2002 @@ -2488,7 +2488,7 @@ completers are only used when completion is attempted a second time on the same string, e.g.: -example(zstyle ':completion:*' completer ' +example(zstyle -e ':completion:*' completer ' if [[ $_last_try != "$HISTNO$BUFFER$CURSOR" ]]; then _last_try="$HISTNO$BUFFER$CURSOR" reply=(_complete _match _prefix) diff -ru -x CVS ../zsh-forge/current/Doc/Zsh/contrib.yo ./Doc/Zsh/contrib.yo --- ../zsh-forge/current/Doc/Zsh/contrib.yo Thu Jan 16 10:36:20 2003 +++ ./Doc/Zsh/contrib.yo Sun Jan 26 13:44:33 2003 @@ -386,6 +386,23 @@ zle -N $widget bash-$widget done) ) +tindex(copy-earlier-word) +item(tt(copy-earlier-word))( +This widget works like a combination of tt(insert-last-word) and +tt(copy-prev-shell-word). Repeated invocations of the widget retrieve +earlier words on the relevant history line. With a numeric argument +var(N), insert the var(N)th word from the history line; var(N) may be +negative to count from the end of the line. + +If tt(insert-last-word) has been used to retrieve the last word on a +previous history line, repeated invocations will replace that word with +earlier words from the same line. + +Otherwise, the widget applies to words on the line currently being edited. +The tt(widget) style can be set to the name of another widget that should +be called to retrieve words. This widget must accept the same three +arguments as tt(insert-last-word). +) tindex(cycle-completion-positions) item(tt(cycle-completion-positions))( After inserting an unambiguous string into the command line, the new @@ -571,13 +588,14 @@ bindkey '^X^Z' predict-on bindkey '^Z' predict-off) ) -findex(smart-insert-last-word) +tindex(smart-insert-last-word) item(tt(smart-insert-last-word))( This function may replace the tt(insert-last-word) widget, like so: example(zle -N insert-last-word smart-insert-last-word) -With a numeric prefix, it behaves like tt(insert-last-word), except that +With a numeric prefix, or when passed command line arguments in a call +from another widget, it behaves like tt(insert-last-word), except that words in comments are ignored when tt(INTERACTIVE_COMMENTS) is set. Otherwise, the rightmost ``interesting'' word from the previous command is @@ -592,20 +610,6 @@ zstyle :insert-last-assignment match '[[:alpha:]][][[:alnum:]]#=*' bindkey '\e=' insert-last-assignment) ) -findex(copy-earlier-word) -item(tt(copy-earlier-word))( -This widget works like a combination of tt(insert-last-word) and -tt(copy-prev-shell-word). Repeated invocations of the widget retrieve -earlier words on the relevant history line. With a numeric argument -var(N), insert the var(N)th word from the history line; var(N) may be -negative to count from the end of the line. - -If tt(insert-last-word) has been used to retrieve the last word on a -previous history line, repeated invocations will replace that word with -earlier words from the same line. - -Otherwise, the widget applies to words on the line currently being edited. -) enditem() subsect(Styles) @@ -766,6 +770,19 @@ these widgets display a message below the prompt when the predictive state is toggled. This is most useful in combination with the tt(toggle) style. The default does not display these messages. +) +kindex(widget, widget style) +item(tt(widget))( +This style is similar to the tt(command) style: For widget functions that +use tt(zle) to call other widgets, this style can sometimes be used to +override the widget which is called. The context for this style is the +name of the calling widget (em(not) the name of the calling function, +because one function may be bound to multiple widget names). + +example(zstyle :copy-earlier-word widget smart-insert-last-word) + +Check the documentation for the calling widget or function to determine +whether the tt(widget) style is used. ) enditem() diff -ru -x CVS ../zsh-forge/current/Functions/Zle/copy-earlier-word ./Functions/Zle/copy-earlier-word --- ../zsh-forge/current/Functions/Zle/copy-earlier-word Tue Mar 5 08:33:21 2002 +++ ./Functions/Zle/copy-earlier-word Sun Jan 26 13:48:31 2003 @@ -5,15 +5,20 @@ # and start from the word before last. Otherwise, it will operate on # the current line. +emulate -L zsh + if (( ${NUMERIC:-0} )); then - # 1 means last word, 2 second last, etc. - (( __copyword = ${NUMERIC:-0} )) + # 1 means last word, 2 second last, etc. + (( __copyword = ${NUMERIC:-0} )) + zstyle -s :$WIDGET widget __copywidget elif [[ -n $__copyword && $WIDGET = $LASTWIDGET ]]; then (( __copyword-- )) elif [[ $LASTWIDGET = *insert-last-word ]]; then __copyword=-2 + __copywidget=$LASTWIDGET else __copyword=-1 + zstyle -s :$WIDGET widget __copywidget fi -zle .insert-last-word 0 $__copyword +zle ${__copywidget:-.insert-last-word} 0 $__copyword diff -ru -x CVS ../zsh-forge/current/Functions/Zle/predict-on ./Functions/Zle/predict-on --- ../zsh-forge/current/Functions/Zle/predict-on Mon Sep 4 14:13:09 2000 +++ ./Functions/Zle/predict-on Sat Jan 25 12:18:23 2003 @@ -55,7 +55,8 @@ ((++CURSOR)) else LBUFFER="$LBUFFER$KEYS" - if [[ $LASTWIDGET == (self-insert|magic-space|backward-delete-char) ]] + if [[ $LASTWIDGET == (self-insert|magic-space|backward-delete-char) || + $LASTWIDGET == (complete-word|accept-*|predict-*) ]] then if ! zle .history-beginning-search-backward then diff -ru -x CVS ../zsh-forge/current/Functions/Zle/smart-insert-last-word ./Functions/Zle/smart-insert-last-word --- ../zsh-forge/current/Functions/Zle/smart-insert-last-word Thu Sep 7 21:15:45 2000 +++ ./Functions/Zle/smart-insert-last-word Sun Jan 26 12:01:10 2003 @@ -1,6 +1,7 @@ # smart-insert-last-word # Inspired by Christoph Lange from zsh-users/3265; -# rewritten to correct multiple-call behavior after zsh-users/3270. +# rewritten to correct multiple-call behavior after zsh-users/3270; +# modified to work with copy-earlier-word after zsh-users/5832. # # This function as a ZLE widget can replace insert-last-word, like so: # @@ -50,14 +51,24 @@ NUMERIC=1 _ilw_lcursor=$lcursor fi +# Handle the up to three arguments of .insert-last-word +if (( $+1 )); then + if (( $+3 )); then + ((NUMERIC = -($1))) + else + ((NUMERIC = _ilw_count - $1)) + fi + (( NUMERIC )) || LBUFFER[lcursor+1,cursor+1]='' + numeric=$((-(${2:--numeric}))) +fi _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 +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 (( NUMERIC > $#lastcmd )) && return 1