From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1838 invoked from network); 8 Mar 2002 12:35:01 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 8 Mar 2002 12:35:01 -0000 Received: (qmail 29032 invoked by alias); 8 Mar 2002 12:34:47 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 16781 Received: (qmail 29020 invoked from network); 8 Mar 2002 12:34:47 -0000 To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: Redirection completion Date: Fri, 08 Mar 2002 12:33:14 +0000 Message-ID: <21013.1015590794@csr.com> From: Peter Stephenson 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 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. **********************************************************************