Subject: bug#30449: imenu contains redundant '*Rescan*' item with auto refresh

From: Lars Ingebrigtsen <[email-masked]>
Date: Sun, 14 Jul 2019 18:32:45 +0200

Campbell Barton <[email-masked]> writes:

> With imenu package when auto rescan is enabled:
>
>   (setq imenu-auto-rescan t)
>
> imenu shows a  '*Refresh*' option,
> which should not be displayed when auto-rescan is used.
>
> See reference: https://emacs.stackexchange.com/a/38808/2418

I don't use imenu, so I can't really test, but does the following fix
the problem?

diff --git a/lisp/imenu.el b/lisp/imenu.el
index 5084fe61ef..9df597b4d6 100644
--- a/lisp/imenu.el
+++ b/lisp/imenu.el
@@ -510,8 +510,9 @@ imenu--make-index-alist
        "No items suitable for an index found in this buffer"))
   (or imenu--index-alist
       (setq imenu--index-alist (list nil)))
-  ;; Add a rescan option to the index.
-  (cons imenu--rescan-item imenu--index-alist))
+  (unless imenu-auto-rescan
+    ;; Add a rescan option to the index.
+    (cons imenu--rescan-item imenu--index-alist)))
 
 (defvar imenu--cleanup-seen nil)

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