Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: perforce completion problems: doesn't use supplied p4 flags
- X-seq: zsh-workers 18951
- From: Peter Stephenson <pws@xxxxxxx>
- To: zw <zsh-workers@xxxxxxxxxx>
- Subject: Re: PATCH: perforce completion problems: doesn't use supplied p4 flags
- Date: Wed, 20 Aug 2003 12:59:16 +0100
- In-reply-to: "Felix Rosencrantz"'s message of "Wed, 20 Aug 2003 04:08:47 PDT." <20030820110847.59173.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
Felix Rosencrantz wrote:
> > I've made it use all of them, let me know if this causes problems.
> > (Hmm, it shouldn't use -x or -G, but those aren't common interactively
> > and you can't complete for -x anyway, and it shouldn't use -V, but you
> > can't complete for that either.)
>
> That will cause problems. Sometimes I use "-G" from the command line, I
> use/test it with a python filter. (btw -x seems broken to me, not the
> completer, the command.) Also, the "-Ztag" flag changes the output format,
> which is likely to cause problems for the completer.
I was planning to improve this anyway...
It also makes completion after p4 -p work better.
Index: Completion/Unix/Command/_perforce
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_perforce,v
retrieving revision 1.10
diff -u -r1.10 _perforce
--- Completion/Unix/Command/_perforce 20 Aug 2003 10:04:13 -0000 1.10
+++ Completion/Unix/Command/_perforce 20 Aug 2003 11:56:54 -0000
@@ -251,27 +251,41 @@
fi
fi
+ # Options with arguments we need to pass down when calling
+ # p4 from completers. There are no options without arguments
+ # we need to pass. (Don't pass down -L language since we
+ # parse based on English output.)
+ local argopts_pass="cCdHpPu"
+ # Other options which have arguments but we shouldn't pass down.
+ # There are some debugging options, but they tend to get used
+ # with the argument in the same word as the option, in which
+ # case they will be handled OK anyway.
+ local argopts_ignore="Lx"
+
+ # If we are at or after the command word, remember the
+ # global arguments to p4 as we will need to pass these down
+ # when generating completion lists.
+ local -a _perforce_global_options
+
# We need to try and check if we are before or after the
# subcommand, since some of the options with arguments, in particular -c,
# work differently. It didn't work if I just added '*::...' to the
# end of the arguments list, anyway.
for (( i = 2; i < CURRENT; i++ )); do
- if [[ $words[i] = -[cCdHLpPux] ]]; then
+ if [[ $words[i] = -[$argopts_pass$argopts_ignore] ]]; then
# word with following argument
+ if [[ $words[i] = -[$argopts_pass] ]]; then
+ _perforce_global_options+=(${words[i,i+1]})
+ fi
(( i++ ))
+ elif [[ $words[i] = -[$argopts_pass]* ]]; then
+ # word including argument which we want to keep
+ _perforce_global_options+=(${words[i]})
elif [[ $words[i] != -* ]]; then
break
fi
done
- # If we are at or after the command word, remember the
- # global arguments to p4 as we will need to pass these down
- # when generating completion lists.
- local -a _perforce_global_options
- if (( i <= CURRENT && i > 2 )); then
- _perforce_global_options=(${words[2,i-1]})
- fi
-
if (( i >= CURRENT )); then
_arguments -s : \
'-c+[client]:client:_perforce_clients' \
@@ -280,7 +294,7 @@
'-H+[hostname]:host:_hosts' \
'-G[python output]' \
'-L+[message language]:language: ' \
- '-p+[server port]:port:_ports' \
+ '-p+[server port]:port:_perforce_hosts_ports' \
'-P+[password on server]:password: ' \
'-s[output script tags]' \
'-u+[user]:user name:_users' \
@@ -305,6 +319,9 @@
_perforce_call_p4() {
local cp_tag=$1
shift
+ # This is for our own use for parsing, and we need English output,
+ # so...
+ local +x P4LANGUAGE
_call_program $cp_tag p4 "${_perforce_global_options[@]}" "$@"
}
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
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.
**********************************************************************
Messages sorted by:
Reverse Date,
Date,
Thread,
Author