0

Is it possible to make imenu refresh on every access, and to remove the *Rescan* item from the menu?

2
  • Variable 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.
    – lawlist
    Feb 13, 2018 at 4:59
  • Checked the code, seems there is no option not to add the rescan menu item.
    – ideasman42
    Feb 13, 2018 at 5:04

1 Answer 1

1

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.

2
  • @ideasman42 you should get an email with the assigned bug number.
    – jpkotta
    Feb 13, 2018 at 21:22
  • But report sent.
    – ideasman42
    Feb 13, 2018 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.