Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Assorted Doc and Functions/Zle stuff
- X-seq: zsh-workers 18143
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: PATCH: Assorted Doc and Functions/Zle stuff
- Date: Mon, 27 Jan 2003 01:31:19 +0000
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
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 <langec@xxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author