From: Marlon Richert <marlon.richert@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Roman Perepelitsa <roman.perepelitsa@gmail.com>,
Zsh Users <zsh-users@zsh.org>
Subject: Re: Completion: How to show description for current option?
Date: Wed, 1 Sep 2021 14:27:19 +0300 [thread overview]
Message-ID: <CAHLkEDsT=nj0RQ-FFeqa7Q4Jnb_EOT=NnM-h_bc+DWJ5urfvDw@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7Z3SsNzFOCf_tgQCJwXsr+sT3cKN4zyai3tfuT6ZW87Aw@mail.gmail.com>
On Wed, Sep 1, 2021 at 3:23 AM Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> On Tue, Aug 31, 2021 at 10:22 AM Bart Schaefer
> <schaefer@brasslantern.com> wrote:
> >
> > That might be all that's needed; a matcher-list entry that allows '-'
> > to become '--'. But I suspect there's something deeper going on in
> > the _git suite.
>
> Indeed, the _git suite of functions almost always use _alternative,
> which calls _describe with a hardcoded matcher which is prefixed to
> whatever appears in the matcher_list style. On line 41 of
> _alternative:
>
> _describe -t "${def%%:*}" "$descr" ws -M 'r:|[_-]=* r:|=*' "$subopts[@]"
>
> I believe that makes it impossible to write a matcher-list zstyle that
> will swap out "-" with "--" in the context where Marlon wants it. Can
> someone demonstrate a workaround?
Thank you all, but unfortunately, none of this is addressing the
actual problems I'm trying to solve. Let me try to rephrase:
# Problem number 1
When I type, for example,
git switch -c^D
then completion shows me only
-c
instead of
-c create and switch to a new
I would like to be able to see the description to check if I'm
actually using the right option.
# Problem number 2
When I type, for example,
git switch -c^D
then completion shows me only
-c
_even if_ I have a matcher (of which the details are not important for
this question) that would actually also match --conflict and --create.
The problem is not in the _git completer (I'm just using `git switch
-c` as an example here) nor in my matchers; the problem is in
_arguments. For whatever reason, if there is a single option that
matches exactly, _arguments decides not to print any description for
it _and_ also refuses to complete any other matching options at that
point.
Is there a way around this? Or have I run into an _arguments bug? The
relevant code can be found on lines 489 - 525:
if [[ -z "$alwopt" || -z "$tried" || "$alwopt" = arg ]] &&
comparguments -s single; then
if [[ "$single" = direct ]]; then
_all_labels options expl option \
compadd -QS '' - "${PREFIX}${SUFFIX}"
elif [[ -z "$optarg" && "$single" = next ]]; then
_all_labels options expl option \
compadd -Q - "${PREFIX}${SUFFIX}"
elif [[ "$single" = equal ]]; then
_all_labels options expl option \
compadd -QqS= - "${PREFIX}${SUFFIX}"
else
tmp1=( "$next[@]" "$direct[@]" "$odirect[@]" "$equal[@]" )
[[ "$PREFIX" = [-+]* ]] && tmp1=( "${(@M)tmp1:#${PREFIX[1]}*}" )
[[ "$single" = next ]] &&
tmp1=( "${(@)tmp1:#[-+]${PREFIX[-1]}((#e)|:*)}" )
[[ "$PREFIX" != --* ]] && tmp1=( "${(@)tmp1:#--*}" )
tmp3=( "${(M@)tmp1:#[-+]?[^:]*}" )
tmp1=( "${(M@)tmp1:#[-+]?(|:*)}" )
tmp2=( "${PREFIX}${(@M)^${(@)${(@)tmp1%%:*}#[-+]}:#?}" )
_describe -O option \
tmp1 tmp2 -Q -S '' -- \
tmp3 -Q
[[ -n "$optarg" && "$single" = next && nm -eq
$compstate[nmatches] ]] &&
_all_labels options expl option \
compadd -Q - "${PREFIX}${SUFFIX}"
fi
single=yes
next prev parent reply other threads:[~2021-09-01 11:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-31 11:03 Marlon Richert
2021-08-31 11:11 ` Roman Perepelitsa
2021-08-31 17:22 ` Bart Schaefer
2021-08-31 17:39 ` Roman Perepelitsa
2021-09-01 0:23 ` Bart Schaefer
2021-09-01 11:27 ` Marlon Richert [this message]
2021-09-02 20:08 ` Oliver Kiddle
2021-09-02 20:41 ` Bart Schaefer
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='CAHLkEDsT=nj0RQ-FFeqa7Q4Jnb_EOT=NnM-h_bc+DWJ5urfvDw@mail.gmail.com' \
--to=marlon.richert@gmail.com \
--cc=roman.perepelitsa@gmail.com \
--cc=schaefer@brasslantern.com \
--cc=zsh-users@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).