zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.dk
Subject: Re: long/short options
Date: Fri, 13 Jul 2001 10:07:24 +0200 (MET DST)	[thread overview]
Message-ID: <200107130807.KAA00965@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: <000601c10aeb$f5cdebb0$21c9ca95@mow.siemens.ru>

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.


Bye
  Sven

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="${(Q)sdef#*:${tag}:}"
     else
-      descr=file
+      if (( $opts[(I)-X] )); then
+        descr=
+      else
+        descr=file
+      fi
       end=yes
     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}" )
 fi
 pats=( "${(@)pats:# #}" )
+
+if (( $#pfx )); then
+  compset -P "$pfx[2]" || pfxsfx=( "$pfx[@]" "$pfxsfx[@]" )
+fi
 
 if (( $#prepaths )); then
   tmp1="${prepaths[2]}"

-- 
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


  reply	other threads:[~2001-07-13  8:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-12 16:01 Andrej Borsenkow
2001-07-13  8:07 ` Sven Wischnowsky [this message]
2001-07-13 17:01   ` Bart Schaefer
2001-07-16  7:14     ` Sven Wischnowsky
2001-07-18 13:07       ` PATCH: " Sven Wischnowsky
2001-07-18 13:46         ` Andrej Borsenkow
2001-07-18 13:51           ` Sven Wischnowsky
2001-07-18 13:59             ` Andrej Borsenkow
2001-07-18 17:20         ` Oliver Kiddle
2001-07-19  8:36           ` Sven Wischnowsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200107130807.KAA00965@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).