Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Re: Completion for "gv" is messed up



Bart Schaefer wrote:

> I typed one TAB as shown and got the following 5 lines of output
> 
> zagzig[64] gv Doc/u<TAB>
> _arguments:compadd:371: unknown match specification character `*'
> zagzig[64] gv Doc/u
> _arguments:compadd:371: unknown match specification character `*'
> zagzig[64] gv Doc/u
> _arguments:compadd:371: unknown match specification character `*'
> zagzig[64] gv Doc/zsh_us.ps

Urgh. That's because $match was used as a local variable and then a
pattern with (#b) was used. The patch makes $match not be used for
something different than that.

Bye
 Sven

Index: Completion/Base/_arguments
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/_arguments,v
retrieving revision 1.18
diff -u -r1.18 _arguments
--- Completion/Base/_arguments	2000/05/16 11:15:25	1.18
+++ Completion/Base/_arguments	2000/05/19 08:19:55
@@ -164,7 +164,7 @@
 
 if (( $# )) && comparguments "$multi[@]" "$autod" "$@"; then
   local action noargs aret expl local tried
-  local next direct odirect equal single match matched ws tmp1 tmp2 tmp3
+  local next direct odirect equal single matcher matched ws tmp1 tmp2 tmp3
   local opts subc tc prefix suffix descrs actions subcs
   local origpre="$PREFIX" origipre="$IPREFIX"
 
@@ -196,6 +196,8 @@
     fi
   fi
 
+  comparguments -M matcher
+
   context=()
   state=()
 
@@ -252,7 +254,7 @@
 
               eval ws\=\( "${action[3,-3]}" \)
 
-              _describe -t "$subc" "$descr" ws -M "$match" "$subopts[@]"
+              _describe -t "$subc" "$descr" ws -M "$matcher" "$subopts[@]"
 	      tried=yes
 
             elif [[ "$action" = \(*\) ]]; then
@@ -307,8 +309,6 @@
 	PREFIX="$origpre"
 	IPREFIX="$origipre"
 
-        comparguments -M match
-	
         if comparguments -s single; then
 
           if [[ "$single" = direct ]]; then
@@ -342,15 +342,15 @@
           next=( "$next[@]" "$odirect[@]" )
 	  if [[ -n "$ismulti" ]]; then
 	    _ms_opt=yes
-	    _ms_match="$_ms_match $match"
+	    _ms_match="$_ms_match $matcher"
 	    _ms_optnext=( "$_ms_optnext[@]" "$next[@]" )
 	    _ms_optdirect=( "$_ms_optdirect[@]" "$direct[@]" )
 	    _ms_optequal=( "$_ms_optequal[@]" "$equal[@]" )
 	  else
             _describe -o option \
-                      next -Q -M "$match" -- \
-                      direct -QS '' -M "$match" -- \
-                      equal -QqS= -M "$match"
+                      next -Q -M "$matcher" -- \
+                      direct -QS '' -M "$matcher" -- \
+                      equal -QqS= -M "$matcher"
           fi
         fi
 	PREFIX="$prevpre"
@@ -368,7 +368,8 @@
       suffix="$SUFFIX"
       PREFIX="${PREFIX%%\=*}"
       SUFFIX=''
-      compadd -M "$match" -D equal - "${(@)equal%%:*}"
+
+      compadd -M "$matcher" -D equal - "${(@)equal%%:*}"
 
       if [[ $#equal -eq 1 ]]; then
         PREFIX="$prefix"
Index: Completion/Core/_approximate
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_approximate,v
retrieving revision 1.4
diff -u -r1.4 _approximate
--- Completion/Core/_approximate	2000/05/08 08:16:32	1.4
+++ Completion/Core/_approximate	2000/05/19 08:19:55
@@ -10,7 +10,7 @@
 
 [[ _matcher_num -gt 1 || "${#:-$PREFIX$SUFFIX}" -le 1 ]] && return 1
 
-local _comp_correct _correct_expl comax cfgacc redef
+local _comp_correct _correct_expl comax cfgacc redef match
 local oldcontext="${curcontext}" opm="$compstate[pattern_match]"
 
 if [[ "$1" = -a* ]]; then
Index: Completion/Core/_files
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_files,v
retrieving revision 1.12
diff -u -r1.12 _files
--- Completion/Core/_files	2000/05/18 07:18:58	1.12
+++ Completion/Core/_files	2000/05/19 08:19:55
@@ -1,6 +1,6 @@
 #autoload
 
-local opts tmp glob pat pats expl tag i def descr end ign ret=1
+local opts tmp glob pat pats expl tag i def descr end ign ret=1 match
 
 zparseopts -a opts \
     '/=tmp' 'f=tmp' 'g+:-=tmp' q n 1 2 P: S: r: R: W: X+: M+: F: J+: V+:
Index: Completion/Core/_multi_parts
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_multi_parts,v
retrieving revision 1.1.1.26
diff -u -r1.1.1.26 _multi_parts
--- Completion/Core/_multi_parts	2000/03/23 04:19:28	1.1.1.26
+++ Completion/Core/_multi_parts	2000/05/19 08:19:55
@@ -8,20 +8,20 @@
 # separator character are then completed independently.
 
 local sep matches pref npref i tmp1 group expl menu pre suf opre osuf cpre
-local opts sopts match imm
+local opts sopts matcher imm
 typeset -U tmp2
 
 # Get the options.
 
 zparseopts -D -a sopts \
     'J+:=group' 'V+:=group' 'X+:=expl' 'P:=opts' 'F:=opts' \
-    S: r: R: q 1 2 n f 'M+:=match' 'i=imm'
+    S: r: R: q 1 2 n f 'M+:=matcher' 'i=imm'
 
 sopts=( "$sopts[@]" "$opts[@]" )
-if (( $#match )); then
-  match="${match[2]}"
+if (( $#matcher )); then
+  matcher="${matcher[2]}"
 else
-  match=''
+  matcher=
 fi
 
 # Get the arguments, first the separator, then the array. The array is 
@@ -59,7 +59,7 @@
 # If the string from the line matches at least one of the strings,
 # we use only the matching strings.
 
-compadd -O tmp1 -M "r:|${sep}=* r:|=* $match" - "$matches[@]"
+compadd -O tmp1 -M "r:|${sep}=* r:|=* $matcher" - "$matches[@]"
 
 (( $#tmp1 )) && matches=( "$tmp1[@]" )
 
@@ -116,16 +116,16 @@
 	if [[ $#imm -ne 0 && $#matches -eq 1 ]] ||
            zstyle -t ":completion:${curcontext}:" expand suffix; then
 	  compadd "$group[@]" "$expl[@]" "$opts[@]" \
-                  -M "r:|${sep}=* r:|=* $match" - "$pref$matches[1]"
+                  -M "r:|${sep}=* r:|=* $matcher" - "$pref$matches[1]"
         else
 	  tmp2=( "${(@M)matches:#${tmp1[1]}${sep}*}" )
 
 	  if (( $#tmp2 )); then
 	    compadd "$group[@]" "$expl[@]" -p "$pref" -r "$sep" -S "$sep" "$opts[@]" \
-                    -M "r:|${sep}=* r:|=* $match" - "$tmp1[1]"
+                    -M "r:|${sep}=* r:|=* $matcher" - "$tmp1[1]"
           else
 	    compadd "$group[@]" "$expl[@]" -p "$pref" "$sopts[@]" \
-                    -M "r:|${sep}=* r:|=* $match" - "$tmp1[1]"
+                    -M "r:|${sep}=* r:|=* $matcher" - "$tmp1[1]"
           fi
         fi
 	return
@@ -138,7 +138,7 @@
 
       PREFIX="$pre"
       SUFFIX="$suf"
-      compadd -O matches -M "r:|${sep}=* r:|=* $match" - "$matches[@]"
+      compadd -O matches -M "r:|${sep}=* r:|=* $matcher" - "$matches[@]"
 
       if [[ "$pre" = *${sep}* ]]; then
  	PREFIX="${cpre}${pre%%${sep}*}"
@@ -166,21 +166,21 @@
 	  *${sep})
             compadd "$group[@]" "$expl[@]" -r "$sep" -S "$sep" "$opts[@]" \
 	            -p "$pref" \
-                    -M "r:|${sep}=* r:|=* $match" - "${i%%${sep}*}" && ret=0
+                    -M "r:|${sep}=* r:|=* $matcher" - "${i%%${sep}*}" && ret=0
             ;;
 	  ${sep}*)
             compadd "$group[@]" "$expl[@]" -S '' "$opts[@]" \
 	            -p "$pref" \
-                    -M "r:|${sep}=* r:|=* $match" - "$sep" && ret=0
+                    -M "r:|${sep}=* r:|=* $matcher" - "$sep" && ret=0
             ;;
 	  *${sep}*)
             compadd "$group[@]" "$expl[@]" -r "$sep" -S "$sep" "$opts[@]" \
 	            -p "$pref" \
-                    -M "r:|${sep}=* r:|=* $match" - "${i%%${sep}*}" && ret=0
+                    -M "r:|${sep}=* r:|=* $matcher" - "${i%%${sep}*}" && ret=0
             ;;
           *)
             compadd "$group[@]" "$expl[@]" -S '' "$opts[@]" -p "$pref" \
-                    -M "r:|${sep}=* r:|=* $match" - "$i" && ret=0
+                    -M "r:|${sep}=* r:|=* $matcher" - "$i" && ret=0
             ;;
           esac
         done
@@ -193,10 +193,10 @@
 	  if [[ "$i" = *${sep}* ]]; then
             compadd "$group[@]" "$expl[@]" "$opts[@]" \
 	            -p "$pref" -s "${i#*${sep}}" \
-                    -M "r:|${sep}=* r:|=* $match" - "${i%%${sep}*}" && ret=0
+                    -M "r:|${sep}=* r:|=* $matcher" - "${i%%${sep}*}" && ret=0
           else
             compadd "$group[@]" "$expl[@]" -S '' "$opts[@]" -p "$pref" \
-                    -M "r:|${sep}=* r:|=* $match" - "$i" && ret=0
+                    -M "r:|${sep}=* r:|=* $matcher" - "$i" && ret=0
           fi
         done
       fi
@@ -214,10 +214,10 @@
 
       if [[ -n "$suf" ]]; then
         compadd "$group[@]" "$expl[@]" -s "$suf" "$sopts[@]" \
-                -M "r:|${sep}=* r:|=* $match" - "$pref$pre"
+                -M "r:|${sep}=* r:|=* $matcher" - "$pref$pre"
       else
         compadd "$group[@]" "$expl[@]" -S '' "$opts[@]" \
-                -M "r:|${sep}=* r:|=* $match" - "$pref$pre"
+                -M "r:|${sep}=* r:|=* $matcher" - "$pref$pre"
       fi
       return
     fi
@@ -251,15 +251,15 @@
       if [[ "$pref" = *${sep} ]]; then
         compadd "$group[@]" "$expl[@]" "$opts[@]" \
                 -p "${pref%${sep}*${sep}}${sep}" -S "$sep" \
-                -M "r:|${sep}=* r:|=* $match" - "${${pref%${sep}}##*${sep}}"
+                -M "r:|${sep}=* r:|=* $matcher" - "${${pref%${sep}}##*${sep}}"
 
       elif [[ "$pref" = *${sep}* ]]; then
         compadd "$group[@]" "$expl[@]" -S '' "$opts[@]" \
                 -p "${pref%${sep}*}${sep}" \
-                -M "r:|${sep}=* r:|=* $match" - "${pref##*${sep}}"
+                -M "r:|${sep}=* r:|=* $matcher" - "${pref##*${sep}}"
       else
         compadd "$group[@]" "$expl[@]" -S '' "$opts[@]" \
-                -M "r:|${sep}=* r:|=* $match" - "$pref"
+                -M "r:|${sep}=* r:|=* $matcher" - "$pref"
       fi
     fi
     return
Index: Completion/Core/_sep_parts
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_sep_parts,v
retrieving revision 1.1.1.17
diff -u -r1.1.1.17 _sep_parts
--- Completion/Core/_sep_parts	2000/03/23 04:19:28	1.1.1.17
+++ Completion/Core/_sep_parts	2000/05/19 08:19:55
@@ -18,17 +18,17 @@
 # `-X explanation' options.
 
 local str arr sep test testarr tmparr prefix suffixes matchers autosuffix
