From: Daniel Shahaf <d.s@daniel.shahaf.name>
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: Sat, 3 Apr 2021 03:12:51 +0000 [thread overview]
Message-ID: <20210403031251.GE28573@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <20210401170800.GA11180@tarpaulin.shahaf.local2>
Daniel Shahaf wrote on Thu, Apr 01, 2021 at 17:08:00 +0000:
> Marlon Richert wrote on Thu, Apr 01, 2021 at 08:11:35 +0300:
> >
> > > On 1. Apr 2021, at 2.20, Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> > >>
> > >> autoload +X -Uz _complete
> > >> functions[_autocomplete._complete]=$functions[_complete]
> > >> _complete() {
> > >> _autocomplete._complete "$@"
> > >> local -i ret=$?
> > >> (( ret )) && _comp_mesg=''
> > >> return ret
> > >
> > > Considered using an «{ } always { }» block?
> >
> > What for?
>
> For clarity, since it seems that's the pattern you're shooting for.
> Also, it would take care of preserving $?.
I was thinking of this:
_complete() {
{
_autocomplete._complete "$@"
} always {
(( $? )) && _comp_mesg=''
}
}
Note that always blocks don't affect the overall exit code:
% { (exit 42) } always { (exit 0) }; echo $?
42
%
> > I have no need to ever restore the original _complete().
>
> An always block wouldn't do this.
next prev parent reply other threads:[~2021-04-03 3:13 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
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 [this message]
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=20210403031251.GE28573@tarpaulin.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--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).