Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [RFC PATCH 1/2] complete absolute paths for mpc add



Bart Schaefer, 2024-11-09T11:44:08-08:00:
> I didn't see this the first time around for some reason.
>
> On Fri, Sep 27, 2024 at 9:34 AM Karel Balej <balejk@xxxxxxxxx> wrote:
> >
> > +(( $+functions[_mpc_helper_all_files] )) ||
> > +_mpc_helper_all_files() {
> > +  if [[ $words[CURRENT] == [/~]* ]]; then
> > +         _files
> > +  fi
> > +  _mpc_helper_files
> > +}
>
> If _files succeeds ($? == 0) but _mpc_helper_files fails ($? != 0)
> then _mpc_helper_all_files will appear to fail and completion will
> proceed to the next possible alternative.
>
> Does something like the following still give the result you expect?
>
> _mpc_helper_all_files() {
>   local ret=1
>   if [[ $words[CURRENT] == [/~]* ]]; then
>          _files
>          ret=$?
>   fi
>   _mpc_helper_files || return ret
> }

Thank you, this seems to give me the same results as the original,
however I don't immediately see any difference in behaviour even when I
force _mpc_helper_files to fail -- the _files results are still
completed even without the ret handling. Or do I just misunderstand how
this should work?

Again, I might misunderstand how this "next possible alternative"
mechanism works, however it occurred to me whether it might be possible
and possibly simpler to just have _mpc_helper_files fail on no matches
and have the completion fall back to _files only then?

Best regards,
K. B.




Messages sorted by: Reverse Date, Date, Thread, Author