zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: rsync --progress stops completion
Date: Sun, 21 Sep 2014 14:08:32 -0700	[thread overview]
Message-ID: <140921140832.ZM1472@torch.brasslantern.com> (raw)
In-Reply-To: <lvncbe$h5b$1@ger.gmane.org>

On Sep 21, 10:27pm, Yuri D'Elia wrote:
}
} Any obvious problems you can spot?

Declaring "local -a _complete_fallback_precmd" will mean that it goes
away after the autoload of _complete_fallback is finished; so after
that point you're just manipulating an undeclared global.

Also I don't think the assignments to/from precmd_functions are going
to do what you want, and there's no reason to do anything if the
context isn't "command" (is there?).

Here's a version with those repairs, and below that a suggested change
that goes back to tabbing twice.

## --- 8< --- snip --- 8< --- 
#autoload
typeset -gH _complete_fallback_precmd

(( $+functions[add-zsh-hook] )) || autoload add-zsh-hook

_complete_fallback_cleanup()
{
  add-zsh-hook -D precmd _complete_fallback\*
  _complete_fallback_precmd=''
}

_complete_fallback()
{
  [[ $compstate[context] = command && $CURRENT -gt 2 ]] || return 1

  if [[ -n $_complete_fallback_precmd || $LASTWIDGET = *complete* ]]
  then
    if [[ -z $_complete_fallback_precmd ]]
    then
      _complete_fallback_precmd=precmd
      add-zsh-hook precmd _complete_fallback_cleanup
      compadd -x "fallback: enabled"
      return 0
    fi

    words=("$words[1]" "${(@)words[$CURRENT,-1]}")
    CURRENT=2
    _compskip=default
    _complete
  fi
}

_complete_fallback "$@"
## --- 8< --- snip --- 8< --- 

Here's the two-tab version:

## --- 8< --- snip --- 8< --- 
#autoload
typeset -gH _complete_fallback_precmd

(( $+functions[add-zsh-hook] )) || autoload add-zsh-hook

_complete_fallback_cleanup()
{
  add-zsh-hook -D precmd _complete_fallback\*
  _complete_fallback_precmd=''
}

_complete_fallback()
{
  [[ $compstate[context] = command && $CURRENT -gt 2 ]] || return 1

  if [[ -z $_complete_fallback_precmd || $LASTWIDGET != *complete* ]]
  then
    _complete_fallback_precmd=precmd
    add-zsh-hook precmd _complete_fallback_cleanup
    compadd -x "Completion failed, press ${${(V)KEYS}:s/\\t/TAB} for fallbacks"
    return 0
  fi

  if [[ $LASTWIDGET = *complete* ]]
  then
    words=("$words[1]" "${(@)words[$CURRENT,-1]}")
    CURRENT=2
    compadd -x "fallback: enabled"
    _compskip=default
    _complete
  fi
}

_complete_fallback "$@"
## --- 8< --- snip --- 8< --- 


  parent reply	other threads:[~2014-09-21 21:08 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-16 15:00 Yuri D'Elia
2014-09-16 15:09 ` Vadim A. Misbakh-Soloviov
2014-09-16 17:50   ` Yuri D'Elia
2014-09-17  0:51     ` Bart Schaefer
2014-09-17  8:08       ` Yuri D'Elia
2014-09-17 15:51         ` Bart Schaefer
2014-09-18  9:42           ` Yuri D'Elia
2014-09-18 16:36             ` Bart Schaefer
2014-09-19  2:01               ` Bart Schaefer
2014-09-19  3:22                 ` Mikael Magnusson
2014-09-19 11:40                 ` Oliver Kiddle
2014-09-21  0:48                   ` Bart Schaefer
2014-09-20 13:25                 ` Yuri D'Elia
2014-09-20 18:20                   ` Bart Schaefer
2014-09-21 16:43                     ` Yuri D'Elia
2014-09-21 17:20                       ` Bart Schaefer
2014-09-21 17:33                         ` Yuri D'Elia
2014-09-21 19:38                           ` Bart Schaefer
2014-09-21 20:27                             ` Yuri D'Elia
2014-09-21 20:37                               ` Yuri D'Elia
2014-09-21 22:07                                 ` Bart Schaefer
2014-09-21 22:29                                   ` Yuri D'Elia
2014-09-22  6:58                                     ` Bart Schaefer
2014-09-21 21:08                               ` Bart Schaefer [this message]
2014-09-21 21:35                                 ` Yuri D'Elia
2014-09-21 21:54                                   ` typeset -g (was Re: rsync --progress stops completion) Bart Schaefer
2014-09-21 18:52                         ` rsync --progress stops completion Yuri D'Elia
2014-09-21 18:59                         ` Yuri D'Elia
2014-09-20 13:20               ` Yuri D'Elia
2014-09-23 14:23                 ` Oliver Kiddle
2014-09-23 14:43                   ` Peter Stephenson
2014-09-16 15:25 ` Vadim A. Misbakh-Soloviov
2014-09-16 16:28 ` Bart Schaefer

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=140921140832.ZM1472@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@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).