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

Re: Redirection completion

Sven wrote:

> And another question where the default-handling is important is: when
> should post-patterns (-P) be tried? Currently this is done only if we
> would otherwise use the function defined for the least specific
> context (the one with all parts being `-default-').

Hmm, we might want to define -redirect-,<,-default- and would want
patterns tried before that. I think the post-patterns should perhaps be
tried just before -default- is first tried in the command position for
redirection and in the parameter name position for values. Or perhaps,
we need to look to see where each post-pattern uses -default-. If it
uses a pattern for one part then we should use it before trying
-default- for that part. We might need to require patterns to all be
of the form -whatever-,pattern,pattern.

> Can't say anything about this without more information. Have you
> remembered to remove the dump-file?

I had. I'm not sure what was wrong but it all works now with the latest
patch. I may have had an old version of a function in my ~/.zfunc.

> Aha. Ugh. No. See above, `-redirect-,-default-,gzip' etc. are enough.
> Not that short either, I admit, but allowing braces there isn't *that*
> simple (well, it isn't that hard either, a bit of `eval' with an array
> and some quoting magic, but...).

Ah, that is better, and neater than braces. I hadn't picked up on that
part of the idea. Very neat.

The patch below does the GZIP thing I mentioned. I've also added
pattern completions for *PATH and *path parameters using _dir_list and
_directories respectively. I've not thought of any exceptions where
this isn't appropriate but I'll leave sufficient time for objections
before committing.


Index: Completion/Unix/Command/_gzip
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_gzip,v
retrieving revision 1.2
diff -u -r1.2 _gzip
--- Completion/Unix/Command/_gzip	31 Jul 2001 13:54:04 -0000	1.2
+++ Completion/Unix/Command/_gzip	13 Mar 2002 17:17:05 -0000
@@ -1,9 +1,16 @@
-#compdef gzip gunzip gzcat=gunzip
+#compdef gzip gunzip gzcat=gunzip -value-,GZIP,-default-
-local decompress expl curcontext="$curcontext" state line
+local decompress files expl curcontext="$curcontext" state line
 typeset -A opt_args
+files=( '*:files:->files' )
 case "$service" in
+  compset -q
+  words=( fake "$words[@]" )
+  (( CURRENT++ ))
+  files=()
+  ;&
@@ -51,7 +58,7 @@
     '(--fast -1 -2 -3 -4 -5 -6 -7    -9 --best)-8' \
     '(--fast -1 -2 -3 -4 -5 -6 -7 -8    --best)-9' \
     '(--fast -1 -2 -3 -4 -5 -6 -7 -8 -9       )--best' \
-    '*:files:->files' && return 0
+    "$files[@]" && return 0
Index: Completion/Unix/Type/_dir_list
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_dir_list,v
retrieving revision 1.2
diff -u -r1.2 _dir_list
--- Completion/Unix/Type/_dir_list	13 Jun 2001 11:05:51 -0000	1.2
+++ Completion/Unix/Type/_dir_list	13 Mar 2002 17:17:05 -0000
@@ -1,4 +1,4 @@
+#compdef -value-,TERMINFO_DIRS,-default- -P -value-,*PATH,-default-
 # options:
 #  -s <sep> to specify the separator (default is a colon)
Index: Completion/Unix/Type/_directories
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_directories,v
retrieving revision 1.4
diff -u -r1.4 _directories
--- Completion/Unix/Type/_directories	20 Feb 2002 12:51:53 -0000	1.4
+++ Completion/Unix/Type/_directories	13 Mar 2002 17:17:05 -0000
@@ -1,4 +1,4 @@
-#compdef rmdir df du dircmp
+#compdef rmdir df du dircmp -P -value-,*path,-default-
 local expl

This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.

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