From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23613 invoked by alias); 21 Sep 2014 18:52:55 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19124 Received: (qmail 17651 invoked from network); 21 Sep 2014 18:52:53 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_NUMERIC_HELO,SPF_HELO_PASS,T_FSL_HELO_BARE_IP_2 autolearn=no version=3.3.2 X-Injected-Via-Gmane: http://gmane.org/ To: zsh-users@zsh.org From: Yuri D'Elia Subject: Re: rsync --progress stops completion Date: Sun, 21 Sep 2014 20:52:37 +0200 Message-ID: References: <2002755.9ryFYYVtTN@note> <5418786F.8030001@thregr.org> <140916175124.ZM5742@torch.brasslantern.com> <54194198.2010607@thregr.org> <140917085133.ZM6725@torch.brasslantern.com> <541AA918.8060503@thregr.org> <140918093602.ZM7963@torch.brasslantern.com> <140918190130.ZM8366@torch.brasslantern.com> <140920112024.ZM29459@torch.brasslantern.com> <140921102006.ZM31805@torch.brasslantern.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 193.106.183.18 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.0 In-Reply-To: <140921102006.ZM31805@torch.brasslantern.com> On 09/21/2014 07:20 PM, Bart Schaefer wrote: > To permit zstyle customizations it might also be useful to set up the > "compcontext" parameter and call _complete instead of "_normal -s". > There aren't any good examples of this except Functions/Misc/nslookup. So here's what I got so far: ============ #autoload typeset -a _complete_fallback_precmd _complete_fallback_cleanup() { precmd_functions=_complete_fallback_precmd RPROMPT=$_complete_fallback_rprompt } _complete_fallback() { if [[ $LASTWIDGET = *complete* || -n $_complete_fallback_precmd ]] then if [[ -z $_complete_fallback_active ]] then _complete_fallback_precmd=precmd_functions precmd_functions+=( _complete_fallback_cleanup ) fi [[ $compstate[context] = command && $CURRENT -gt 2 ]] || return 1 words=("$words[1]" "${(@)words[$CURRENT,-1]}") CURRENT=2 local curcontext="${curcontext%:*}:fallback" _compskip=default _complete fi } _complete_fallback "$@" ============ First, I hook into "precmd_functions" to setup some cleanup actions. The idea is that once fallback is active, it's immediately entered upon the completion of another argument. I couldn't find a better way to perform cleanup really. This allows rsync --random something [tab] to immediately enter the fallback if it was enabled at least once. Then I just append "fallback" to curcontext, so that in theory if you wanted to customize the fallback, you could match the style on "*:fallback:*". So then I tried to change the prompt so that I get an indicator that the fallback is active. But changing PROMPT/RPROMPT inside the completer doesn't redraw the prompt until the command is accepted. Is there a way to force the prompt to be updated?