From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id e2068e14 for ; Tue, 2 Apr 2019 03:12:20 +0000 (UTC) Received: (qmail 27120 invoked by alias); 2 Apr 2019 03:12:09 -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: 44201 Received: (qmail 27726 invoked by uid 1010); 2 Apr 2019 03:12:09 -0000 X-Qmail-Scanner-Diagnostics: from mail-ot1-f41.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.1/25405. spamassassin: 3.4.2. Clear:RC:0(209.85.210.41):SA:0(-1.8/5.0):. Processed in 0.732028 secs); 02 Apr 2019 03:12:09 -0000 X-Envelope-From: phy1729@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.210.41 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:mime-version :content-disposition:user-agent; bh=P5nyknHaxAJm4pAxPwovRQMkjzHQ2IeA0RCaCwxiPrQ=; b=Ac24oFnTt2RnIdjYn+FH/YjfTWplVxAkVhldPLphQi9al4Kx7mnFZmcXaJ4IwIqPcD I20jk955GWrVfXd3eO1MtELD4NMZBqrteomMf3rXzB58I84zTDEjUy4OGp68dGMBiASJ 3HzrSB3VoktUm2Bzq5NlRYAGfBPZ9eYuMq/IQmzbRPVhkda39PHlCAruV7svZo98UPRd uJa7c/g8m6xi1TuuGc6GwUsJkExinGfAghViu+PvH+4gz15I5FKv5j+QXDq/HnjNK2di jfL7yJDbw/ZIDCF8cHOgt8F0Rn7yWb1dBc3rrR+9BXoonzil7Cqn9jOwh+xkVAndC8Yd SE+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :mime-version:content-disposition:user-agent; bh=P5nyknHaxAJm4pAxPwovRQMkjzHQ2IeA0RCaCwxiPrQ=; b=ea3Pu+AhTvxUzbJULsuD0/aO9chKKDopo5NnZmMaBBR9Kr6Of8DmBBHwfZbLs5HfHb Ti6dA2h64u3mMIXeXN+feSe4eowdC2jRYOIKBFDGA5gpyNW32+Wmr3Tj6NeqhbukA+9b oFmEL1v5rvTA9rsa2PFFrp3leEjaLCLLykZf6+gaI5sSTZXH2LlcVP1iw+O0aiA2RNEm BvzOJ2vGb9FXor/nzkOtMi919XPKtaXk0mPs4Wi4moiNcMxcyv5bUfgDBAQjqljtUjEB yWd0Zux8m7DNX6o+xIyATYpmWPZPTYm4P9sJ5f01Io8VK4irEAak3QAkhoRWen6AV7H3 QX0A== X-Gm-Message-State: APjAAAWgAq+dAHKz3OANlGGVTz4s88ZgyDrCeidzelJVkFl21gT10on8 tqNibu3BI53zK7bSfyXE9eJo7Xe0e9Q= X-Google-Smtp-Source: APXvYqwM+WSMshByqkuctgxnFtnsolL+UrpKEQ/GjU8kXIxW5O7HdViWoJ2B+3jPCn5ziE5KZXh7Hw== X-Received: by 2002:a05:6830:1398:: with SMTP id d24mr46748421otq.104.1554174695885; Mon, 01 Apr 2019 20:11:35 -0700 (PDT) Date: Mon, 1 Apr 2019 22:11:33 -0500 From: Matthew Martin To: zsh-workers@zsh.org Subject: [PATCH 3/4] _command_name: Check for external forcing precommand Message-ID: <20190402031130.GA24609@CptOrmolo.darkstar> Mail-Followup-To: zsh-workers@zsh.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.11.4 (2019-03-13) 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