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

Re: rsync --progress stops completion



On 09/20/2014 08:20 PM, Bart Schaefer wrote:
> } will stop the completion entirely. Surely, with _files you can go on,
> } but I would like /--?.*/ to be simply treated as an unknown argument, so
> } that a further flag would properly complete as expected as if --unknown
> } was never there in the first place.
> 
> OK. so you'd like that.  That doesn't mean everyone would like that, so
> you still haven't answered the question "how would you like to tell the
> completion system about it, if not in the completer zstyle?"

I mean, I don't particularly "like" that, it's obvious that I would love
the completion to be accurate (I guess I can't just be lazy about broken
completers.. right?).

I'm just sure that I don't like to have to force file completion "at
times", but I honestly don't have a better alternative. I was just
suggesting a possibility. I agree about all the counter points about
this approach as well.

And yes, a zstyle would definitely be the way I would tell the completer
about the preference.

> However, perhaps the following is close enough to what you want?  This
> is similar to doing "compset -n $CURRENT" except that it retains the
> first word (presumably the command name).
> 
> 
> _try_again() {
>   [[ $compstate[context] = command && CURRENT -gt 2 ]] || return 1
>   words=("$words[1]" "${(@)words[CURRENT,-1]}")
>   CURRENT=2
>   _compskip=default
>   _normal -s
> }
> zstyle ':completion:*' completer _oldlist _expand _complete _try_again
> 
> 
> Obviously this defeats any attempt at making option suggestions mutually
> exclusive, and might (depending again upon the implementation of the
> completion function) end up suggesting options where only a non-option
> argument is valid.

Good points about suggesting invalid alternatives, but very interesting
nonetheless:

_complete_failed()
{
  if [[ $LASTWIDGET = *complete* && -z $_complete_failed_active ]]
  then
    local _complete_failed_active=1
    [[ $compstate[context] = command && CURRENT -gt 2 ]] || return 1
    words=("$words[1]" "${(@)words[CURRENT,-1]}")
    CURRENT=2
    _compskip=default
    _normal -s
  fi
}

Now, this only offers the fallback if we attempt completion *twice*, so
it's somewhat in the middle.

At first, trying it randomly, looks like a good compromise to me.

rsync --bullshit doesn't offer me any flat at first, but completes
sensibly at the second attempt. This means mutually exclusive options
will also correctly be offered.




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