bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Alex Branham
Subject: bug#33695: 27.0.50; which-function reports wrong imenu information
Date: Tue, 11 Dec 2018 08:32:54 -0600
User-agent: mu4e 1.1.0; emacs 27.0.50

On Tue 11 Dec 2018 at 02:35, martin rudalics <rudalics@gmx.at> wrote:

>> - Have `which-function' update `imenu--index-alist' before checking it
>>    (also easy to implement, but updating the index could be slow in large
>>    buffers)
>
> Maybe we should try to do what 'imenu-update-menubar' does here:
> Compare the values of 'imenu-menubar-modified-tick' and
> 'buffer-chars-modified-tick' and update 'imenu--index-alist' if they
> differ.

Thanks for the reply. This seems to work well, though I haven't tried it
in an enormous buffer.

Alex

>From d794595fdbaff40df2f7769b22dd05a7786e56e7 Mon Sep 17 00:00:00 2001
From: Alex Branham <alex.branham@gmail.com>
Date: Tue, 11 Dec 2018 08:29:50 -0600
Subject: [PATCH] which-function: Do not display outdated imenu information

* lisp/progmodes/which-func.el (which-function): Update
  imenu--index-alist if needed. Bug #33695
---
 lisp/progmodes/which-func.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el
index 7604be0c25..bbdfa2fff7 100644
--- a/lisp/progmodes/which-func.el
+++ b/lisp/progmodes/which-func.el
@@ -281,7 +281,10 @@ which-function

     ;; If Imenu is loaded, try to make an index alist with it.
     (when (and (null name)
-              (boundp 'imenu--index-alist) (null imenu--index-alist)
+              (boundp 'imenu--index-alist)
+               (or (null imenu--index-alist)
+                   ;; Update if outdated
+                   (/= (buffer-chars-modified-tick) 
imenu-menubar-modified-tick))
               (null which-function-imenu-failed))
       (ignore-errors (imenu--make-index-alist t))
       (unless imenu--index-alist
--
2.19.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]