From 650a664ccd1e801f869f64d441b65db7dcb395f0 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Mon, 30 Mar 2020 19:25:40 +0000 Subject: [PATCH] Let imenu to work on the menu bar when its list is a single non-nested member. * lisp/imenu.el (imenu-update-menubar): No longer accept a list of length 1 as being sufficient evidence for a nested list structure. Instead, additionally check whether or not certain elements are atoms. --- lisp/imenu.el | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lisp/imenu.el b/lisp/imenu.el index fb8b3de662b..1949f2f48f7 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el @@ -911,11 +911,15 @@ to `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 (if (or (< 1 (length (cdr menu))) + ;; Have we a non-nested single entry? + (atom (cdadr menu)) + (atom (cadadr menu))) + menu + (car (cdr menu)))) + 'imenu--menubar-select))) (setcdr imenu--menubar-keymap (cdr menu1))))))) (defun imenu--menubar-select (item) -- 2.39.2