zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: "Zsh Hackers' List" <zsh-workers@zsh.org>
Subject: Re: Interrupts in completion, traps in _main_complete
Date: Tue, 9 Dec 2014 21:09:36 +0000	[thread overview]
Message-ID: <20141209210936.4da0a3c4@pws-pc.ntlworld.com> (raw)
In-Reply-To: <20141209115041.08f4043b@pwslap01u.europe.root.pri>

On Tue, 09 Dec 2014 11:50:41 +0000
Peter Stephenson <p.stephenson@samsung.com> 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.
 


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

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-02 15:54 Something rotten in tar completion Peter Stephenson
2014-12-02 16:48 ` Bart Schaefer
2014-12-02 17:26   ` Peter Stephenson
2014-12-04 16:56     ` Bart Schaefer
2014-12-04 17:12       ` Peter Stephenson
2014-12-05  8:20         ` Interrupting globs (Re: Something rotten in tar completion) Bart Schaefer
2014-12-05 14:17           ` Jérémie Roquet
2014-12-06 21:50             ` Bart Schaefer
2014-12-06 22:15               ` Bart Schaefer
2014-12-05 14:50           ` Peter Stephenson
2014-12-05 15:14             ` Jérémie Roquet
     [not found]             ` <22084.1417791853@thecus.kiddle.eu>
2014-12-05 15:29               ` Peter Stephenson
2014-12-05 17:03                 ` Peter Stephenson
2014-12-05 17:53             ` Peter Stephenson
2014-12-05 18:06             ` Bart Schaefer
2014-12-05 18:13               ` Peter Stephenson
2014-12-05 20:34                 ` Peter Stephenson
2014-12-05 22:07                   ` Peter Stephenson
2014-12-06  0:32                     ` Ray Andrews
2014-12-06 22:27                       ` Bart Schaefer
2014-12-06 22:57                         ` Ray Andrews
2014-12-06  0:36                     ` Mikael Magnusson
2014-12-06  0:40                       ` Mikael Magnusson
2014-12-06 22:31                         ` Bart Schaefer
2014-12-06  0:52                       ` Mikael Magnusson
2014-12-06 11:49                         ` Mikael Magnusson
2014-12-06 17:48                           ` Bart Schaefer
2014-12-07  1:42                             ` Mikael Magnusson
2014-12-07  4:45                               ` Bart Schaefer
2014-12-07  5:04                                 ` Bart Schaefer
2014-12-07 17:39                           ` Peter Stephenson
2014-12-07 22:59                             ` Mikael Magnusson
2014-12-07  5:18                     ` Bart Schaefer
2014-12-07 17:07                       ` Peter Stephenson
2014-12-07 17:19                         ` Peter Stephenson
2014-12-08 11:18                           ` Peter Stephenson
2014-12-08 12:43                             ` Mikael Magnusson
2014-12-08 13:03                               ` Peter Stephenson
2014-12-08 15:51                                 ` Mikael Magnusson
2014-12-08 16:41                                 ` Bart Schaefer
2014-12-07 17:37                         ` Oliver Kiddle
2014-12-07 18:18                           ` Peter Stephenson
2014-12-07 18:34                         ` Bart Schaefer
2014-12-07 18:59                           ` Peter Stephenson
2014-12-07 19:58                             ` Bart Schaefer
2014-12-08 10:01                               ` Peter Stephenson
2014-12-07 20:20                             ` Peter Stephenson
2014-12-07 20:54                               ` Bart Schaefer
2014-12-07 20:03                       ` Peter Stephenson
2014-12-07  5:59                   ` Bart Schaefer
2014-12-07  7:15                     ` Mikael Magnusson
2014-12-07 16:21                     ` Peter Stephenson
2014-12-07 23:01                       ` Interrupts in completion, traps in _main_complete Bart Schaefer
2014-12-08 20:27                         ` Peter Stephenson
2014-12-09  4:43                           ` Bart Schaefer
2014-12-09 11:26                             ` Peter Stephenson
2014-12-09 11:50                               ` Peter Stephenson
2014-12-09 21:09                                 ` Peter Stephenson [this message]
2014-12-10 10:02                               ` interrupt_abort incorporation Peter Stephenson
2014-12-11 10:00                                 ` Peter Stephenson
2014-12-04 17:24       ` Something rotten in tar completion 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=20141209210936.4da0a3c4@pws-pc.ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@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).