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: Sat, 28 Mar 2020 20:10:57 +0000 Message-ID: <20200328201057.GH7449@ACM> References: <1385091004.1458082.1585083014184@mail1.libero.it> <2124649786.1598258.1585324562989@mail1.libero.it> <20200328151944.GF7449@ACM> <56971920.1649844.1585416890173@mail1.libero.it> 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="114900"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: emacs-devel@gnu.org To: Angelo Graziosi Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Mar 28 21:11:36 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 1jIHns-000TpN-A3 for ged-emacs-devel@m.gmane-mx.org; Sat, 28 Mar 2020 21:11:36 +0100 Original-Received: from localhost ([::1]:59662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jIHnr-0000gn-C9 for ged-emacs-devel@m.gmane-mx.org; Sat, 28 Mar 2020 16:11:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51848) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jIHnL-0000G9-RI for emacs-devel@gnu.org; Sat, 28 Mar 2020 16:11:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jIHnK-00017Q-Og for emacs-devel@gnu.org; Sat, 28 Mar 2020 16:11:03 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:44101 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1jIHnK-00016w-F3 for emacs-devel@gnu.org; Sat, 28 Mar 2020 16:11:02 -0400 Original-Received: (qmail 6669 invoked by uid 3782); 28 Mar 2020 20:11:00 -0000 Original-Received: from acm.muc.de (p2E5D54D7.dip0.t-ipconnect.de [46.93.84.215]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 28 Mar 2020 21:10:58 +0100 Original-Received: (qmail 10750 invoked by uid 1000); 28 Mar 2020 20:10:57 -0000 Content-Disposition: inline In-Reply-To: <56971920.1649844.1585416890173@mail1.libero.it> 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:245900 Archived-At: Hello again, Angelo. On Sat, Mar 28, 2020 at 18:34:50 +0100, Angelo Graziosi wrote: > > Il 28 marzo 2020 alle 16.19 Alan Mackenzie ha scritto: > > The function where things go wrong is imenu-update-menubar, in the "else" > > branch of the single `if' form in the function. > > I hope to have time soon to look into this more thoroughly, assuming > > nobody else does first. ;-) OK, the problem was imenu-update-menubar's handling of nested imenu element lists. (Somewhat simplified) the function was inadequately recognising a nested list by testing the list's length being 1. With such a list, it then attempted to strip the enclosing (superfluous) verbiage. However when the list had a single elemental element, such as the function "main", it threw an exception on attempting to strip the non-existent enclosing level. I think the following patch fixes the trouble. Please try it out and report on this list how well it works. Thanks: diff --git a/lisp/imenu.el b/lisp/imenu.el index fb8b3de662..7d25c2bf91 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el @@ -911,11 +911,21 @@ imenu-update-menubar (setq index-alist (imenu--split-submenus index-alist)) (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))) + (menu1 (imenu--create-keymap + (car menu) + (cdr + (cond + ((cddr menu) + ;; (cdr menu) is a list of len > 1 + menu) + ((and (consp (cdadr menu)) + ;; POSITION of a "Special element" is an atom: + (consp (cadadr menu))) + ;; Discard the enclosing level of the nested list. + (cadr menu)) + (t ; Non-nested list of length 1 + menu))) + 'imenu--menubar-select))) (setcdr imenu--menubar-keymap (cdr menu1))))))) (defun imenu--menubar-select (item) > Thanks! -- Alan Mackenzie (Nuremberg, Germany).