From: "Jun T." <takimoto-j@kba.biglobe.ne.jp>
To: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: [PATCH] complete two or more options for zsh
Date: Thu, 1 Oct 2015 19:41:10 +0900 [thread overview]
Message-ID: <E20B622F-8B47-4CA6-8165-03EF7310C5E6@kba.biglobe.ne.jp> (raw)
In-Reply-To: <150930091939.ZM22628@torch.brasslantern.com>
On 2015/10/01, at 1:19, Bart Schaefer <schaefer@brasslantern.com> 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 <TAB> # or -<TAB>
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 <TAB>' 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
+local curcontext=$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
prev parent reply other threads:[~2015-10-01 10:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-19 19:27 Jun T.
2015-09-23 5:39 ` Bart Schaefer
2015-09-25 16:04 ` Jun T.
2015-09-25 17:03 ` Bart Schaefer
2015-09-30 16:03 ` Jun T.
2015-09-30 16:19 ` Bart Schaefer
2015-10-01 10:41 ` Jun T. [this message]
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=E20B622F-8B47-4CA6-8165-03EF7310C5E6@kba.biglobe.ne.jp \
--to=takimoto-j@kba.biglobe.ne.jp \
--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).