Is it possible to make imenu refresh on every access, and to remove the *Rescan*
item from the menu?
1 Answer
This makes the rescan item an empty string, maybe that's good enough.
(setq imenu-auto-rescan t
imenu-auto-rescan-maxout (* 1024 1024)
imenu--rescan-item '("" . -99))
Here's some advice on some internal imenu functions that actually removes the rescan item. I think I got the corner cases, but it might break in the future.
(defun jpk/imenu-no-rescan-item (ret)
(when (and imenu-auto-rescan (<= (buffer-size) imenu-auto-rescan-maxout))
(setq ret (delq imenu--rescan-item ret)))
ret)
(advice-add 'imenu--make-index-alist :filter-return #'jpk/imenu-no-rescan-item)
(advice-add 'imenu--split-menu :filter-return #'jpk/imenu-no-rescan-item)
You should make a bug report to get a proper fix in. It seems silly to have the rescan item if auto rescan is enabled.
imenu-auto-rescan
: "Non-nil means Imenu should always rescan the buffers." I do not know if that resolves the*Rescan*
from appearing in the list and will not be testing that aspect/feature this evening, sorry.