Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Why does _main_complete not try the next completer when $_comp_mesg is non-zero?
- X-seq: zsh-workers 48380
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Marlon Richert <marlon.richert@xxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- 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
- Archived-at: <https://zsh.org/workers/48380>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2021-04/20210403031251.GE28573%40tarpaulin.shahaf.local2>
- In-reply-to: <20210401170800.GA11180@tarpaulin.shahaf.local2>
- List-id: <zsh-workers.zsh.org>
- References: <20210331232013.GC16838@tarpaulin.shahaf.local2> <DF08DE09-74A1-473A-8A9E-3D4F74AB83C6@gmail.com> <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@xxxxxxxxxxxxxxxxxx> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author