Subject: 27.0.50; Imenu bug when imenu-auto-rescan is enabled

From: Alex Peitsinis <[email-masked]>
Date: Thu, 19 Sep 2019 12:25:05 +0100

The relevant commit (here linked from github):
https://github.com/emacs-mirror/emacs/commit/8635147ccba1fc8e1010010da8c3f8e467562f76#diff-10f71b5f4495401d9de9677a0836462b

With this latest change, if `imenu-auto-rescan` is set to `t` then
calling `imenu--index-alist` will return `nil`. The fix is to change
`(unless imenu-auto-rescan (cons ...))` to
`(if imenu-auto-rescan imenu--index-alist (cons ...))` in `imenu.el`.

Reproduction steps:
- Visit a file that supports `imenu` (e.g. an elisp buffer with some
functions defined)
- C-M-; (setq imenu-auto-rescan nil)
- M-x imenu
- There should be items in the list
- C-M-; (setq imenu-auto-rescan t)
- M-x imenu
- The list should be empty

In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.18.9,
cairo version 1.14.6)
 of 2019-09-17 built on alex-Z370M-D3H
Repository revision: bc1c2cf009e30af77523fd87a8910fdbc4284704
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description: Ubuntu 16.04.6 LTS

Recent messages:
Mark set [3 times]
Auto-saving...
imenu--make-index-alist
Scanning declarations in Cmdline.hs... ( 89%)
Sorting declarations in Cmdline.hs...done
Quit [2 times]
counsel-imenu
Scanning declarations in Cmdline.hs... ( 89%)
Sorting declarations in Cmdline.hs...done
Quit [2 times]

Configured using:
 'configure --with-imagemagick --with-gnutls --with-xwidgets
 --with-cairo --with-mailutils --with-pop
 --prefix=/home/alex/opt/emacs/install'

Configured features:
XPM JPEG TIFF GIF PNG CAIRO SOUND DBUS GSETTINGS GLIB NOTIFY INOTIFY
GNUTLS LIBXML2 FREETYPE HARFBUZZ ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE
XIM THREADS XWIDGETS PDUMPER GMP

Important settings:
  value of $LANG: en_GB.UTF-8
  value of $XMODIFIERS:
  locale-coding-system: utf-8-unix

Major mode: Haskell

