From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4190 invoked by alias); 6 Aug 2018 09:20:45 -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: 43241 Received: (qmail 23507 invoked by uid 1010); 6 Aug 2018 09:20:45 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.com 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(66.111.4.25):SA:0(-2.6/5.0):. Processed in 3.72497 secs); 06 Aug 2018 09:20:45 -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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=yfu4ZRw/f+jjzrHEzDoeDlty5++9r /POIX9wM+qeakI=; b=dhxxD7z8vFERQLasQmpGLAWpKJVhZ6t0RpQtUHEtYD0Y5 qgGz/ka8GxcmRzi0KF0j41YzRn/bWX1hfzhWyYnZbLHWa4aRb/ciCJkYJOSsJweL Z5FaruoKx8iCh4ClHdKpTtXNSn/3+XRkynprisfieFTfOCOWsxZHOdeIqVWxgPPw Yz2f/Qh6+t5X/GvFNppycYZZCe/Y60FGpZqe8AWj5DxHvpf2XzZl6CeJzYjQz950 QNDm9SovtFIwbrB72F4k4I0POWDmuGWC0/HobEFA+X6zQfO5qdQYKjm7hSOJhH86 /Z0eXXJHsmvkUsTVy6fL5MyW5lzIN/MG2I6uZHcCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=yfu4ZRw/f+jjzrHEzDoeDlty5++9r /POIX9wM+qeakI=; b=C70T8P9wafnP9j9CXxhIpMkwTdkitS1kNmxSW7Lra0aSP Fo4Cjn8TYfA5AAVbCdkpANyJR1dKJyU3SPrqIV5n/iy0E3pnHbwCdFrmq9bERZx1 93sOvw76QymLSkWAZ3mN/p5uS+br4x4vQ9J4knZaFEywilmMwyA/oEQ5SmLiHetA x4Bzehn/hwyDAEGYZD+1R4OuXTng93wnUW3rB8PllX6meEdiKnzWqzBcq/D+6K2M V18zyKklTuv+rbveJ2Z23XLwQEf9HCDLjVxER3rhOERJ/RrK/ZMyofE+OaP2UzvH K0NxeXjEV5YzUmoo05fyiswn8v/OVpXOqXAYMhkhA== X-ME-Proxy: X-ME-Sender: Date: Mon, 6 Aug 2018 09:20:32 +0000 From: Daniel Shahaf To: Anton Shestakov Cc: zsh-workers@zsh.org Subject: Re: [PATCH 2/5] _hg: declare appropriate local parameters for ->string form Message-ID: <20180806092032.uizmxvlc2oku2ik6@tarpaulin.shahaf.local2> References: <20180806072813.5051-1-av6@dwimlabs.net> <20180806072813.5051-3-av6@dwimlabs.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180806072813.5051-3-av6@dwimlabs.net> User-Agent: NeoMutt/20170113 (1.7.2) Anton Shestakov wrote on Mon, Aug 06, 2018 at 15:28:10 +0800: > && ret=0 is also needed (not sure why, the help page doesn't explain > it), otherwise completing `hg diff -` doesn't look right. Completion functions are supposed to return 0 if they added at least one match and non-zero otherwise. It's common for completion functions to have the following form: local ret=1 _foo && ret=0 return ret (usually with some code before/after the call to _foo) Simply adding '&&ret=0' without declaring 'ret' local is a bug: it sets the variable in the caller's scope. Furthermore, if 'ret' were declared local, setting it to 0 without using it afterwards would naturally have no effect. I'm not sure what the correct fix is. > To -workers, couldn't we write a wrapper such as the following: _added_matches_p() { local nmatches=$compstate[nmatches] "$@" (( nmatches < $compstate[nmatches] )) } to reduce the need to manage $ret in every single layer of the callstack? > Cheers, Daniel > @@ -715,14 +717,14 @@ _hg_cmd_resolve() { > } > > _hg_cmd_revert() { > - local context state line > + local context state state_descr line > 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