From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3312 invoked by alias); 1 Oct 2015 10:41:36 -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: 36732 Received: (qmail 14675 invoked from network); 1 Oct 2015 10:41:13 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Biglobe-Sender: Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Subject: Re: [PATCH] complete two or more options for zsh From: "Jun T." In-Reply-To: <150930091939.ZM22628@torch.brasslantern.com> Date: Thu, 1 Oct 2015 19:41:10 +0900 Content-Transfer-Encoding: quoted-printable Message-Id: References: <150922223902.ZM30528@torch.brasslantern.com> <91D49604-A261-46A4-95BC-624420629B84@kba.biglobe.ne.jp> <150925100303.ZM3552@torch.brasslantern.com> <5AB853BF-EBC6-4F61-BDBC-66604DCE926B@kba.biglobe.ne.jp> <150930091939.ZM22628@torch.brasslantern.com> To: "zsh-workers@zsh.org" X-Mailer: Apple Mail (2.1510) X-Biglobe-Spnum: 63557 On 2015/10/01, at 1:19, Bart Schaefer wrote: > Probably the ideal way to complete script args is to use "compset -n" > to simulate the script name appearing in command position, and then > call _normal. Before sending the previous patch I tried *::script argumets:_normal and the following worked (IF script had its own compdef): % zsh script # or - But then I thought there would be not much chance that the user had defined compdef for the script; otherwise it would just complete files. (Or are there any difference even if there is no compdef for the = script?) And it caused 'zsh -s ' to complete executables instead of = arguments. So I thought it would just be enough to call _files. But, yes, maybe calling _normal would be useful for some users. How about the following? (includes my previous patch) diff --git a/Completion/Unix/Command/_zsh b/Completion/Unix/Command/_zsh index 3b6d7ad..a541467 100644 --- a/Completion/Unix/Command/_zsh +++ b/Completion/Unix/Command/_zsh @@ -1,8 +1,23 @@ #compdef zsh =20 +local curcontext=3D$curcontext state state_descr line expl +typeset -A opt_args + _arguments -S -s : \ '*-o+[set named option]:option:_options' \ '*+o+[unset named option]:option:_options' \ + '(1 -s --shinstdin)'{-s,--shinstdin}'[read commands from standard = input]' \ + '(-)-b[end of option processing, like --]' \ '(1 -)-c[run a command]:command:_cmdstring' \ '(-)1:script file:_files' \ - '*:command arguments' -- + '*::script arguments:->args' -- && return 0 + +case $state in + (args) + if [[ -n ${opt_args[(I)-c|-s|--shinstdin]} ]]; then + _files + else + _normal + fi + ;; +esac