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

Re: long/short options

Andrej Borsenkow wrote:

> ...
> What I'd really like is something like
> -b, --binary        -- Unix line endings
> ...
> Or do I miss something and this is already possible?

It isn't.  And it's hard to write (but that didn't stop us in the past).
One would have to change the way comparguments stores and reports the
options and one would have to change the code in _describe to list
things differently.

And one would have to handle this correctly with menu selection where
users expect a one-to-one correspondence between matches (in this case:
lines) and strings to insert in the line.

That's more work than I want to invest in it.

> Another question is, in case of
> '(-c -i --import-old-mounts -p --show-cygdrive-prefix)--change-cygdrive-
> prefix[cygdrive prefix]:cygdrive prefix (POSIX path):_files -/'
> I get something like
> (tty1)% mount --change-cygdrive-prefix --
> No matches for: `cygdrive prefix (POSIX path)' or `file'
>                                                ^^^^^^^^^
> How can I prevent the last part (I want description only from option).

I was about to tell you that you can't because it is added by _files in
line 75 which we need for the tag handling.

But then I looked again and maybe the patch is all we need.  It makes
_files check if there is a user-supplied description and if so, doesn't
use `file' as its own description (it then uses an empty string which is
basically ignored in _description).

This is a development version.  Let's try.

> Oh, and is _files /*(/) the right way to complete absolute pathnames? :-)

The other hunk below is for this one.  Somehow I thought `_files -P/ -W "(/)" -/' 
would be the best solution.  But _path_files had some problems with a
-P-prefix if it was already on the line and there isn't much we can do
about that -- 60% of _path_files is about prefix and suffix handling. 
But the patch below duplicates code in the C-code to make _path_files
ignore a -P-prefix on the line.

And with that the call to _files as shown above seems to work.


Index: Completion/Unix/Type/_files
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_files,v
retrieving revision 1.3
diff -u -r1.3 _files
--- Completion/Unix/Type/_files	2001/05/07 09:25:05	1.3
+++ Completion/Unix/Type/_files	2001/07/13 07:28:33
@@ -65,7 +65,11 @@
     if [[ "$sdef" = *:${tag}:* ]]; then
-      descr=file
+      if (( $opts[(I)-X] )); then
+        descr=
+      else
+        descr=file
+      fi
Index: Completion/Unix/Type/_path_files
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_path_files,v
retrieving revision 1.7
diff -u -r1.7 _path_files
--- Completion/Unix/Type/_path_files	2001/07/06 10:46:31	1.7
+++ Completion/Unix/Type/_path_files	2001/07/13 07:28:33
@@ -5,7 +5,7 @@
 local linepath realpath donepath prepath testpath exppath skips skipped
 local tmp1 tmp2 tmp3 tmp4 i orig eorig pre suf tpre tsuf opre osuf cpre
-local pats haspats ignore pfxsfx sopt gopt opt sdirs ignpar cfopt listsfx
+local pats haspats ignore pfx pfxsfx sopt gopt opt sdirs ignpar cfopt listsfx
 local nm=$compstate[nmatches] menu matcher mopts sort match mid accex fake
 typeset -U prepaths exppaths
@@ -15,7 +15,7 @@
 # Get the options.
 zparseopts -a mopts \
-    'P:=pfxsfx' 'S:=pfxsfx' 'q=pfxsfx' 'r:=pfxsfx' 'R:=pfxsfx' \
+    'P:=pfx' 'S:=pfxsfx' 'q=pfxsfx' 'r:=pfxsfx' 'R:=pfxsfx' \
     'W:=prepaths' 'F:=ignore' 'M+:=matcher' \
     J+: V+: X+: 1: 2: n: 'f=tmp1' '/=tmp1' 'g+:-=tmp1'
@@ -28,6 +28,10 @@
   pats=( "${(@)=${(@M)tmp1:#-g*}#-g}" )
 pats=( "${(@)pats:# #}" )
+if (( $#pfx )); then
+  compset -P "$pfx[2]" || pfxsfx=( "$pfx[@]" "$pfxsfx[@]" )
 if (( $#prepaths )); then

Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx

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