From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 353 invoked by alias); 9 Dec 2014 21:09:44 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 33942 Received: (qmail 1577 invoked from network); 9 Dec 2014 21:09:40 -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.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-Originating-IP: [86.6.25.230] X-Spam: 0 X-Authority: v=2.1 cv=RdIeCjdv c=1 sm=1 tr=0 a=c0CwWhpM9oUd/BnC3z6Gzg==:117 a=c0CwWhpM9oUd/BnC3z6Gzg==:17 a=NLZqzBF-AAAA:8 a=kj9zAlcOel0A:10 a=hD80L64hAAAA:8 a=7JWPZ_Xup-Ws2mwFHHYA:9 a=CjuIK1q_8ugA:10 Date: Tue, 9 Dec 2014 21:09:36 +0000 From: Peter Stephenson To: "Zsh Hackers' List" Subject: Re: Interrupts in completion, traps in _main_complete Message-ID: <20141209210936.4da0a3c4@pws-pc.ntlworld.com> In-Reply-To: <20141209115041.08f4043b@pwslap01u.europe.root.pri> References: <20141202155452.647182b4@pwslap01u.europe.root.pri> <141202084858.ZM31517@torch.brasslantern.com> <20141202172654.30e7d380@pwslap01u.europe.root.pri> <141204085606.ZM9146@torch.brasslantern.com> <20141204171226.301e9d2c@pwslap01u.europe.root.pri> <141205002023.ZM19736@torch.brasslantern.com> <20141205145054.655a2f70@pwslap01u.europe.root.pri> <141205100632.ZM508@torch.brasslantern.com> <20141205181330.2b458b46@pwslap01u.europe.root.pri> <20141205203417.2bc66b7b@pws-pc.ntlworld.com> <141206215911.ZM16010@torch.brasslantern.com> <20141207162157.27cf418f@pws-pc.ntlworld.com> <141207150140.ZM24076@torch.brasslantern.com> <20141208202717.46678b7d@pws-pc.ntlworld.com> <141208204310.ZM5625@torch.brasslantern.com> <20141209112647.3cc9f1d8@pwslap01u.europe.root.pri> <20141209115041.08f4043b@pwslap01u.europe.root.pri> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 09 Dec 2014 11:50:41 +0000 Peter Stephenson wrote: > > I don't really understand what's going on with ZLE_COLORS, however. In > > the majority of cases it just seems to be saved and restored as if it > > were local. The only exception seems to be if the show-ambiguity style > > is set it gets saved for use in another completion. What is it about > > show-ambiguity that requires this? Is it so that if we redisplay a > > listing without going through _main_complete again it appears correct? > > In summary: er, well, yeah. It seems ZLS_COLORS does need to survive after the end of _main_complete, which is a bit of a messy special case. But the patch ensures ZLS_COLORS gets restored on an interrupt. I don't know what, if anything, $comppostfuncs is used for apart from _all_matches, but we could introduce a separate variable compcleanupfuncs that goes inside the always block. Nothing in _all_matches_end looks crucial; it does unset _all_matches_context but that's unimportant until the next time _all_matches runs. diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete index 91b68fe..23b91d3 100644 --- a/Completion/Base/Core/_main_complete +++ b/Completion/Base/Core/_main_complete @@ -43,6 +43,8 @@ local -a precommands typeset -U _lastdescr _comp_ignore _comp_colors +{ + [[ -z "$curcontext" ]] && curcontext=::: zstyle -s ":completion:${curcontext}:" insert-tab tmp || tmp=yes @@ -349,17 +351,20 @@ fi ( "$_comp_force_list" = ?* && nm -ge _comp_force_list ) ]] && compstate[list]="${compstate[list]//messages} force" -if [[ "$compstate[old_list]" = keep ]]; then - if [[ $_saved_colors_set = 1 ]]; then - ZLS_COLORS="$_saved_colors" +} always { + # Stuff we always do to clean up. + if [[ "$compstate[old_list]" = keep ]]; then + if [[ $_saved_colors_set = 1 ]]; then + ZLS_COLORS="$_saved_colors" + else + unset ZLS_COLORS + fi + elif (( $#_comp_colors )); then + ZLS_COLORS="${(j.:.)_comp_colors}" else unset ZLS_COLORS fi -elif (( $#_comp_colors )); then - ZLS_COLORS="${(j.:.)_comp_colors}" -else - unset ZLS_COLORS -fi +} # Now call the post-functions.