zsh-workers
 help / color / mirror / code / Atom feed
* Re: The options variable of _arguments.
@ 1999-09-14  8:17 Sven Wischnowsky
  0 siblings, 0 replies; 2+ messages in thread
From: Sven Wischnowsky @ 1999-09-14  8:17 UTC (permalink / raw)
  To: zsh-workers


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@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 2+ messages in thread

* The options variable of _arguments.
@ 1999-09-13 20:32 Tanaka Akira
  0 siblings, 0 replies; 2+ messages in thread
From: Tanaka Akira @ 1999-09-13 20:32 UTC (permalink / raw)
  To: zsh-workers

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
-- 
Tanaka Akira


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-09-14  8:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-09-14  8:17 The options variable of _arguments Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
1999-09-13 20:32 Tanaka Akira

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).