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

Re: PATCH: Re: _rsync duplicated options in completion



Sven Wischnowsky wrote:

> Wayne Davison wrote:
> 
> ...
> 
> > This makes the duplicated-option bug goes away.  Someone may want to
> > translate that into a zsh expansion pattern to avoid the call to sed.
> > OR, we may want to add the ability to specify an option like
> > "--include=PATTERN" in the _rsync file and have the PATTERN part only
> > show up as part of the help text, but not be included when completing
> > the option name.
> 
> Strange, when I found the bug, I thought about automatically including
> it in the description, too. No patch for that yet, though (and even
> then user-defined specs should take preference).

Here is the patch for that. It takes the part after the `=' in lower
case form as the description shown when trying to complete after the
option (i.e. it turns it into a `--foo:bar:' spec).


Bye
  Sven

Index: Completion/Base/Utility/_arguments
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_arguments,v
retrieving revision 1.13
diff -u -r1.13 _arguments
--- Completion/Base/Utility/_arguments	21 May 2002 07:44:57 -0000	1.13
+++ Completion/Base/Utility/_arguments	23 May 2002 12:17:20 -0000
@@ -79,7 +79,7 @@
       # Using (( ... )) gives a parse error.
 
       let "$tmpargv[(I)(|\([^\)]#\))(|\*)${opt}(|[-+]|=(|-))(|\[*\])(|:*)]" ||
-          tmp=( "$tmp[@]" "$opt" )
+          tmp=( "$tmp[@]" "$lopts[(r)$opt(|=*)]" )
     done
     lopts=( "$tmp[@]" )
 
@@ -102,7 +102,7 @@
     # makes those options be completed without an argument description.
 
     set -- "$@" '*=FILE*:file:_files' \
-           '*=(DIR|PATH)*:directory:_files -/' '*: :  '
+           '*=(DIR|PATH)*:directory:_files -/' '*=*:=: ' '*: :  '
 
     while (( $# )); do
 
@@ -136,12 +136,19 @@
       tmpo=("${(@M)tmp:#*\[\=*}")
       if (( $#tmpo )); then
         tmp=("${(@)tmp:#*\[\=*}")
-        tmpo=("${(@)${(@)tmpo%%\=*}//[^a-z0-9-]}")
 
-        if [[ "$descr" = ::* ]]; then
-	  cache=( "$cache[@]" "${(@)^tmpo}=${dir}${descr}" )
+        if [[ "$descr" = :\=* ]]; then
+          for opt in "$tmpo[@]"; do
+            cache=( "$cache[@]"
+                    "${${opt%%\=*}//[^a-zA-Z0-9-]}=::${(L)${opt%\]}#*\=}: " )
+          done
         else
-	  cache=( "$cache[@]" "${(@)^tmpo}=${dir}:${descr}" )
+          tmpo=("${(@)${(@)tmpo%%\=*}//[^a-zA-Z0-9-]}")
+          if [[ "$descr" = ::* ]]; then
+	    cache=( "$cache[@]" "${(@)^tmpo}=${dir}${descr}" )
+          else
+	    cache=( "$cache[@]" "${(@)^tmpo}=${dir}:${descr}" )
+          fi
         fi
       fi
 
@@ -150,9 +157,17 @@
       tmpo=("${(@M)tmp:#*\=*}")
       if (( $#tmpo )); then
         tmp=("${(@)tmp:#*\=*}")
-        tmpo=("${(@)${(@)tmpo%%\=*}//[^a-z0-9-]}")
 
-	cache=( "$cache[@]" "${(@)^tmpo}=${dir}${descr}" )
+        if [[ "$descr" = :\=* ]]; then
+          for opt in "$tmpo[@]"; do
+            cache=( "$cache[@]"
+                    "${${opt%%\=*}//[^a-zA-Z0-9-]}=:${(L)${opt%\]}#*\=}: " )
+          done
+        else
+          tmpo=("${(@)${(@)tmpo%%\=*}//[^a-z0-9-]}")
+
+	  cache=( "$cache[@]" "${(@)^tmpo}=${dir}${descr}" )
+        fi
       fi
 
       # Everything else is just added as an option without arguments or

-- 
Sven Wischnowsky                          wischnow@xxxxxxxxx



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