zsh-workers
 help / color / mirror / code / Atom feed
From: Matthew Martin <phy1729@gmail.com>
To: zsh-workers@zsh.org
Subject: [PATCH 3/4] _command_name: Check for external forcing precommand
Date: Mon, 1 Apr 2019 22:11:33 -0500	[thread overview]
Message-ID: <20190402031130.GA24609@CptOrmolo.darkstar> (raw)

Do not complete internal "commandish" possibilities if there is
a precommand that forces an external command. This means each caller of
_normal (that uses -p or next patch -P) need not split out the command
word (cf. _setsid and _command).

Move builtin_precommands into _main_complete where precommands is made
local, so the definition need not be duplicated in _pick_variant and
_command_names.

---
 Completion/Base/Core/_main_complete   | 6 ++++++
 Completion/Base/Utility/_pick_variant | 6 ------
 Completion/Linux/Command/_setsid      | 1 -
 Completion/Zsh/Command/_command       | 1 -
 Completion/Zsh/Type/_command_names    | 2 ++
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete
index aa2486236..6b2cf2bcf 100644
--- a/Completion/Base/Core/_main_complete
+++ b/Completion/Base/Core/_main_complete
@@ -45,6 +45,12 @@ unset _comp_priv_prefix
 # _precommand sets this to indicate we are following a precommand modifier
 local -a precommands
 
+# Precommands which allow their wrapped command to be a builtin.
+# All of these are necessarily builtins or reserved words themselves,
+# but not all builtin precommands are listed here:
+# for one, the 'command' builtin is excluded.
+local -ar builtin_precommands=(- builtin eval exec nocorrect noglob time)
+
 typeset -U _lastdescr _comp_ignore _comp_colors
 
 {
diff --git a/Completion/Base/Utility/_pick_variant b/Completion/Base/Utility/_pick_variant
index 872e8f583..b75233038 100644
--- a/Completion/Base/Utility/_pick_variant
+++ b/Completion/Base/Utility/_pick_variant
@@ -4,12 +4,6 @@ local output cmd pat pre
 local -a var
 local -A opts
 
-# Precommands which allow their wrapped command to be a builtin.
-# All of these are necessarily builtins or reserved words themselves,
-# but not all builtin precommands are listed here:
-# for one, the 'command' builtin is excluded.
-local -ar builtin_precommands=(- builtin eval exec nocorrect noglob time)
-
 (( $+_cmd_variant )) || typeset -gA _cmd_variant
 
 zparseopts -D -A opts b: c: r:
diff --git a/Completion/Linux/Command/_setsid b/Completion/Linux/Command/_setsid
index f3aef500a..d248925aa 100644
--- a/Completion/Linux/Command/_setsid
+++ b/Completion/Linux/Command/_setsid
@@ -6,5 +6,4 @@ _arguments -s -S -A '-*' : \
   '(-c --ctty)'{-c,--ctty}'[set controlling terminal to current one]' \
   '(-f --fork)'{-f,--fork}'[always fork]' \
   '(-w --wait)'{-w,--wait}'[wait for program to exit, and use same return code]' \
-  '1: :_path_commands' \
   '*:: : _normal -p $service'
diff --git a/Completion/Zsh/Command/_command b/Completion/Zsh/Command/_command
index 46e4ffc81..297c49842 100644
--- a/Completion/Zsh/Command/_command
+++ b/Completion/Zsh/Command/_command
@@ -4,5 +4,4 @@ _arguments \
   '-v[indicate result of command search]:*:command:_path_commands' \
   '-V[show result of command search in verbose form]:*:command:_path_commands' \
   '(-)-p[use default PATH to find command]' \
-  ':command:_path_commands' \
   '*::arguments: _normal -p $service'
diff --git a/Completion/Zsh/Type/_command_names b/Completion/Zsh/Type/_command_names
index f8188774d..cd630b7a4 100644
--- a/Completion/Zsh/Type/_command_names
+++ b/Completion/Zsh/Type/_command_names
@@ -21,6 +21,8 @@ defs=(
 
 if [[ "$1" = -e ]]; then
   shift
+elif (( ${#precommands:|builtin_precommands} )); then
+  # precommand excludes internal options below
 else
   [[ "$1" = - ]] && shift
 
-- 
2.21.0


                 reply	other threads:[~2019-04-02  3:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20190402031130.GA24609@CptOrmolo.darkstar \
    --to=phy1729@gmail.com \
    --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).