Minor modes in effect:
  subword-mode: t
  haskell-decl-scan-mode: t
  intero-mode: t
  hl-line-mode: t
  global-hi-lock-mode: t
  hi-lock-mode: t
  winner-mode: t
  direnv-mode: t
  pdf-occur-global-minor-mode: t
  ivy-mode: t
  projectile-mode: t
  persp-mode: t
  global-flycheck-mode: t
  flycheck-mode: t
  company-quickhelp-mode: t
  company-quickhelp-local-mode: t
  global-company-mode: t
  company-mode: t
  haskell-indentation-mode: t
  hybrid-mode: t
  global-evil-surround-mode: t
  evil-surround-mode: t
  global-evil-visualstar-mode: t
  evil-visualstar-mode: t
  evil-leader-mode: t
  global-diff-hl-mode: t
  diff-hl-mode: t
  whitespace-mode: t
  highlight-numbers-mode: t
  recentf-mode: t
  xah-math-input-mode: t
  global-xah-math-input-mode: t
  global-anzu-mode: t
  anzu-mode: t
  engine-mode: t
  which-key-mode: t
  show-smartparens-global-mode: t
  show-smartparens-mode: t
  smartparens-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  shell-dirtrack-mode: t
  evil-local-mode: t
  save-place-mode: t
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny rfc822 mml mml-sec epa
epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils misearch
multi-isearch pulse bug-reference cua-base expand-region
subword-mode-expansions text-mode-expansions the-org-mode-expansions
python-el-fgallina-expansions html-mode-expansions er-basic-expansions
expand-region-core expand-region-custom evil-nerd-commenter
evil-nerd-commenter-operator evil-nerd-commenter-sdk smartparens-html
sgml-mode dom cl-print eieio-opt speedbar sb-image ezimage dframe
help-fns radix-tree haskell-doc inf-haskell haskell haskell-completions
haskell-load haskell-commands highlight-uses-mode haskell-modules
haskell-sandbox haskell-navigate-imports haskell-repl haskell-svg
haskell-collapse hideshow haskell-debug haskell-interactive-mode
haskell-presentation-mode haskell-compile haskell-hoogle haskell-process
haskell-session vc-git cap-words superword subword haskell-decl-scan
intero time hl-line company-oddmuse company-keywords company-etags
company-gtags company-dabbrev-code company-dabbrev company-files
company-capf company-cmake company-xcode company-clang company-semantic
company-eclim company-template company-bbdb company-anaconda
anaconda-mode url url-proxy url-privacy url-expand url-methods
url-history url-cookie url-domsuf url-util mailcap pythonic pyvenv
smartparens-python python tramp-sh tramp tramp-loaddefs trampver
tramp-integration files-x tramp-compat parse-time iso8601 ls-lisp
symbol-overlay hi-lock winner lucius-mono-theme ob-haskell ob-python
powerline powerline-separators powerline-themes direnv pdf-occur tablist
tablist-filter semantic/wisent/comp semantic/wisent
semantic/wisent/wisent semantic/util-modes semantic/util semantic
semantic/tag semantic/lex semantic/fw mode-local cedet pdf-isearch
let-alist pdf-misc imenu pdf-tools cus-edit cus-start cus-load pdf-view
bookmark text-property-search pp jka-compr pdf-cache pdf-info tq
pdf-util image-mode dired-filter f dired-aux dired-x dired-subtree
dired-hacks-utils smex ido ivy-xref counsel-projectile counsel xdg
swiper ivy flx delsel colir color ivy-overlay ag vc-svn find-dired s
dired dired-loaddefs persp-projectile projectile grep ibuf-ext ibuffer
ibuffer-loaddefs perspective cl flycheck company-quickhelp pos-tip
company proof-general custom-purescript-font-lock derived
smartparens-haskell haskell-mode haskell-cabal haskell-utils
haskell-font-lock haskell-indentation haskell-string
haskell-sort-imports haskell-lexeme haskell-align-imports haskell-compat
haskell-complete-module haskell-ghc-support flymake-proc flymake
warnings etags fileloop xref project compile dabbrev haskell-customize
evil-surround evil-visualstar evil-leader diff-hl vc-dir ewoc vc
vc-dispatcher diff-mode whitespace highlight-numbers parent-mode
em-smart pcase em-hist eshell em-pred esh-mode esh-cmd esh-ext esh-proc
esh-io esh-arg esh-module esh-groups esh-opt esh-util recentf
tree-widget wid-edit xah-math-input evil-anzu anzu engine-mode which-key
smartparens-config smartparens-org smartparens-text evil-smartparens
smartparens dash evil evil-keybindings evil-integration undo-tree diff
evil-maps evil-commands reveal flyspell ispell evil-jumps
evil-command-window evil-types evil-search evil-ex shell evil-macros
evil-repeat evil-states evil-core evil-common windmove thingatpt rect
evil-digraphs evil-vars autorevert filenotify saveplace diminish
use-package use-package-ensure use-package-delight use-package-diminish
use-package-bind-key bind-key use-package-core finder-inf org-element
avl-tree generator org advice org-macro org-footnote org-pcomplete
pcomplete org-list org-faces org-entities time-date noutline outline
easy-mmode org-version ob-emacs-lisp ob ob-tangle org-src ob-ref ob-lob
ob-table ob-keys ob-exp ob-comint comint ansi-color ring ob-core ob-eval
org-compat org-macs org-loaddefs format-spec find-func cal-menu calendar
cal-loaddefs rx cl-extra help-mode proof-site proof-autoloads edmacro
kmacro info package easymenu browse-url url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache json subr-x map url-vars seq byte-opt gv bytecomp
byte-compile cconv cl-loaddefs cl-lib tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads dbusbind inotify dynamic-setting system-font-setting
font-render-setting xwidget-internal cairo move-toolbar gtk x-toolkit x
multi-tty make-network-process emacs)

Memory information:
((conses 16 672434 60435)
 (symbols 48 42799 6)
 (strings 32 200345 8564)
 (string-bytes 1 6847260)
 (vectors 16 90639)
 (vector-slots 8 1773190 53886)
 (floats 8 464 834)
 (intervals 56 5460 2974)
 (buffers 992 23)
 (heap 1024 64379 13426))