Subject: bug#33695: closed (Re: [PATCH] Fix which-function reporting outdated information)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 22 Feb 2019 21:29:02 +0000

Your bug report

#33695: 27.0.50; which-function reports wrong imenu information

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
33695: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=33695
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: [PATCH] Fix which-function reporting outdated information
From: Alex Branham <[email-masked]>
To: [email-masked]
Date: Fri, 22 Feb 2019 15:28:25 -0600
List-Id: <debbugs-submit.debbugs.gnu.org>

Committed as 0613e7a38efc3b0534e0ca5c5fa401e2a3bda906 in what will be Emacs 27

Subject: 27.0.50; which-function reports wrong imenu information
From: Alex Branham <[email-masked]>
To: [email-masked]
Date: Mon, 10 Dec 2018 12:58:25 -0600
List-Id: <debbugs-submit.debbugs.gnu.org>

(which-function) can report outdated information because it relies on
imenu--index-alist. To see what I'm talking about, from emacs -q:

M-x which-function-mode RET

type:
    (defun test () "foo" (ignore))

M-x imenu *Rescan* RET C-g

type:
    (defun test2 () "bar" (ignore))

With point inside test2, (which-function) reports test (you'll see this
in the modeline) because it uses the (outdated) information in
`imenu--index-alist'.

I see a few potential fixes:

- Check `add-log-current-defun' before checking `imenu--index-alist' in
  `which-function' (easy, but falling back on imenu--index-alist could
  still report old info)

- Have `which-function' update `imenu--index-alist' before checking it
  (also easy to implement, but updating the index could be slow in large
  buffers)

- Something else

I'm happy to write up a patch, just let me know what solution is best.

Thanks,
Alex