zsh-workers
 help / color / mirror / code / Atom feed
* _rsync duplicated options in completion
@ 2002-05-15 20:52 Wayne Davison
  2002-05-16  2:18 ` Clint Adams
  0 siblings, 1 reply; 7+ messages in thread
From: Wayne Davison @ 2002-05-15 20:52 UTC (permalink / raw)
  To: Zsh Workers

I've noticed that the _rsync completer duplicates most (all?) of the
options.  For instance, if I type "--include-f<TAB>" it lists one with
a description and one without, but won't complete the option name any
further.

..wayne..


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

* Re: _rsync duplicated options in completion
  2002-05-15 20:52 _rsync duplicated options in completion Wayne Davison
@ 2002-05-16  2:18 ` Clint Adams
  2002-05-16 17:10   ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: Clint Adams @ 2002-05-16  2:18 UTC (permalink / raw)
  To: Wayne Davison; +Cc: Zsh Workers

> I've noticed that the _rsync completer duplicates most (all?) of the
> options.  For instance, if I type "--include-f<TAB>" it lists one with
> a description and one without, but won't complete the option name any
> further.

Perhaps the -- stuff should be removed if it can't coexist well.


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

* Re: _rsync duplicated options in completion
  2002-05-16  2:18 ` Clint Adams
@ 2002-05-16 17:10   ` Bart Schaefer
  2002-05-18 16:46     ` Wayne Davison
  2002-05-21  7:37     ` Sven Wischnowsky
  0 siblings, 2 replies; 7+ messages in thread
From: Bart Schaefer @ 2002-05-16 17:10 UTC (permalink / raw)
  To: Wayne Davison, Zsh Workers, Clint Adams

On May 15,  1:52pm, Wayne Davison wrote:
} Subject: _rsync duplicated options in completion
}
} I've noticed that the _rsync completer duplicates most (all?) of the
} options.  For instance, if I type "--include-f<TAB>" it lists one with
} a description and one without, but won't complete the option name any
} further.

The problem is that the `--' argument to _arguments is causing the
output from `rsync --help' to be merged with the long list of options
provided in the completion function itself.  Instead of recognizing
that there are overlaps, every option is being presented twice.

There additionally seems to be a navigation problem with menu selection.
Complete after `rsync --' (so that all combinations of options are in
the menu) and then begin scrolling down.  On an 80-column terminal, you
ventually come to a place where a blank line appears in the display.  If
you scroll down across this, you can't scroll back up again; rather you
have to cycle off the bottom to get back to the top.

On May 15, 10:18pm, Clint Adams wrote:
}
} Perhaps the -- stuff should be removed if it can't coexist well.

Clearly there's a bug that needs fixing, probably related to the code
to coalesce identical descriptions for the same option.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* Re: _rsync duplicated options in completion
  2002-05-16 17:10   ` Bart Schaefer
@ 2002-05-18 16:46     ` Wayne Davison
  2002-05-21  7:43       ` PATCH: " Sven Wischnowsky
  2002-05-21  7:37     ` Sven Wischnowsky
  1 sibling, 1 reply; 7+ messages in thread
From: Wayne Davison @ 2002-05-18 16:46 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Workers

On Thu, 16 May 2002, Bart Schaefer wrote:
> The problem is that the `--' argument to _arguments is causing the
> output from `rsync --help' to be merged with the long list of options
> provided in the completion function itself.  Instead of recognizing
> that there are overlaps, every option is being presented twice.

I've discovered that the problem stems from the rsync options containing
"--foo=BAR" items (such as --ignore=FILE and --include=PATTERN) while
the options in the _rsync file only say "--foo=".  If I add a sed
command to the end of the command that invokes --help, the end of the
line looks like this:

    ... --help 2>&1|sed 's/\(--[-A-Za-z_]*=\)[-A-Za-z_]*/\1/')//\[--/

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.

..wayne..


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

* PATCH: Re: _rsync duplicated options in completion
  2002-05-16 17:10   ` Bart Schaefer
  2002-05-18 16:46     ` Wayne Davison
@ 2002-05-21  7:37     ` Sven Wischnowsky
  1 sibling, 0 replies; 7+ messages in thread
