From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10686 invoked by alias); 21 Jul 2016 15:34:08 -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: X-Seq: 38904 Received: (qmail 19494 invoked from network); 21 Jul 2016 15:34:08 -0000 X-Qmail-Scanner-Diagnostics: from nm15-vm6.bullet.mail.ir2.yahoo.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(212.82.96.203):SA:0(0.0/5.0):. Processed in 0.156416 secs); 21 Jul 2016 15:34:08 -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=0.0 required=5.0 tests=FREEMAIL_FROM,SPF_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: okiddle@yahoo.co.uk X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.mail.yahoo.com designates 212.82.96.203 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1469114907; bh=PhfCAmrnKVExETPVk5mmp4Dg3tGymG1HwfIsJbx0YYQ=; h=In-reply-to:From:References:To:cc:Subject:Date:From:Subject; b=CvM8QfgbQ6n+/k9zNCe7WzyRNEIdcX9hQSEXjsnvf8HUZXu1+I4ny6jF2B6SdC7q8lKJr+jlGs/wMeVqkgCyuutklXn4Jmh8EToGm5SvKlBIMuvAvQv6zBNwS6yR7slt9MwUx2e9WgIjweESG/+5VDLQzOmseOEzgw00vaFDtFBQkBHef2hAbhOBg7Fih2K/a0NpCV0itJo7UxG63YR081G/SksAOnUlRNl+aUNXgtH6uHBvxUQDkzHqDCBCNhTxEgs3Km32kVLzl4P227dFzclGtOGa8mya7p/vkKkltMjDCKFnB6ypPTavFvoHi3SJnfayFjCfjGpp0JQNRjGFew== X-Yahoo-Newman-Id: 286463.22537.bm@smtp141.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: G8hQQW4VM1m.4o4XS4BthTfjmaKPDV4epvT_4pJ7dpLqv3i P7hcoxZqdCLEqX0pAW11O777M4LprFJ8Oxu0.lliPvSSaSfxKew5LWnaQd4F U9S3wyyCTw6yD2xEBXSHQEk5WbG1qHCERnJwSO3r968TBL.9BRLRGaaXe4fu 2HqaH_En13X0IbPBE0CuyoYMfoIGOGkMopCBXShtHzMWX1EYXVK17aznWTJ2 08nK8vt8DyY3HAq9UiHf8ZZrTVpNOajs3Q8WqbKkjfAS87WnlLPTJzSXTOoK O72c.Dto654ZosM0JM7KwnkhVU.cMMhQdTnHw_cLkbYcIPZy.YBQSdp8JjU1 JJtmCJpowFDaFpx7HqCf2jBdTJC7SwzzhMeRvdcurleZS4TQvcbKG0hFpazk 1iIbE3frE1swJ4rrIGzaaKk74AFXP6DFB1EQI2D768SsubnqaLCT.jdKHmai _y.hGKmbv7GAfSjfqHfwoxmuERaZM4sT7pRChlbPBOeN9SxOssvvv7mu.kaV GctaQ3LGQ.LdcSfm.65vkarV9_MMiULQlmtx0i2Q05H4- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- In-reply-to: <20160720065421.GE28939@tarsus.local2> From: Oliver Kiddle References: <160716185103.ZM5258@torch.brasslantern.com> <1468767614-9635-1-git-send-email-danielsh@tarsus.local2> <91351.1468835277@hydra.kiddle.eu> <20160720065421.GE28939@tarsus.local2> To: Daniel Shahaf cc: zsh-workers@zsh.org Subject: Re: [PATCH v2] Re: [PATCH] _add-zle-hook-widget: New completion. MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <22467.1469114906.1@hydra.kiddle.eu> Date: Thu, 21 Jul 2016 17:28:26 +0200 Message-ID: <22468.1469114906@hydra.kiddle.eu> Daniel Shahaf wrote: > This is just a coding style question; there are arguments for both > sides. What's the house style for completion functions, to have > explicit 'return' statements or not to have them? > > I'll make the v3 iteration use the house style, whatever it is. I don't claim to be the arbiter on whatever the house style is. Most early completion code was written by Sven and I've tried to be consistent with that. Looking over some examples now, he didn't appear to use superfluous return statements. In the end, it is more important to get the return status right, however. In the process of looking, I noticed that _normal appears to use a ret variable without declaring it local. _main_complete does set ret to 1 so this never actually matters. Furthermore, while checking that this wasn't intentional I noticed a couple of functions that use _normal where _default was meant. If you haven't got a compset -q, -n or similar changes to words/CURRENT, _normal ends up being a never ending recursive loop. Oliver diff --git a/Completion/Base/Core/_normal b/Completion/Base/Core/_normal index 539b378..dd607d2 100644 --- a/Completion/Base/Core/_normal +++ b/Completion/Base/Core/_normal @@ -30,9 +30,9 @@ if [[ CURRENT -eq 1 ]]; then curcontext="${curcontext%:*:*}:-command-:" comp="$_comps[-command-]" - [[ -n "$comp" ]] && eval "$comp" && ret=0 + [[ -n "$comp" ]] && eval "$comp" && return - return ret + return 1 fi _set_command diff --git a/Completion/Unix/Command/_iostat b/Completion/Unix/Command/_iostat index 7dc33a1..6653a5d 100644 --- a/Completion/Unix/Command/_iostat +++ b/Completion/Unix/Command/_iostat @@ -129,4 +129,4 @@ if (( $#args )); then return fi -_normal +_default diff --git a/Completion/Unix/Command/_top b/Completion/Unix/Command/_top index 10c0e34..0259c23 100644 --- a/Completion/Unix/Command/_top +++ b/Completion/Unix/Command/_top @@ -98,4 +98,4 @@ if (( $#specs )); then return fi -_normal +_default