From: Bart Schaefer <schaefer@brasslantern.com>
To: Marlon Richert <marlon.richert@gmail.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Why does _main_complete not try the next completer when $_comp_mesg is non-zero?
Date: Sun, 28 Mar 2021 13:51:12 -0700 [thread overview]
Message-ID: <CAH+w=7Z3Cka8Mg7M0K+Bsma0AUGpREXmaTEoVJhonuWcnVbfeQ@mail.gmail.com> (raw)
In-Reply-To: <CAHLkEDvZ=hRKVXKjRpZsBCJ9DRm4wNEFpQ0EReHkgm7hGa-iTQ@mail.gmail.com>
On Sun, Mar 28, 2021 at 11:07 AM Marlon Richert
<marlon.richert@gmail.com> wrote:
>
> Would there be any drawback to removing this check?
I think it would break the intended behavior of "_guard" when used in
an _arguments action (which is how we're getting into _message in the
first place).
There is some divergence between the doc for _guard and the actual
implementation. The doc says:
_guard [ OPTIONS ] PATTERN DESCR
This function displays DESCR if PATTERN matches the string to be
completed. It is intended to be used in the ACTION for the
specifications passed to _arguments and similar functions.
The return status is zero if the message was displayed and the word
to complete is not empty, and non-zero otherwise.
In fact the return status only depends on the word being non-empty,
not on the message at all.
Another curiousity is that _message is supposed to take an optional tag
_message -e [ TAG ] DESCR
but _guard never passes it one, it just passes all it's non-option
arguments as a string:
_message -e "$*"
This has the effect that anything looked up as a style down-stack from
_message repeats the context as the tag, e.g. from _complete_debug:
+_description:15> zstyle -s
:completion::complete:grep:argument-1:argument-1 group-name gname
So there may very well be something more needed here than just
removing that check.
> Convenient would be that I could specify through a zstyle that I don't
> want that behavior. Though, why anyone would actually want the current
> behavior is unclear to me.
In this case the author of the _grep completion function determined
that to be the desirable behavior, otherwise _guard would not have
been used in that context.
Whether an author should ever be able to "know better" than the user
is an entirely different question. But there are tags generated for
both _guard and _message that could be used to look up additional
styles within those functions, if we as a group can agree on the
semantics.
Meanwhile, what about putting this in your completer style?
_complete_or_history () {
_complete "$@"
local ret=$? _mesg=$_comp_mesg
if [[ $ret -ne 0 || -n "$_comp_mesg" ]]
then
_comp_mesg=''
_history "$@" && ret=0
fi
(( $compstate[nmatches] )) || _comp_mesg=$mesg
return ret
}
next prev parent reply other threads:[~2021-03-28 20:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-28 16:33 Marlon Richert
2021-03-28 17:10 ` Mikael Magnusson
2021-03-28 17:27 ` Marlon Richert
2021-03-28 17:46 ` Bart Schaefer
2021-03-28 18:06 ` Marlon Richert
2021-03-28 20:51 ` Bart Schaefer [this message]
2021-03-28 21:42 ` Oliver Kiddle
2021-03-29 1:22 ` Bart Schaefer
2021-03-31 6:29 ` Marlon Richert
2021-03-31 9:25 ` Oliver Kiddle
2021-03-31 10:07 ` Marlon Richert
2021-03-31 23:20 ` Daniel Shahaf
2021-04-01 5:11 ` Marlon Richert
2021-04-01 17:08 ` Daniel Shahaf
2021-04-02 12:58 ` Marlon Richert
2021-04-03 3:12 ` Daniel Shahaf
2021-04-05 10:26 ` Marlon Richert
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='CAH+w=7Z3Cka8Mg7M0K+Bsma0AUGpREXmaTEoVJhonuWcnVbfeQ@mail.gmail.com' \
--to=schaefer@brasslantern.com \
--cc=marlon.richert@gmail.com \
--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).