From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3639 invoked by alias); 7 Aug 2018 06:13:06 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 43251 Received: (qmail 29214 invoked by uid 1010); 7 Aug 2018 06:13:06 -0000 X-Qmail-Scanner-Diagnostics: from nl.dwimlabs.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(81.4.124.96):SA:0(-1.9/5.0):. Processed in 2.735653 secs); 07 Aug 2018 06:13:06 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: av6@dwimlabs.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dwimlabs.net; s=20171204; t=1533622379; bh=LmUWtk2LYRJGN0YMggpFZ8MxiamKMoyiwzz/T0OQSJQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jPNcBubq1KgMR1Cge5IO2m4PcD/ZZ5dBoHqbCA5IJ8J8VzopY4H1neVW+uh49FV6L jSmtDIw+z8VDsg9uKFMzqVIXJlM0dy7ui7PPW3dL1Fq9rOwrtuYz+yLuarqI1poa0d VZJuWU1W74kU8w/plQI/BzhfLgMg62UUDktRN6wk= From: Anton Shestakov To: zsh-workers@zsh.org Cc: Anton Shestakov Subject: [PATCH v2 2/5] _hg: declare appropriate local parameters for ->string form Date: Tue, 7 Aug 2018 14:11:58 +0800 Message-Id: <20180807061201.31646-2-av6@dwimlabs.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180807061201.31646-1-av6@dwimlabs.net> References: <20180807061201.31646-1-av6@dwimlabs.net> http://zsh.sourceforge.net/Doc/Release/Completion-System.html says that when ->string form is used for _arguments, the function that calls it must declare appropriate local parameters. Managing local return value also makes sense, plus without `&& ret=0` completing `hg diff -` doesn't look right. --- Completion/Unix/Command/_hg | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Completion/Unix/Command/_hg b/Completion/Unix/Command/_hg index 50ab7132c..0526fdd81 100644 --- a/Completion/Unix/Command/_hg +++ b/Completion/Unix/Command/_hg @@ -523,24 +523,28 @@ _hg_cmd_copy() { } _hg_cmd_diff() { + local context state state_descr line ret=1 typeset -A opt_args + _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts \ '*'{-r+,--rev=}'[revision]:revision:_hg_revrange' \ '(--show-function -p)'{-p,--show-function}'[show which function each change is in]' \ '(--ignore-all-space -w)'{-w,--ignore-all-space}'[ignore white space when comparing lines]' \ '(--ignore-space-change -b)'{-b,--ignore-space-change}'[ignore changes in the amount of white space]' \ '(--ignore-blank-lines -B)'{-B,--ignore-blank-lines}'[ignore changes whose lines are all blank]' \ - '*:file:->diff_files' + '*:file:->diff_files' && ret=0 if [[ $state == 'diff_files' ]] then if [[ -n $opt_args[-r] ]] then - _hg_files + _hg_files && ret=0 else - _hg_modified + _hg_modified && ret=0 fi fi + + return ret } _hg_cmd_export() { @@ -698,43 +702,47 @@ _hg_cmd_rename() { } _hg_cmd_resolve() { - local context state line + local context state state_descr line ret=1 typeset -A opt_args _arguments -s : $_hg_global_opts \ '(--list -l --mark -m --unmark -u)'{-l,--list}'[list state of files needing merge]:*:merged files:->resolve_files' \ '(--mark -m --list -l --unmark -u)'{-m,--mark}'[mark files as resolved]:*:unresolved files:_hg_unresolved' \ '(--unmark -u --list -l --mark -m)'{-u,--unmark}'[unmark files as resolved]:*:resolved files:_hg_resolved' \ - '*:file:_hg_unresolved' + '*:file:_hg_unresolved' && ret=0 if [[ $state == 'resolve_files' ]] then _alternative 'files:resolved files:_hg_resolved' \ - 'files:unresolved files:_hg_unresolved' + 'files:unresolved files:_hg_unresolved' && ret=0 fi + + return ret } _hg_cmd_revert() { - local context state line + local context state state_descr line ret=1 typeset -A opt_args _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \ '(--rev -r)'{-r+,--rev=}'[revision to revert to]:revision:_hg_tags' \ '--no-backup[do not save backup copies of files]' \ - '*:file:->diff_files' + '*:file:->diff_files' && ret=0 if [[ $state == 'diff_files' ]] then if [[ -n $opt_args[-r] ]] then - _hg_files + _hg_files && ret=0 else typeset -a status_files _hg_status mard - _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files + _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files && ret=0 fi fi + + return ret } _hg_cmd_serve() { -- 2.11.0