zsh-workers
 help / color / mirror / code / Atom feed
From: "Jun T." <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: Re: [PATCH] complete two or more options for zsh
Date: Sat, 26 Sep 2015 01:04:07 +0900	[thread overview]
Message-ID: <91D49604-A261-46A4-95BC-624420629B84@kba.biglobe.ne.jp> (raw)
In-Reply-To: <150922223902.ZM30528@torch.brasslantern.com>


2015/09/23 14:39, Bart Schaefer <schaefer@brasslantern.com> wrote:

> After your change,
> script names are never offered unless you first type at least one
> character that is not "-".

If you type

% zsh <TAB>

then script names (or any file names) *are* offered, but they are
at the end of the long list of options without description (and before
the options with description), so they may be not easy to find.
The real problem is that options are offered even if no '-' is
typed yet. I think this was so even before my patch.

I was using

zstyle ':completion:*' group-name ''

and then the file names were listed before the options (under the
group name 'file').

Anyway, yes, it's better to do all the completion by _arguments alone.
How about the patch below?
(or is it better to create _zsh to do the completion for zsh only?).

> Hm.  Is this a bug in _arguments rather than in the way that _sh
> called _arguments?  That is, should descr ever be a single ":"?


If there is ever an intended effect of specifying '*:' as a helpspec,
then it would better to fix _arguments to do the intended job.

2015/09/20 04:27, I wrote:
> But even with '*:' options without description are listed after
> those with description

This was wrong; I was testing with lots of my own zstyles.
With only 'autoload _Uz compinit; compint', then options with
description are listed after options without description irrespective
of whether I use '*:' or not.

So anyway '*:' seems to have no effect on how the options are ordered.
What is the intended effect of '*:' as a help spec?


diff --git a/Completion/Unix/Command/_sh b/Completion/Unix/Command/_sh
index 1b51122..1b80bd7 100644
--- a/Completion/Unix/Command/_sh
+++ b/Completion/Unix/Command/_sh
@@ -1,12 +1,14 @@
 #compdef sh ksh bash zsh csh tcsh rc
 
 if [[ $service == zsh ]]; then
-  # try a bit harder
-  if [[ ${words[CURRENT-1]} == -o ]]; then
-    _options
-    # no other possibilities
-    return
-  fi
+  _arguments -S -s : \
+    '*-o+[set named option]:option:_options' \
+    '*+o+[unset named option]:option:_options' \
+    '(1 -)-c[run a command]:command:_cmdstring' \
+    '(-)1:script file:_files' \
+    '*:command arguments' \
+    -- && return 0
+  return 1
 fi
 
 if (( CURRENT == ${words[(i)-c]} + 1 )); then
@@ -21,9 +23,3 @@ else
   fi
   _default
 fi
-
-local ret=$?
-
-[[ $service == zsh ]] && _arguments -S -s -- && ret=0
-
-return ret





  reply	other threads:[~2015-09-25 16:43 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. [this message]
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.

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=91D49604-A261-46A4-95BC-624420629B84@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).