unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Angelo Graziosi <angelo.g0@libero.it>
Cc: emacs-devel@gnu.org
Subject: Re: Error in C++ mode with Emacs 27.0.90
Date: Sat, 28 Mar 2020 20:10:57 +0000	[thread overview]
Message-ID: <20200328201057.GH7449@ACM> (raw)
In-Reply-To: <56971920.1649844.1585416890173@mail1.libero.it>

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).



  reply	other threads:[~2020-03-28 20:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-24 20:50 Error in C++ mode with Emacs 27.0.90 Angelo Graziosi
2020-03-27 15:56 ` Angelo Graziosi
2020-03-28 15:19   ` Alan Mackenzie
2020-03-28 17:34     ` Angelo Graziosi
2020-03-28 20:10       ` Alan Mackenzie [this message]
2020-03-28 22:31         ` Angelo Graziosi
2020-03-29 11:58           ` Alan Mackenzie
2020-03-29 13:56             ` Eli Zaretskii
2020-03-30 17:49               ` Alan Mackenzie
2020-03-30 18:36                 ` Eli Zaretskii
2020-03-30 19:46                   ` Alan Mackenzie
2020-03-28 23:18         ` Dmitry Gutov
2020-03-29 11:50           ` Alan Mackenzie
2020-03-29 22:32             ` Dmitry Gutov
2020-04-04 11:46               ` Alan Mackenzie
2020-04-04 12:52                 ` Dmitry Gutov
2023-02-18 17:52               ` Alan Mackenzie

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200328201057.GH7449@ACM \
    --to=acm@muc.de \
    --cc=angelo.g0@libero.it \
    --cc=emacs-devel@gnu.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.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).