Subject: bug#56430: [PATCH] fix broken `imenu--create-keymap` when an item is nil

From: Lars Ingebrigtsen <[email-masked]>
Date: Thu, 07 Jul 2022 20:02:42 +0200

Brennan Vincent <[email-masked]> writes:

> I actually observed item itself being nil, not just (car item).

Does the following simple change fix the problem, then?

diff --git a/lisp/imenu.el b/lisp/imenu.el
index 040e373fb4..dcd816cb7a 100644
--- a/lisp/imenu.el
+++ b/lisp/imenu.el
@@ -471,7 +471,7 @@ imenu--create-keymap
                      (t
                       (lambda () (interactive)
                         (if cmd (funcall cmd item) item))))))
-              alist)))
+              (seq-filter #'identity alist))))
 
 (defun imenu--in-alist (str alist)
   "Check whether the string STR is contained in multi-level ALIST."

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no