Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID
	autolearn=ham autolearn_force=no version=3.4.1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=brasslantern-com.20150623.gappssmtp.com; s=20150623;
        h=from:message-id:date:in-reply-to:comments:references:to:subject
         :mime-version:content-type;
        bh=HxZjLODe4TRDkGlFvnUDbwQE8zt9ghHzexJtqXUIyWg=;
        b=ecFKktldx9/rIW0LiviRSejNVctrJRVzdjyxoSF3TxdheU4klXO6EYj2HIaX1Kz4qs
         LmTJdh8ym+WFUvZVEOCxDdAXvtuWYZIk7/ObKoaQKmUKLcHbQlVrKgFes8ATVkkMssZC
         N1o1rq0wVNFijgnS5kY/Z6+jkfMpMwt8ORgjyVgG830V6wp9S+Wxeo5c+US4x8o+G+Zb
         xvdU3hNjVVnf8lwI5iLhmJUCcXlqLBtXBsOihFLGidc7vRevcOOcnA2Cn4RssUsrYf9M
         keP4WyPGYMvfYtiTLulvHiY5GpkoQYPZbRs9yGO/0sXpvJZtkBFngb3VDpR0VCOXME9/
         ZBMA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:message-id:date:in-reply-to:comments
         :references:to:subject:mime-version:content-type;
        bh=HxZjLODe4TRDkGlFvnUDbwQE8zt9ghHzexJtqXUIyWg=;
        b=TEpYPyCv+AXIg8vnTLVFafLwlHHPIiTyPUD0fZsKlyl2+Tvvcn13rU3R1hHrrT/bc0
         OSQGP9dZeareWpTxselKhJvMkKOKjzn3r4XX18kYDY45wygzJ1PEViQ+xmtZYDKP/olr
         yTBw21lAicL7xqd2+Ki4fnaiBxCpHKwN2MOP7VzA6nr6HQR1+wZxdgBQdhzmxGQWPSOU
         rvJDEgZGgeMzLCsktUSLhcimO2QLsP2RAaWNdBJj+/dJKgS3coMUj61xzhmZ2na60VVi
         qlRuV+UATMIln29tiDpGCUbauohGlZsNt3sYniYCBBMQXwMB9ebONDkX+tIKOut+IGBy
         wJ5Q==
X-Gm-Message-State: AG10YOSsCfH2EkbIR4s9sBHVyxPqevnEQfOFWN20DiVS3FzPzL6h1PLbqvqVrrtKlwjH0A==
X-Received: by 10.98.14.68 with SMTP id w65mr48621311pfi.146.1454997631092;
        Mon, 08 Feb 2016 22:00:31 -0800 (PST)
From: Bart Schaefer <schaefer@brasslantern.com>
Message-Id: <160208220038.ZM29149@torch.brasslantern.com>
Date: Mon, 8 Feb 2016 22:00:38 -0800
In-Reply-To: <56B92722.7070004@gmx.com>
Comments: In reply to Eric Cook <llua@gmx.com>
        "Re: Segfault when displaying completion lists" (Feb  8,  6:39pm)
References: <1454972312.10740.8.camel@gladbachcity.de> 
	<56B92722.7070004@gmx.com>
X-Mailer: OpenZMail Classic (0.9.2 24April2005)
To: zsh-workers@zsh.org
Subject: Re: Segfault when displaying completion lists
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Seq: zsh-workers 37927

On Feb 8,  6:39pm, Eric Cook wrote:
}
} This is a guess:

Pretty good one.

} If my guess is true, zsh should handle the menuselect keymap not
} existing more elegantly.

This is a bit brute-force, but perhaps the following?  It has the added
side-effect that if you create your own keymap named "menuselect" and/or
"listscroll" before loading zsh/complist, your bindings take precedence.

diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 06a07a4..937e1d1 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -989,6 +989,7 @@ asklistscroll(int ml)
 
     fflush(shout);
     zsetterm();
+    menuselect_bindings();	/* sanity in case deleted by user */
     selectlocalmap(lskeymap);
     if (!(cmd = getkeycmd()) || cmd == Th(z_sendbreak))
 	ret = 1;
@@ -2433,6 +2434,7 @@ domenuselect(Hookdef dummy, Chdata dat)
     unqueue_signals();
     mhasstat = (mstatus && *mstatus);
     fdat = dat;
