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

Re: PATCH: _xwit



Tanaka Akira wrote:

> This is a completion function for xwit.
> 
> I used _regex_arguments for parsing a command line since xwit has the
> option -keyrepeat which cannot be handled by _arguments.  -keyrepeat
> takes variable length of arguments for it, but the last argument is
> featureless --- just a integer.  So _arguments cannot detect end of
> the option.

Hm. If I parsed _xwit correctly (which I'm not sure about, because I
haven't really understood _regex_arguments yet):

  _arguments '-keyrepeat:*[0-9]##:keycode: ' ...

What have I missed?

> ...
>
> +_wanted colormapids expl 'colormap id' || return 1
>
> +compadd "$expl[@]" "$@" "$desc[@]" - "${(@)list%% *}" 

If the tag alias changes make it in, this would become what is shown
in the patch below.

> ...
>
> +_xwit_compopts () {
> +  local expl
> +  _description options expl option
> +  compadd "$expl[@]" - ${(k)no[(R)*~0]} || compadd "$expl[@]" - ${(k)no}

The patch also shows one of the way to do this with tag aliases. Unless 
we find a way to put that into _regex_arguments, that is. We would
need the descriptions and tags there then but it doesn't handle them,
right? Sigh.


Bye
 Sven

diff -ru ../z.old/Completion/X/_x_colormapid Completion/X/_x_colormapid
--- ../z.old/Completion/X/_x_colormapid	Fri Mar 24 13:46:31 2000
+++ Completion/X/_x_colormapid	Fri Mar 24 13:48:33 2000
@@ -2,7 +2,7 @@
 
 local expl list desc
 
-_wanted colormapids expl 'colormap id' || return 1
+_wanted colormapids || return 1
 
 list=(${(f)"$(xprop -root -f RGB_COLOR_MAP 32xcccccccxx ': $0\n'|awk -F'[ ():]' '/^[a-zA-Z_]+\(RGB_COLOR_MAP\)/ {print $5, "--", $1}')"})
 
@@ -12,4 +12,4 @@
   desc=()
 fi
 
-compadd "$expl[@]" "$@" "$desc[@]" - "${(@)list%% *}" 
+_loop colormapids expl 'colormap id' compadd "$@" "$desc[@]" - "${(@)list%% *}" 
diff -ru ../z.old/Completion/X/_xwit Completion/X/_xwit
--- ../z.old/Completion/X/_xwit	Fri Mar 24 13:46:31 2000
+++ Completion/X/_xwit	Fri Mar 24 13:52:01 2000
@@ -16,8 +16,8 @@
 
 _xwit_compopts () {
   local expl
-  _description options expl option
-  compadd "$expl[@]" - ${(k)no[(R)*~0]} || compadd "$expl[@]" - ${(k)no}
+  _wanted options expl option compadd - ${(k)no[(R)*~0]} ||
+      _loop options expl option compadd - ${(k)no}
 }
 
 _regex_arguments _xwit_parse \

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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