zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: Redirection completion
Date: Fri, 08 Mar 2002 12:33:14 +0000	[thread overview]
Message-ID: <21013.1015590794@csr.com> (raw)

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


             reply	other threads:[~2002-03-08 12:35 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-08 12:33 Peter Stephenson [this message]
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

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=21013.1015590794@csr.com \
    --to=pws@csr.com \
    --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).