+    menuselect_bindings();	/* sanity in case deleted by user */
     selectlocalmap(mskeymap);
     noselect = 1;
     while ((menuacc &&
@@ -3486,6 +3488,37 @@ enables_(Module m, int **enables)
 }
 
 /**/
+static void
+menuselect_bindings(void)
+{
+    if (!(mskeymap = openkeymap("menuselect"))) {
+	mskeymap = newkeymap(NULL, "menuselect");
+	linkkeymap(mskeymap, "menuselect", 1);
+	bindkey(mskeymap, "\t", refthingy(t_completeword), NULL);
+	bindkey(mskeymap, "\n", refthingy(t_acceptline), NULL);
+	bindkey(mskeymap, "\r", refthingy(t_acceptline), NULL);
+	bindkey(mskeymap, "\33[A",  refthingy(t_uplineorhistory), NULL);
+	bindkey(mskeymap, "\33[B",  refthingy(t_downlineorhistory), NULL);
+	bindkey(mskeymap, "\33[C",  refthingy(t_forwardchar), NULL);
+	bindkey(mskeymap, "\33[D",  refthingy(t_backwardchar), NULL);
+	bindkey(mskeymap, "\33OA",  refthingy(t_uplineorhistory), NULL);
+	bindkey(mskeymap, "\33OB",  refthingy(t_downlineorhistory), NULL);
+	bindkey(mskeymap, "\33OC",  refthingy(t_forwardchar), NULL);
+	bindkey(mskeymap, "\33OD",  refthingy(t_backwardchar), NULL);
+    }
+    if (!(lskeymap = openkeymap("listscroll"))) {
+	lskeymap = newkeymap(NULL, "listscroll");
+	linkkeymap(lskeymap, "listscroll", 1);
+	bindkey(lskeymap, "\t", refthingy(t_completeword), NULL);
+	bindkey(lskeymap, " ", refthingy(t_completeword), NULL);
+	bindkey(lskeymap, "\n", refthingy(t_acceptline), NULL);
+	bindkey(lskeymap, "\r", refthingy(t_acceptline), NULL);
+	bindkey(lskeymap, "\33[B",  refthingy(t_downlineorhistory), NULL);
+	bindkey(lskeymap, "\33OB",  refthingy(t_downlineorhistory), NULL);
+    }
+}
+
+/**/
 int
 boot_(Module m)
 {
@@ -3503,27 +3536,7 @@ boot_(Module m)
     }
     addhookfunc("comp_list_matches", (Hookfn) complistmatches);
     addhookfunc("menu_start", (Hookfn) domenuselect);
-    mskeymap = newkeymap(NULL, "menuselect");
-    linkkeymap(mskeymap, "menuselect", 1);
-    bindkey(mskeymap, "\t", refthingy(t_completeword), NULL);
-    bindkey(mskeymap, "\n", refthingy(t_acceptline), NULL);
-    bindkey(mskeymap, "\r", refthingy(t_acceptline), NULL);
-    bindkey(mskeymap, "\33[A",  refthingy(t_uplineorhistory), NULL);
-    bindkey(mskeymap, "\33[B",  refthingy(t_downlineorhistory), NULL);
-    bindkey(mskeymap, "\33[C",  refthingy(t_forwardchar), NULL);
-    bindkey(mskeymap, "\33[D",  refthingy(t_backwardchar), NULL);
-    bindkey(mskeymap, "\33OA",  refthingy(t_uplineorhistory), NULL);
-    bindkey(mskeymap, "\33OB",  refthingy(t_downlineorhistory), NULL);
-    bindkey(mskeymap, "\33OC",  refthingy(t_forwardchar), NULL);
-    bindkey(mskeymap, "\33OD",  refthingy(t_backwardchar), NULL);
-    lskeymap = newkeymap(NULL, "listscroll");
-    linkkeymap(lskeymap, "listscroll", 1);
-    bindkey(lskeymap, "\t", refthingy(t_completeword), NULL);
-    bindkey(lskeymap, " ", refthingy(t_completeword), NULL);
-    bindkey(lskeymap, "\n", refthingy(t_acceptline), NULL);
-    bindkey(lskeymap, "\r", refthingy(t_acceptline), NULL);
-    bindkey(lskeymap, "\33[B",  refthingy(t_downlineorhistory), NULL);
-    bindkey(lskeymap, "\33OB",  refthingy(t_downlineorhistory), NULL);
+    menuselect_bindings();
     return 0;
 }
 

