From: Alan Mackenzie <acm@muc.de>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: Angelo Graziosi <angelo.g0@libero.it>, emacs-devel@gnu.org
Subject: Re: Error in C++ mode with Emacs 27.0.90
Date: Sat, 4 Apr 2020 11:46:38 +0000 [thread overview]
Message-ID: <20200404114638.GC5329@ACM> (raw)
In-Reply-To: <c3d6439e-ac00-af30-8e68-8c7da94bcdcb@yandex.ru>
Hello, Dmitry.
On Mon, Mar 30, 2020 at 01:32:48 +0300, Dmitry Gutov wrote:
> On 29.03.2020 14:50, Alan Mackenzie wrote:
> > 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.
> What's the worst that can happen in this case? We get a nested submenu
> with just one element?
Probably.
> > 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.
> If you're implying we can get rid of the check and always return (cdr
> menu), I say let's try.
I think we can get rid of the check and just use (cdr menu), yes. In
master, that is.
> >> 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,
> (setq imenu-use-popup-menu t)
> followed by
> M-x imenu
> did that for me in the example buffer.
Yes, thanks. For me, too.
> > but perhaps it could do with the same correction,
> > just in case. What do you think?
> Yup.
Sorry it didn't get into my patch for emacs-27.
> > Incidentally, that patch from last night was a bit untidy. I think it
> > needs cleaning up a bit.
> So how about this one? In my very brief testing, it seems to work, both
> in the example buffer, and for imenu indices in several bigger files:
> diff --git a/lisp/imenu.el b/lisp/imenu.el
> index fb8b3de662..809ddd7ed1 100644
> --- a/lisp/imenu.el
> +++ b/lisp/imenu.el
> @@ -814,9 +814,7 @@ imenu--mouse-menu
> (setq index-alist (imenu--split-submenus index-alist))
> (let* ((menu (imenu--split-menu index-alist (or title (buffer-name))))
> (map (imenu--create-keymap (car menu)
> - (cdr (if (< 1 (length (cdr menu)))
> - menu
> - (car (cdr menu)))))))
> + (cdr menu))))
> (popup-menu map event)))
> (defun imenu-choose-buffer-index (&optional prompt alist)
> @@ -912,9 +910,7 @@ imenu-update-menubar
> (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))))
> + (cdr menu)
> 'imenu--menubar-select)))
> (setcdr imenu--menubar-keymap (cdr menu1)))))))
I think this would be a good patch for master. I don't think Eli would
let it into the release branch, though I may be wrong.
Maybe for the release branch he would let in a patch like the one I've
already applied.
imenu is _complicated_.
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2020-04-04 11:46 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
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 [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200404114638.GC5329@ACM \
--to=acm@muc.de \
--cc=angelo.g0@libero.it \
--cc=dgutov@yandex.ru \
--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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.