summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2000-05-08 08:58:37 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2000-05-08 08:58:37 +0000
commit38bb84d97577fdfc359ba0261daea730a0cfb405 (patch)
tree15222079b6024fea1a2d7636ca023bb2672196e2
parentbedd4cf2c57a89bec8bd98e6ed65082164b69d93 (diff)
downloadzsh-38bb84d97577fdfc359ba0261daea730a0cfb405.tar.gz
zsh-38bb84d97577fdfc359ba0261daea730a0cfb405.zip
11194, 11200, 11214
-rw-r--r--ChangeLog14
-rw-r--r--Completion/Base/_arguments2
-rw-r--r--Completion/Core/compinstall93
-rw-r--r--Completion/User/_configure19
-rw-r--r--Doc/Zsh/expn.yo10
-rw-r--r--Etc/NEWS2
-rw-r--r--Src/subst.c8
7 files changed, 106 insertions, 42 deletions
diff --git a/ChangeLog b/ChangeLog
index 9451c75bf..d79d9ec01 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -37,6 +37,20 @@
* 11216: Doc/Zsh/builtins.yo, Src/loop.c: small doc fix and AIX
dependency fix
+2000-05-05 Peter Stephenson <pws@cambridgesiliconradio.com>
+
+ * 11214: Completion/Core/compinstall: remember file in
+ filename style for :compinstall context; make null matchers
+ more obvious.
+
+ * 11200: Src/subst.c, Doc/Zsh/expn.yo: backout change that
+ ${foo/$subst/repl} would allow # and % anchors inside $subst.
+
+ * Andrej Borsenkow: 11194: Completion/Base/_arguments,
+ Completion/User/_configure: use globsubst for substitutions
+ via -s option to _arguments and hence use (#s) for anchor
+ in _substitutions from _configure.
+
2000-05-05 Tanaka Akira <akr@zsh.org>
* 11213: Completion/User/_cvs: don't complete files which is
diff --git a/Completion/Base/_arguments b/Completion/Base/_arguments
index 68f187af4..195f03f82 100644
--- a/Completion/Base/_arguments
+++ b/Completion/Base/_arguments
@@ -82,7 +82,7 @@ if (( long )); then
# ... and add "same" options
while (( $#sopts )); do
- lopts=( $lopts ${lopts/$sopts[1]/$sopts[2]} )
+ lopts=( $lopts ${lopts/$~sopts[1]/$sopts[2]} )
shift 2 sopts
done
diff --git a/Completion/Core/compinstall b/Completion/Core/compinstall
index 1c931c808..9c6e8f9de 100644
--- a/Completion/Core/compinstall
+++ b/Completion/Core/compinstall
@@ -27,9 +27,8 @@ typeset startline='# The following lines were added by compinstall'
typeset endline='# End of lines added by compinstall'
typeset ifile line fpath_line
typeset -A styles
-typeset match mbegin mend matchers warn_unknown warn_old warn_comment
+typeset match mbegin mend warn_unknown warn_old warn_comment
integer lines_found
-matchers=()
#
# Check the user's .zshrc, if any.
@@ -48,12 +47,17 @@ __ci_test_ifile() {
}
local foundold=false
-ifile=${ZDOTDIR:-~}/.zshrc
-if __ci_test_ifile ${ZDOTDIR:-~}/.compinstall; then
- ifile=${ZDOTDIR:-~}/.compinstall
- foundold=true
-elif __ci_test_ifile $ifile; then
+if zstyle -s :compinstall filename ifile &&
+ __ci_test_ifile $ifile; then
foundold=true
+else
+ ifile=${ZDOTDIR:-~}/.zshrc
+ if __ci_test_ifile ${ZDOTDIR:-~}/.compinstall; then
+ ifile=${ZDOTDIR:-~}/.compinstall
+ foundold=true
+ elif __ci_test_ifile $ifile; then
+ foundold=true
+ fi
fi
local newifile=$ifile
@@ -113,7 +117,8 @@ ${match[3]}"
warn_comment=1
elif [[ $line != [[:blank:]]# &&
$line != [[:blank:]]#'autoload -U compinit' &&
- $line != [[:blank:]]#compinit ]]; then
+ $line != [[:blank:]]#compinit &&
+ $line != [[:blank:]]#zstyle[[:blank:]]#:compinstall* ]]; then
warn_unknown="${warn_unknown:+$warn_unknown
}$line"
fi
@@ -834,6 +839,16 @@ __ci_toggle_matcher() {
if [[ ${${(P)1}[$2]} = ' ' ]]; then
# toggle on
eval "${1}[$2]=$2"
+ if [[ $1 = n* ]]; then
+ # no matcher turned on, turn off the others
+ c_list[$2]=' '
+ C_list[$2]=' '
+ p_list[$2]=' '
+ s_list[$2]=' '
+ else
+ # something else turned on, turn off no matcher
+ n_list[$2]=' '
+ fi
return 0
else
# toggle off
@@ -859,10 +874,11 @@ __ci_do_matchers() {
# ?_list say whether the four possible matchers are set for passes 1,
# 2, 3, 4, in an easy-to-read manner, i.e. the Nth part of the string
# is either N (on) or space (off).
- c_list=" "
- C_list=" "
- p_list=" "
- s_list=" "
+ n_list=" " # null completion, i.e. standard
+ c_list=" " # case match one way
+ C_list=" " # case match both ways
+ p_list=" " # partial word completion
+ s_list=" " # substring completion
# $pws_seps gives the separators used for partial-word completion
# by element of the matcher list; these can be edited separately.
pw_seps=('._-' '._-' '._-' '._-')
@@ -870,7 +886,8 @@ __ci_do_matchers() {
# See what's in the matcher initially. If these have been edited,
# we're in trouble, but that's pretty much true of everything.
- for (( eltcnt = 1; eltcnt <= 4; eltcnt++ )); do
+ for (( eltcnt = 1; eltcnt <= $#mlist; eltcnt++ )); do
+ [[ -z $mlist[$eltcnt] ]] && n_list[$eltcnt]=$eltcnt
[[ $mlist[$eltcnt] = *"m:{a-z}={A-Z}"* ]] && c_list[$eltcnt]=$eltcnt
[[ $mlist[$eltcnt] = *"m:{a-zA-Z}={A-Za-z}"* ]] && C_list[$eltcnt]=$eltcnt
# For partial word stuff, we use backreferences to find out what
@@ -895,11 +912,13 @@ the string on the command line with a possible match, as listed below.
A list of different matchers can be given; each is tried until at least
one possible completion is found. The numbers given below show what is
included in each element of the list; everything for 1 is tried at the same
-time, and if necessary everything for 2, etc. If nothing is set for element
-1, it will do ordinary matching, so special matching won't kick until
-element 2. Elements from 1 to 4 can be set; empty trailing elements will
-be removed, and if nothing is set, the style will not be set.
+time, and if necessary everything for 2, etc. If no matcher is set
+ordinary completion will be done at that point. Elements from 1 to 4 can
+be set; empty trailing elements will be removed, and if nothing is set, the
+style will not be set.
+n. ($n_list)\
+ No matchers; you may want to try this as the first choice.
c. ($c_list)\
Case-insensitive completion (lowercase matches uppercase)
C. ($C_list)\
@@ -918,7 +937,7 @@ q. Return without saving.
read -k key'?--- Hit selection --- '
print
- if [[ $key = [cCpPsS] ]]; then
+ if [[ $key = [nNcCpPsS] ]]; then
while true; do
read -k key2'?Set/unset for element number (1234)? '
print
@@ -928,6 +947,10 @@ q. Return without saving.
fi
case $key in
+ [nN]) __ci_toggle_matcher n_list $key2
+ if [[ $n_list[$key2] != ' ' ]]; then
+ fi
+ ;;
c) __ci_toggle_matcher c_list $key2
;;
C) __ci_toggle_matcher C_list $key2
@@ -984,7 +1007,7 @@ terminators to be matched in this way? (y/n) [n] "
elt="${elt:+$elt }l:|=* r:|=*"
fi
fi
- [[ -n $elt ]] && lastnz=$eltcnt
+ [[ -n $elt || $n_list[$eltcnt] != ' ' ]] && lastnz=$eltcnt
mlist[$eltcnt]=$elt
done
@@ -1657,6 +1680,13 @@ zstyle ${(qq)stylevals[1]} $style $stylevals[2]"
done
fi
+if ! read -q key"?Save new settings to $ifile? "; then
+ print "Enter a different filename (~ will be expanded), or return to abort:"
+ ifile=
+ vared -ch -p 'file> ' ifile
+ ifile=${~ifile}
+fi
+
local tmpout=${TMPPREFIX:-/tmp/zsh}compinstall$$
#
# Assemble the complete set of lines to
@@ -1668,17 +1698,24 @@ compinit"
[[ -n $fpath_line ]] && print -r "$fpath_line"
- print -r "$output
-$endline" } >$tmpout
-
-if ! read -q key"?Save new settings to $ifile? "; then
- print "Enter a different filename (~ will be expanded), or return to abort:"
- ifile=
- vared -ch -p 'file> ' ifile
- ifile=${~ifile}
-fi
+ print -r "$output"
+ if [[ -n $ifile ]]; then
+ line="zstyle :compinstall filename ${(qq)ifile}"
+ print -r "$line"
+ eval "$line"
+ fi
+ print -r "$endline"
+} >$tmpout
if [[ -n $ifile ]]; then
+ if [[ $ifile != *(zshrc|zlogin|zshenv) ]]; then
+ print "\
+If you want this file to be run automatically, you should add
+ . $ifile
+to your .zshrc. compinstall will remember the name of this file for
+future use."
+ __ci_newline || return 1
+ fi
#
# Now use sed to update the file.
#
diff --git a/Completion/User/_configure b/Completion/User/_configure
index de8d5fba5..e66e06082 100644
--- a/Completion/User/_configure
+++ b/Completion/User/_configure
@@ -1,12 +1,9 @@
-#defcomp configure
+#compdef configure
-if [[ $PREFIX = *=* ]]; then
- # Complete filenames after e.g. --prefix=
- IPREFIX=${PREFIX%%=*}=
- PREFIX=${PREFIX#*=}
- complist -f
-else
- # Generate a list of options from configure --help
- complist -s '$($COMMAND --help |
- sed -n -e '\''s/^ *\(--[-a-z0-9]*\)[ =,].*$/\1/p'\'')'
-fi
+_arguments -- -i '(--(disable|enable)-FEATURE* --(with|without)-PACKAGE*)' \
+ -s '((#s)--disable- --enable-
+ (#s)--enable- --disable-
+ (#s)--with- --without-
+ (#s)--without- --with-)' \
+ '*=(E|)PREFIX*:prefix directory:_files -/' \
+ '*=PROGRAM*:program:_command_names -e'
diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index ae81c1bb6..82f88358e 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -456,13 +456,21 @@ item(tt(${)var(name)tt(//)var(pattern)tt(/)var(repl)tt(}))(
Replace the longest possible match of var(pattern) in the expansion of
parameter var(name) by string var(repl). The first form
replaces just the first occurrence, the second form all occurrences.
+Both var(pattern) and var(repl) are subject to double-quoted substitution,
+so that expressions like tt(${name/$opat/$npat}) will work, but note the
+usual rule that pattern characters in tt($opat) are not treated specially
+unless either the option tt(GLOB_SUBST) is set, or tt($opat) is instead
+substituted as tt(${~opat}).
+
The var(pattern) may begin with a `tt(#)', in which case the
var(pattern) must match at the start of the string, or `tt(%)', in
which case it must match at the end of the string. The var(repl) may
be an empty string, in which case the final `tt(/)' may also be omitted.
To quote the final `tt(/)' in other cases it should be preceded by two
backslashes (i.e., a quoted backslash); this is not necessary if the
-`tt(/)' occurs inside a substituted parameter.
+`tt(/)' occurs inside a substituted parameter. Note also that the `tt(#)'
+and `tt(%)' are not active if they occur inside a substituted parameter,
+even at the start.
The first `tt(/)' may be preceded by a `tt(:)', in which case the match
will only succeed if it matches the entire word. Note also the
diff --git a/Etc/NEWS b/Etc/NEWS
index abd4ae8b2..7f954814c 100644
--- a/Etc/NEWS
+++ b/Etc/NEWS
@@ -20,7 +20,7 @@ Further enhancements to new completion system:
behave in the usual way
- $fpath now set up to use installed functions by default; functions
can be loaded just by `autoload -U compinit; compinit'
- - Much improved handling of nested quoting
+ - Much improved handling of nested quoting and nested braces
- New LIST_PACKED and LIST_ROWS_FIRST completion options and corresponding
styles
- compctl library separated out (frozen but still supported)
diff --git a/Src/subst.c b/Src/subst.c
index 1f992dd54..1dc952083 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -1466,6 +1466,13 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
char t = s[-1];
singsub(&s);
+#if 0
+ /*
+ * This allows # and % to be at the start of
+ * a parameter in the substitution, which is
+ * a bit nasty, and can be done (although
+ * less efficiently) with anchors.
+ */
if (t == '/' && (flags & SUB_SUBSTR)) {
if ((c = *s) == '#' || c == '%') {
flags &= ~SUB_SUBSTR;
@@ -1476,6 +1483,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
s++;
}
}
+#endif
}
if (!vunset && isarr) {