From: Sven Wischnowsky @ 2002-05-21  7:37 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> ...
> 
> There additionally seems to be a navigation problem with menu selection.
> Complete after `rsync --' (so that all combinations of options are in
> the menu) and then begin scrolling down.  On an 80-column terminal, you
> ventually come to a place where a blank line appears in the display.  If
> you scroll down across this, you can't scroll back up again; rather you
> have to cycle off the bottom to get back to the top.

There was an obiwan-error: lines could get exactly $COLUMNS characters
long, caused the known display bug (we still don't have the code to
portably output in the last column, do we?). I wanted the code to
avoid that, but...


Bye
  Sven

Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.78
diff -u -r1.78 computil.c
--- Src/Zle/computil.c	14 May 2002 08:01:19 -0000	1.78
+++ Src/Zle/computil.c	21 May 2002 07:37:45 -0000
@@ -579,8 +579,8 @@
                     memset(buf, ' ', cd_state.pre);
                     memcpy(buf, str->str, str->len);
                     strcpy(sufp, str->desc);
-                    if (strlen(buf) >= columns)
-                        buf[columns] = '\0';
+                    if (strlen(buf) >= columns - 1)
+                        buf[columns - 1] = '\0';
                     *dp++ = ztrdup(buf);
                 }
                 *mp = *dp = NULL;

-- 
Sven Wischnowsky                          wischnow@berkom.de


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

* PATCH: Re: _rsync duplicated options in completion
  2002-05-18 16:46     ` Wayne Davison
@ 2002-05-21  7:43       ` Sven Wischnowsky
  2002-05-23 12:18         ` Sven Wischnowsky
  0 siblings, 1 reply; 7+ messages in thread
From: Sven Wischnowsky @ 2002-05-21  7:43 UTC (permalink / raw)
  To: zsh-workers


Wayne Davison wrote:

> On Thu, 16 May 2002, Bart Schaefer wrote:
> > The problem is that the `--' argument to _arguments is causing the
> > output from `rsync --help' to be merged with the long list of options
> > provided in the completion function itself.  Instead of recognizing
> > that there are overlaps, every option is being presented twice.
> 
> I've discovered that the problem stems from the rsync options containing
> "--foo=BAR" items (such as --ignore=FILE and --include=PATTERN) while
> the options in the _rsync file only say "--foo=".  [...]

Yep.

> 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).


Plus a fix for a typo in _rsync.


Bye
  Sven

Index: Completion/Base/Utility/_arguments
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_arguments,v
retrieving revision 1.12
diff -u -r1.12 _arguments
--- Completion/Base/Utility/_arguments	14 May 2002 08:08:45 -0000	1.12
+++ Completion/Base/Utility/_arguments	21 May 2002 07:41:42 -0000
@@ -74,11 +74,11 @@
     # Remove options also described by user-defined specs.
 
     tmp=()
-    for opt in "${(@)lopts:#--}"; do
+    for opt in "${(@)${(@)lopts:#--}%%\=*}"; do
 
       # Using (( ... )) gives a parse error.
 
-      let "$tmpargv[(I)(|\([^\)]#\))(|\*)${opt}(|[-+=])(|\[*\])(|:*)]" ||
+      let "$tmpargv[(I)(|\([^\)]#\))(|\*)${opt}(|[-+]|=(|-))(|\[*\])(|:*)]" ||
           tmp=( "$tmp[@]" "$opt" )
     done
     lopts=( "$tmp[@]" )
Index: Completion/Unix/Command/_rsync
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_rsync,v
retrieving revision 1.4
diff -u -r1.4 _rsync
--- Completion/Unix/Command/_rsync	16 Apr 2002 07:48:46 -0000	1.4
+++ Completion/Unix/Command/_rsync	21 May 2002 07:41:43 -0000
@@ -121,7 +121,7 @@
  	'(--whole-file)-W[copy whole files]' \
  	'(-W)--whole-file[copy whole files]' \
  	'(--one-file-system)-x[do not cross filesystem boundaries]' \
- 	'(-x)-one-file-system[do not cross filesystem boundaries]' \
+ 	'(-x)--one-file-system[do not cross filesystem boundaries]' \
  	'(--block-size)-B[checksum blocking size]:block size:' \
  	'(-B)--block-size=[checksum blocking size]:block size:' \
  	'(--rsh)-e[rsh command]:remote command:(rsh ssh)' \

-- 
Sven Wischnowsky                          wischnow@berkom.de


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

* Re: PATCH: Re: _rsync duplicated options in completion
  2002-05-21  7:43       ` PATCH: " Sven Wischnowsky
@ 2002-05-23 12:18         ` Sven Wischnowsky
  0 siblings, 0 replies; 7+ messages in thread
From: Sven Wischnowsky @ 2002-05-23 12:18 UTC (permalink / raw)
  To: zsh-workers


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@berkom.de


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

end of thread, other threads:[~2002-05-23 12:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-15 20:52 _rsync duplicated options in completion Wayne Davison
2002-05-16  2:18 ` Clint Adams
2002-05-16 17:10   ` Bart Schaefer
2002-05-18 16:46     ` Wayne Davison
2002-05-21  7:43       ` PATCH: " Sven Wischnowsky
2002-05-23 12:18         ` Sven Wischnowsky
2002-05-21  7:37     ` Sven Wischnowsky

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).