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

Re: The options variable of _arguments.



Tanaka Akira wrote:

> Z(2):akr@is27e1u11% Src/zsh -f
> is27e1u11% bindkey -e; fpath=($PWD/Completion/*(/)); autoload -U compinit; compinit -D; compdef _tst tst
> is27e1u11% _tst () { _arguments -s '-a' '-b' ':descr:{ compadd - $+options[-a] }' }
> is27e1u11% tst -ab <TAB>
> 
> ->
> 
> is27e1u11% tst -ab 0 
> 
> Hm. It should be:
> 
> is27e1u11% tst -ab 1

Right. For single-character options the `options' assoc wasn't
correctly set.

This also documents that `expl' may be use inside actions.

Bye
 Sven

diff -u oldcompletion/Base/_arguments Completion/Base/_arguments
--- oldcompletion/Base/_arguments	Tue Sep 14 09:09:00 1999
+++ Completion/Base/_arguments	Tue Sep 14 10:16:27 1999
@@ -8,7 +8,7 @@
 local args rest ws cur nth def nm expl descr action opt arg tmp xor
 local single uns ret=1 aret soptseq soptseq1 sopts prefix _line odescr
 local beg optbeg argbeg nargbeg inopt inrest fromrest cmd="$words[1]"
-local matched curopt noargs
+local matched curopt noargs i
 
 # Associative arrays used to collect information about the options.
 
@@ -433,7 +433,9 @@
 	if (( $+opts[$tmp] )); then
 	  def="$opts[$tmp]"
           curopt="$tmp"
-          _options[$curopt]=''
+	  for i in ${(s::)ws[1][2,-1]}; do
+            _options[${ws[1][1]}$i]=''
+	  done
 	  optbeg="$beg"
 	  argbeg="$beg"
           inopt=yes
@@ -646,6 +648,9 @@
         def="$dopts[$tmp[1]]"
 	opt=''
 	uns="${prefix[2,-1]%%${tmp[1][2]}*}${tmp[1][2]}"
+	for i in ${(s::)prefix[2,-1]%%${tmp[1][2]}*} ${tmp[1][2]}; do
+	  _options[${prefix[1]}$i]=''
+	done
 	break
       elif compset -P "$tmp[1]"; then
 
@@ -667,6 +672,9 @@
         def="$odopts[$tmp[1]]"
 	opt=''
 	uns="${prefix[2,-1]%%${tmp[1][2]}*}${tmp[1][2]}"
+	for i in ${(s::)prefix[2,-1]%%${tmp[1][2]}*} ${tmp[1][2]}; do
+	  _options[${prefix[1]}$i]=''
+	done
 	break
       elif compset -P "$tmp[1]"; then
 	def="$odopts[$tmp[1]]"
diff -u od/Zsh/compsys.yo Doc/Zsh/compsys.yo
--- od/Zsh/compsys.yo	Tue Sep 14 09:08:51 1999
+++ Doc/Zsh/compsys.yo	Tue Sep 14 10:12:51 1999
@@ -819,7 +819,10 @@
 otherwise it will be invoked with some extra string placed after the
 first word which can be given as arguments to the tt(compadd) and
 tt(compgen) builtins and which make sure that the var(message) given
-in the description will be shown above the matches.
+in the description will be shown above the matches. These arguments
+are taken from the array parameter tt(expl) which will be set up
+before executing the var(action) and hence may be used in it (normally 
+in an expansion like `tt($expl[@])').
 
 In places where no sensible matches can be generated, the action
 should consist of only a space. This will make the var(message) be

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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