From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27682 invoked from network); 20 Aug 2003 11:59:37 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 20 Aug 2003 11:59:37 -0000 Received: (qmail 27282 invoked by alias); 20 Aug 2003 11:59:25 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 18951 Received: (qmail 27273 invoked from network); 20 Aug 2003 11:59:24 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 20 Aug 2003 11:59:24 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [62.189.183.235] by sunsite.dk (MessageWall 1.0.8) with SMTP; 20 Aug 2003 11:59:24 -0000 Received: from EXCHANGE02.csr.com (unverified) by MAILSWEEPER01.cambridgesiliconradio.com (Content Technologies SMTPRS 4.3.10) with ESMTP id for ; Wed, 20 Aug 2003 12:58:23 +0100 Received: from csr.com ([192.168.144.127]) by EXCHANGE02.csr.com with Microsoft SMTPSVC(5.0.2195.5329); Wed, 20 Aug 2003 13:01:03 +0100 To: zw Subject: Re: PATCH: perforce completion problems: doesn't use supplied p4 flags In-reply-to: "Felix Rosencrantz"'s message of "Wed, 20 Aug 2003 04:08:47 PDT." <20030820110847.59173.qmail@web10407.mail.yahoo.com> Date: Wed, 20 Aug 2003 12:59:16 +0100 Message-ID: <28263.1061380756@csr.com> From: Peter Stephenson X-OriginalArrivalTime: 20 Aug 2003 12:01:03.0859 (UTC) FILETIME=[BADC7C30:01C36712] 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 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. **********************************************************************