-local matchflags opt group expl nm=$compstate[nmatches] opre osuf opts match
+local matchflags opt group expl nm=$compstate[nmatches] opre osuf opts matcher
 
 # Get the options.
 
 zparseopts -D -a opts \
-    'J+:=group' 'V+:=group' P: F: S: r: R: q 1 2 n 'X+:=expl' 'M+:=match'
+    'J+:=group' 'V+:=group' P: F: S: r: R: q 1 2 n 'X+:=expl' 'M+:=matcher'
 
-if (( $#match )); then
-  match="${match[2]}"
+if (( $#matcher )); then
+  matcher="${matcher[2]}"
 else
-  match=''
+  matcher=''
 fi
 
 # Get the string from the line.
@@ -147,7 +147,7 @@
 # If we have collected matching specifications, we build an array
 # from it that can be used as arguments to `compadd'.
 
-[[ $#matchers+$#match -gt 0 ]] && matchers=(-M "$matchers $match")
+[[ $#matchers+$#matcher -gt 0 ]] && matchers=(-M "$matchers $matcher")
 
 # Add the matches for each of the suffixes.
 
Index: Completion/Debian/_apt
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Debian/_apt,v
retrieving revision 1.5
diff -u -r1.5 _apt
--- Completion/Debian/_apt	2000/05/06 07:59:53	1.5
+++ Completion/Debian/_apt	2000/05/19 08:19:56
@@ -53,7 +53,7 @@
   comp_hasarg="{case \$current_option in
   ${comp_hasarg}esac}"
 
-  local short_seq false true bool bool_prefix intlevel word word1 nul qnul
+  local short_seq false true bool bool_prefix intlevel word word1 nul qnul match
   local comp_bool comp_intlevel comp_configfile comp_arbitem comp_long comp_opt
   local regex_short regex_long regex_all
 
Index: Completion/User/_enscript
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_enscript,v
retrieving revision 1.3
diff -u -r1.3 _enscript
--- Completion/User/_enscript	2000/05/05 13:38:46	1.3
+++ Completion/User/_enscript	2000/05/19 08:19:56
@@ -1,6 +1,6 @@
 #compdef enscript
 
-local state context line curcontext="$curcontext"
+local state context line curcontext="$curcontext" match
 typeset -A opt_args
 
 _arguments -C -s \
Index: Completion/User/_finger
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_finger,v
retrieving revision 1.2
diff -u -r1.2 _finger
--- Completion/User/_finger	2000/05/05 13:38:46	1.2
+++ Completion/User/_finger	2000/05/19 08:19:56
@@ -1,6 +1,6 @@
 #compdef finger
 
-local curcontext="$curcontext" state line
+local curcontext="$curcontext" state line match
 typeset -A opt_args
 
 if (( ! $+_finger_args )); then
Index: Completion/User/_urls
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_urls,v
retrieving revision 1.6
diff -u -r1.6 _urls
--- Completion/User/_urls	2000/05/02 08:23:31	1.6
+++ Completion/User/_urls	2000/05/19 08:19:56
@@ -38,7 +38,7 @@
 #    E.g.:
 #      zstyle ':completion:*:urls' local www /usr/local/apache/htdocs public_html
 
-local ipre scheme host user uhosts ret=1 expl
+local ipre scheme host user uhosts ret=1 expl match
 local urls_path localhttp
 zstyle -s ":completion:${curcontext}:urls" path urls_path ||
     urls_path="${ZDOTDIR:-$HOME}/.zsh/urls"
Index: Completion/X/_xutils
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/X/_xutils,v
retrieving revision 1.5
diff -u -r1.5 _xutils
--- Completion/X/_xutils	2000/05/03 14:44:01	1.5
+++ Completion/X/_xutils	2000/05/19 08:19:56
@@ -46,7 +46,7 @@
     '-rv'
   ;;
 xhost)
-  local expl type ret=1 tmp
+  local expl type ret=1 tmp match
 
   if compset -P '-'; then
     tmp=(${(f)"$(xhost)"})

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author