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

Re: rsync --progress stops completion

On 09/21/2014 09:38 PM, Bart Schaefer wrote:
> You might be better off using "compadd -x" to display a message, but
> that only shows up if there's a completion listing.  Hmm.

After some testing, I got this:

local -a _complete_fallback_precmd


  if [[ -n $_complete_fallback_precmd || $LASTWIDGET = *complete* ]]
    if [[ -z $_complete_fallback_precmd ]]
      precmd_functions+=( _complete_fallback_cleanup )
      compadd -x "fallback: enabled"
      return 0

    [[ $compstate[context] = command && $CURRENT -gt 2 ]] || return 1
    words=("$words[1]" "${(@)words[$CURRENT,-1]}")

_complete_fallback "$@"


When the hook is added, I display a message and then stop to make it
readable, as otherwise it's obliterated by the completion list. Felt a
bit odd in the beginning, since you need to press tab *again*, but it
gives you a chance to just accept/cancel the command if you're in doubt.
I like the behavior, as it makes obvious that the completion broke at
that point.

I also removed the local curcontext, since after
_complete_fallback_precmd is set, the context is already
:completion::complete-fallback:* due to the fact that _complete_fallback
is immediately entered.

Any obvious problems you can spot?

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