zsh-workers
 help / color / mirror / code / Atom feed
* Redirection completion
@ 2002-03-08 12:33 Peter Stephenson
  2002-03-08 12:54 ` Sven Wischnowsky
  2002-03-08 13:20 ` Oliver Kiddle
  0 siblings, 2 replies; 23+ messages in thread
From: Peter Stephenson @ 2002-03-08 12:33 UTC (permalink / raw)
  To: Zsh hackers list

I'm just amusing myself between tasks by playing with the new system for
completing redirections.

Is the patch at the end useful?  I got caught out because I originally
defined a completion for a non-existent type `redir'.  The list of types
appears to be closed --- i.e. you can't add your own because they're
handled internally --- in which case it's safe to test the type.

Next, it looks like the context for redirections isn't all that helpful
at the moment.  After `echo 2>' I seem to get just
`:completion::complete:echo::'.  Could we have something like the way
arguments work, so that it at least indicates we're in a redirection,
and preferably also the `2>' bit?  Along the lines of
  :completion::complete:dvips:option-o-1:
I would suggest
  :completion::complete:echo:redir-2>:'
for `echo 2>'.

Another point is that I don't seem to be able to supply completions for
`2>|' and so on, but maybe I haven't tried hard enough.

(What I was trying to do, for orientation, was make completion after any
`2>' prefer to send output to local files with the suffix `.log'.  I
came up with this:


#compdef -T redirs 2> 2>>

local expl

_wanted logfiles expl 'log files' _path_files -g "*.log" && return 0
_wanted all-files expl 'all files' _files


This always prefers log files, and it would probably be nicer to use
_alternative.  But then I need a tag order to make sure they don't all
get shown at once, and for that I need a context.  At least, I think.
Thinking some more, I could probably do all this more easily with
file-patterns, but that definitely requires more specific context
information.)

By the way, I think I'm going to expand the user guide to include more
recipe-style information.  If anyone wants to send me a list of stuff
that can be done that's not described at the moment (see
http://zsh.sunsite.dk/Guide/zshguide06.html) I'll add it.

Index: Completion/compinit
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/compinit,v
retrieving revision 1.7
diff -u -r1.7 compinit
--- Completion/compinit	4 Mar 2002 08:53:42 -0000	1.7
+++ Completion/compinit	8 Mar 2002 11:55:48 -0000
@@ -412,6 +412,11 @@
             echo "$0: missing type"
             return 1
           fi
+	  if [[ $1 != (comps|redirs|values) ]]; then
+            print \
+              "compinit: Warning: completion type \`$1' is not supported.
+Supported types are comps, redirs, values." >&2
+          fi
           _comp_assocs=( "$_comp_assocs[@]" "$1" )
           typeset -gA _$1 _service$1 _pat$1 _postpat$1
           assoc="$1"
@@ -441,6 +446,10 @@
       if (( ! $# )); then
         echo "$0: missing type"
         return 1
+      fi
+      if [[ $1 != (comps|redirs|values) ]]; then
+         print "compinit: Warning: completion type \`$1' is not supported.
+Supported types are comps, redirs, values." >&2
       fi
       _comp_assocs=( "$_comp_assocs[@]" "$1" )
       typeset -gA _$1 _service$1 _pat$1 _postpat$1

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 392070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


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

end of thread, other threads:[~2002-03-14 14:44 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-08 12:33 Redirection completion Peter Stephenson
2002-03-08 12:54 ` Sven Wischnowsky
2002-03-08 14:06   ` Peter Stephenson
2002-03-08 14:10     ` Sven Wischnowsky
2002-03-11  8:42       ` Sven Wischnowsky
2002-03-11  9:58         ` Sven Wischnowsky
2002-03-11 10:54         ` Peter Stephenson
2002-03-11 11:16           ` Sven Wischnowsky
2002-03-11 11:29             ` Peter Stephenson
2002-03-11 12:08               ` Sven Wischnowsky
2002-03-11 14:01                 ` Peter Stephenson
2002-03-11 16:56                 ` Bart Schaefer
2002-03-12  9:03                   ` Sven Wischnowsky
2002-03-12 13:16         ` Oliver Kiddle
2002-03-13  9:25           ` Sven Wischnowsky
2002-03-13 16:55             ` Peter Stephenson
2002-03-14 12:03               ` Sven Wischnowsky
2002-03-13 17:58             ` Oliver Kiddle
2002-03-13 18:19               ` Bart Schaefer
2002-03-14 13:51                 ` Oliver Kiddle
2002-03-14 14:41                   ` Peter Stephenson
2002-03-14 14:43                     ` Sven Wischnowsky
2002-03-08 13:20 ` Oliver Kiddle

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