zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: zsh-workers@zsh.org
Subject: Re: [PATCH v2] Re: [PATCH] _add-zle-hook-widget: New completion.
Date: Thu, 21 Jul 2016 17:28:26 +0200	[thread overview]
Message-ID: <22468.1469114906@hydra.kiddle.eu> (raw)
In-Reply-To: <20160720065421.GE28939@tarsus.local2>

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


  reply	other threads:[~2016-07-21 15:34 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-04 10:40 Next release (5.3) Peter Stephenson
2016-07-04 15:04 ` Bart Schaefer
2016-07-05  6:00   ` Sebastian Gniazdowski
2016-07-05  6:33     ` Bart Schaefer
2016-07-05  8:33   ` Peter Stephenson
2016-07-05 11:48     ` Peter Stephenson
2016-07-05 16:29       ` Bart Schaefer
2016-07-07  2:00   ` Daniel Shahaf
2016-07-13  5:00     ` add-zle-hook-widget " Daniel Shahaf
2016-07-14  0:11       ` Bart Schaefer
2016-07-17  1:51         ` Bart Schaefer
2016-07-17 15:00           ` [PATCH] _add-zle-hook-widget: New completion Daniel Shahaf
2016-07-17 19:21             ` Bart Schaefer
2016-07-17 20:40               ` Bart Schaefer
2016-07-17 21:57             ` Bart Schaefer
2016-07-18  9:47             ` Oliver Kiddle
2016-07-18 15:30               ` Bart Schaefer
2016-07-19 10:30                 ` Oliver Kiddle
2016-07-19 17:58                   ` Bart Schaefer
2016-07-20  6:54               ` [PATCH v2] " Daniel Shahaf
2016-07-21 15:28                 ` Oliver Kiddle [this message]
2016-07-22  6:22                   ` Daniel Shahaf
2016-07-22 18:21                     ` Bart Schaefer
2016-07-22 18:45                     ` Oliver Kiddle
2016-07-23 18:03                       ` Daniel Shahaf
2016-07-17 14:59         ` add-zle-hook-widget Re: Next release (5.3) Daniel Shahaf
2016-07-17 18:48           ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=22468.1469114906@hydra.kiddle.eu \
    --to=okiddle@yahoo.co.uk \
    --cc=d.s@daniel.shahaf.name \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).