From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Error in C++ mode with Emacs 27.0.90 Date: Sun, 29 Mar 2020 11:50:56 +0000 Message-ID: <20200329115056.GA5469@ACM> References: <1385091004.1458082.1585083014184@mail1.libero.it> <2124649786.1598258.1585324562989@mail1.libero.it> <20200328151944.GF7449@ACM> <56971920.1649844.1585416890173@mail1.libero.it> <20200328201057.GH7449@ACM> <3d764ea5-0d60-1070-0d8a-f9820d013033@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="22096"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: Angelo Graziosi , emacs-devel@gnu.org To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Mar 29 13:51:42 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jIWTd-0005e3-II for ged-emacs-devel@m.gmane-mx.org; Sun, 29 Mar 2020 13:51:41 +0200 Original-Received: from localhost ([::1]:36722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jIWTc-0001aT-KY for ged-emacs-devel@m.gmane-mx.org; Sun, 29 Mar 2020 07:51:40 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46880) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jIWT2-0001Ah-Nq for emacs-devel@gnu.org; Sun, 29 Mar 2020 07:51:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jIWT0-0006dK-21 for emacs-devel@gnu.org; Sun, 29 Mar 2020 07:51:03 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:12687 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1jIWSz-0006cO-G7 for emacs-devel@gnu.org; Sun, 29 Mar 2020 07:51:01 -0400 Original-Received: (qmail 17274 invoked by uid 3782); 29 Mar 2020 11:50:58 -0000 Original-Received: from acm.muc.de (p2E5D5872.dip0.t-ipconnect.de [46.93.88.114]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 29 Mar 2020 13:50:56 +0200 Original-Received: (qmail 5530 invoked by uid 1000); 29 Mar 2020 11:50:56 -0000 Content-Disposition: inline In-Reply-To: <3d764ea5-0d60-1070-0d8a-f9820d013033@yandex.ru> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 193.149.48.1 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:245928 Archived-At: Hello, Dmitry. On Sun, Mar 29, 2020 at 01:18:13 +0200, Dmitry Gutov wrote: > Hi Alan, > On 28.03.2020 22:10, Alan Mackenzie wrote: > > I think the following patch fixes the trouble. Please try it out and > > report on this list how well it works > I wonder if we could rewrite the related code such as not to depend on > whether a list has one element or several. That sounds ugly. Though the > change would likely take a fair amount of rework. It seems unlikely that we can get a nested list (in imenu--index-alist) with only one element. I have tried creating a C++ buffer with 25 functions in it. This gives a simple list of 25 elements. With 26 functions, I get a nested alist with two elements. However, in an emacs-lisp-mode buffer, we get things like "Variables" and "*Rescan*", but I've not yet succeeded in causing a nested list with just one element. I'm not convinced enough that it couldn't happen, though. The latter part of the function looks like this (before my patch): (let* ((menu (imenu--split-menu index-alist (buffer-name))) (menu1 (imenu--create-keymap (car menu) ========> (cdr (if (< 1 (length (cdr menu))) menu (car (cdr menu)))) 'imenu--menubar-select))) (setcdr imenu--menubar-keymap (cdr menu1))))))) That `if' form has been there since imenu-update-menubar was first written by Karl Heuer in 1997 (commit 0a8e8bc63e3). Presumably, it really was needed back then. > In any case, imenu--create-keymap is also called from imenu--mouse-menu, > which probably needs the same kind of fix. Possibly. I've not managed to create the same error in imenu--mouse-menu, but perhaps it could do with the same correction, just in case. What do you think? Incidentally, that patch from last night was a bit untidy. I think it needs cleaning up a bit. -- Alan Mackenzie (Nuremberg, Germany).