GNU bug report logs - #33695
27.0.50; which-function reports wrong imenu information

Previous Next

Package: emacs;

Reported by: Alex Branham <alex.branham <at> gmail.com>

Date: Mon, 10 Dec 2018 18:59:02 UTC

Severity: normal

Found in version 27.0.50

Done: Alex Branham <alex.branham <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 33695 in the body.
You can then email your comments to 33695 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#33695; Package emacs. (Mon, 10 Dec 2018 18:59:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Alex Branham <alex.branham <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 10 Dec 2018 18:59:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Alex Branham <alex.branham <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.50; which-function reports wrong imenu information
Date: Mon, 10 Dec 2018 12:58:25 -0600
(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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33695; Package emacs. (Tue, 11 Dec 2018 08:36:04 GMT) Full text and rfc822 format available.

Message #8 received at 33695 <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Alex Branham <alex.branham <at> gmail.com>, 33695 <at> debbugs.gnu.org
Subject: Re: bug#33695: 27.0.50; which-function reports wrong imenu information
Date: Tue, 11 Dec 2018 09:35:08 +0100
> - 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.

martin




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33695; Package emacs. (Tue, 11 Dec 2018 14:34:02 GMT) Full text and rfc822 format available.

Message #11 received at 33695 <at> debbugs.gnu.org (full text, mbox):

From: Alex Branham <alex.branham <at> gmail.com>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 33695 <at> debbugs.gnu.org
Subject: Re: bug#33695: 27.0.50; which-function reports wrong imenu information
Date: Tue, 11 Dec 2018 08:32:54 -0600
On Tue 11 Dec 2018 at 02:35, martin rudalics <rudalics <at> 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 <at> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33695; Package emacs. (Wed, 12 Dec 2018 08:32:02 GMT) Full text and rfc822 format available.

Message #14 received at 33695 <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Alex Branham <alex.branham <at> gmail.com>
Cc: 33695 <at> debbugs.gnu.org
Subject: Re: bug#33695: 27.0.50; which-function reports wrong imenu information
Date: Wed, 12 Dec 2018 09:31:41 +0100
> Thanks for the reply. This seems to work well, though I haven't tried it
> in an enormous buffer.

Maybe we should make it optional so people on slower machines have the
choice.  I have no opinion because I don't use 'which-func-mode' hence
people who do should chime in.

For me the idea of calculating all function position in a buffer and
afterwards have 'which-func-mode' scan them to find out which function
point is in, strikes me as enormous over-kill.  In particular with
'syntax-ppss' around which usually should, without any additional
cost, provide the position where the current functions starts via the
9th element of its return value.  But don't let these rantings
distract you.

martin




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33695; Package emacs. (Wed, 12 Dec 2018 22:55:02 GMT) Full text and rfc822 format available.

Message #17 received at 33695 <at> debbugs.gnu.org (full text, mbox):

From: Alex Branham <alex.branham <at> gmail.com>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 33695 <at> debbugs.gnu.org
Subject: Re: bug#33695: 27.0.50; which-function reports wrong imenu information
Date: Wed, 12 Dec 2018 16:53:59 -0600
On Wed 12 Dec 2018 at 02:31, martin rudalics <rudalics <at> gmx.at> wrote:

>> Thanks for the reply. This seems to work well, though I haven't tried it
>> in an enormous buffer.
>
> Maybe we should make it optional so people on slower machines have the
> choice.  I have no opinion because I don't use 'which-func-mode' hence
> people who do should chime in.
>
> For me the idea of calculating all function position in a buffer and
> afterwards have 'which-func-mode' scan them to find out which function
> point is in, strikes me as enormous over-kill.  In particular with
> 'syntax-ppss' around which usually should, without any additional
> cost, provide the position where the current functions starts via the
> 9th element of its return value.  But don't let these rantings
> distract you.

That won't help with non-lispy languages like R or python though, I
don't think.

Perhaps we should reverse the order of what which-function checks? It
currently looks at:

1. which-func-functions
2. imenu--index-alist
3. add-log-current-defun

but we could switch those last two. add-log-current-defun should be
faster than reconstructing imenu--index-alist.

Alex




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33695; Package emacs. (Thu, 13 Dec 2018 09:02:02 GMT) Full text and rfc822 format available.

Message #20 received at 33695 <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Alex Branham <alex.branham <at> gmail.com>
Cc: 33695 <at> debbugs.gnu.org
Subject: Re: bug#33695: 27.0.50; which-function reports wrong imenu information
Date: Thu, 13 Dec 2018 10:01:18 +0100
>> For me the idea of calculating all function position in a buffer and
>> afterwards have 'which-func-mode' scan them to find out which function
>> point is in, strikes me as enormous over-kill.  In particular with
>> 'syntax-ppss' around which usually should, without any additional
>> cost, provide the position where the current functions starts via the
>> 9th element of its return value.  But don't let these rantings
>> distract you.
>
> That won't help with non-lispy languages like R or python though, I
> don't think.

IIUC 'python-info-looking-at-beginning-of-defun' uses 'syntax-ppss'
while for example 'c-beginning-of-defun' doesn't.

I understand that the implementors of which-func chose the most simple
existing way to get the function point is in.  But it amounts to
having 'beginning-of-defun' always construct a list of the positions
of all function definitions in a buffer to find the first one before
point.  With wich-func a user won't notice the effect because it's
done when Emacs is idle.  Still it's not ecological.

> Perhaps we should reverse the order of what which-function checks? It
> currently looks at:
>
> 1. which-func-functions
> 2. imenu--index-alist
> 3. add-log-current-defun
>
> but we could switch those last two. add-log-current-defun should be
> faster than reconstructing imenu--index-alist.

I think so.  But I'm afraid it's not well supported everywhere.
Anyway, as I already said don't let my remarks distract you.

martin




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33695; Package emacs. (Wed, 19 Dec 2018 15:44:02 GMT) Full text and rfc822 format available.

Message #23 received at 33695 <at> debbugs.gnu.org (full text, mbox):

From: Alex Branham <alex.branham <at> gmail.com>
To: 33695 <at> debbugs.gnu.org
Cc: martin rudalics <rudalics <at> gmx.at>
Subject: [PATCH] Fix which-function reporting outdated information
Date: Wed, 19 Dec 2018 09:42:51 -0600
[Message part 1 (text/plain, inline)]
Hello -

The following patch fixes `which-function' returning outdated imenu
information by:

1. Preferring `add-log-current-defun' over `imenu--index-alist' and

2. Updating `imenu--index-alist' more aggressively if we fall back to
it.

Thanks,
Alex

From a06b1318f23b3f67ed0e1041f50ccea67d46ea48 Mon Sep 17 00:00:00 2001
From: Alex Branham <alex.branham <at> 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): Check
  `add-log-current-defun' before imenu. Update `imenu--index-alist' if
  needed. Bug #33695
---
 lisp/progmodes/which-func.el | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el
index 7604be0c25..7cc75e0edb 100644
--- a/lisp/progmodes/which-func.el
+++ b/lisp/progmodes/which-func.el
@@ -272,16 +272,21 @@ which-func-functions
 
 (defun which-function ()
   "Return current function name based on point.
-Uses `which-func-functions', `imenu--index-alist'
-or `add-log-current-defun'.
+Uses `which-func-functions', `add-log-current-defun'.
+or `imenu--index-alist'
 If no function name is found, return nil."
   (let ((name
 	 ;; Try the `which-func-functions' functions first.
 	 (run-hook-with-args-until-success 'which-func-functions)))
-
+    ;; Try using add-log support.
+    (when (null name)
+      (setq name (add-log-current-defun)))
     ;; 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
@@ -323,10 +328,6 @@ which-function
                              (funcall
                               which-func-imenu-joiner-function
                               (reverse (cons (car pair) namestack))))))))))))
-
-    ;; Try using add-log support.
-    (when (null name)
-      (setq name (add-log-current-defun)))
     ;; Filter the name if requested.
     (when name
       (if which-func-cleanup-function
-- 
2.19.2



[0001-which-function-Do-not-display-outdated-imenu-informa.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33695; Package emacs. (Thu, 10 Jan 2019 19:56:01 GMT) Full text and rfc822 format available.

Message #26 received at 33695 <at> debbugs.gnu.org (full text, mbox):

From: Alex Branham <alex.branham <at> gmail.com>
To: 33695 <at> debbugs.gnu.org
Subject: Re: [PATCH] Fix which-function reporting outdated information
Date: Thu, 10 Jan 2019 13:55:48 -0600
[Message part 1 (text/plain, inline)]
Hi -

I guess this fell through the cracks with the holidays. Would someone
mind following up with either comments or applying this patch?

Thanks,
Alex

On Wed 19 Dec 2018 at 09:42, Alex Branham <alex.branham <at> gmail.com> wrote:

> Hello -
>
> The following patch fixes `which-function' returning outdated imenu
> information by:
>
> 1. Preferring `add-log-current-defun' over `imenu--index-alist' and
>
> 2. Updating `imenu--index-alist' more aggressively if we fall back to
> it.
>
> Thanks,
> Alex
>
> From a06b1318f23b3f67ed0e1041f50ccea67d46ea48 Mon Sep 17 00:00:00 2001
> From: Alex Branham <alex.branham <at> 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): Check
>   `add-log-current-defun' before imenu. Update `imenu--index-alist' if
>   needed. Bug #33695
> ---
>  lisp/progmodes/which-func.el | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el
> index 7604be0c25..7cc75e0edb 100644
> --- a/lisp/progmodes/which-func.el
> +++ b/lisp/progmodes/which-func.el
> @@ -272,16 +272,21 @@ which-func-functions
>
>  (defun which-function ()
>    "Return current function name based on point.
> -Uses `which-func-functions', `imenu--index-alist'
> -or `add-log-current-defun'.
> +Uses `which-func-functions', `add-log-current-defun'.
> +or `imenu--index-alist'
>  If no function name is found, return nil."
>    (let ((name
>  	 ;; Try the `which-func-functions' functions first.
>  	 (run-hook-with-args-until-success 'which-func-functions)))
> -
> +    ;; Try using add-log support.
> +    (when (null name)
> +      (setq name (add-log-current-defun)))
>      ;; 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
> @@ -323,10 +328,6 @@ which-function
>                               (funcall
>                                which-func-imenu-joiner-function
>                                (reverse (cons (car pair) namestack))))))))))))
> -
> -    ;; Try using add-log support.
> -    (when (null name)
> -      (setq name (add-log-current-defun)))
>      ;; Filter the name if requested.
>      (when name
>        (if which-func-cleanup-function
> --
> 2.19.2
>
>
>
> From a06b1318f23b3f67ed0e1041f50ccea67d46ea48 Mon Sep 17 00:00:00 2001
> From: Alex Branham <alex.branham <at> 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): Check
>   `add-log-current-defun' before imenu. Update `imenu--index-alist' if
>   needed. Bug #33695
> ---
>  lisp/progmodes/which-func.el | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el
> index 7604be0c25..7cc75e0edb 100644
> --- a/lisp/progmodes/which-func.el
> +++ b/lisp/progmodes/which-func.el
> @@ -272,16 +272,21 @@ which-func-functions
>
>  (defun which-function ()
>    "Return current function name based on point.
> -Uses `which-func-functions', `imenu--index-alist'
> -or `add-log-current-defun'.
> +Uses `which-func-functions', `add-log-current-defun'.
> +or `imenu--index-alist'
>  If no function name is found, return nil."
>    (let ((name
>  	 ;; Try the `which-func-functions' functions first.
>  	 (run-hook-with-args-until-success 'which-func-functions)))
> -
> +    ;; Try using add-log support.
> +    (when (null name)
> +      (setq name (add-log-current-defun)))
>      ;; 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
> @@ -323,10 +328,6 @@ which-function
>                               (funcall
>                                which-func-imenu-joiner-function
>                                (reverse (cons (car pair) namestack))))))))))))
> -
> -    ;; Try using add-log support.
> -    (when (null name)
> -      (setq name (add-log-current-defun)))
>      ;; Filter the name if requested.
>      (when name
>        (if which-func-cleanup-function

[0001-which-function-Do-not-display-outdated-imenu-informa.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#33695; Package emacs. (Tue, 19 Feb 2019 21:31:01 GMT) Full text and rfc822 format available.

Message #29 received at 33695 <at> debbugs.gnu.org (full text, mbox):

From: Alex Branham <alex.branham <at> gmail.com>
To: 33695 <at> debbugs.gnu.org
Subject: Re: [PATCH] Fix which-function reporting outdated information
Date: Tue, 19 Feb 2019 15:29:51 -0600
[Message part 1 (text/plain, inline)]
Hi all -

Assuming no objections, I'll apply the patch below to master later this week.

Alex

On Thu 10 Jan 2019 at 13:55, Alex Branham <alex.branham <at> gmail.com> wrote:

> Hi -
>
> I guess this fell through the cracks with the holidays. Would someone
> mind following up with either comments or applying this patch?
>
> Thanks,
> Alex
>
> On Wed 19 Dec 2018 at 09:42, Alex Branham <alex.branham <at> gmail.com> wrote:
>
>> Hello -
>>
>> The following patch fixes `which-function' returning outdated imenu
>> information by:
>>
>> 1. Preferring `add-log-current-defun' over `imenu--index-alist' and
>>
>> 2. Updating `imenu--index-alist' more aggressively if we fall back to
>> it.
>>
>> Thanks,
>> Alex
>>
>> From a06b1318f23b3f67ed0e1041f50ccea67d46ea48 Mon Sep 17 00:00:00 2001
>> From: Alex Branham <alex.branham <at> 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): Check
>>   `add-log-current-defun' before imenu. Update `imenu--index-alist' if
>>   needed. Bug #33695
>> ---
>>  lisp/progmodes/which-func.el | 17 +++++++++--------
>>  1 file changed, 9 insertions(+), 8 deletions(-)
>>
>> diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el
>> index 7604be0c25..7cc75e0edb 100644
>> --- a/lisp/progmodes/which-func.el
>> +++ b/lisp/progmodes/which-func.el
>> @@ -272,16 +272,21 @@ which-func-functions
>>
>>  (defun which-function ()
>>    "Return current function name based on point.
>> -Uses `which-func-functions', `imenu--index-alist'
>> -or `add-log-current-defun'.
>> +Uses `which-func-functions', `add-log-current-defun'.
>> +or `imenu--index-alist'
>>  If no function name is found, return nil."
>>    (let ((name
>>  	 ;; Try the `which-func-functions' functions first.
>>  	 (run-hook-with-args-until-success 'which-func-functions)))
>> -
>> +    ;; Try using add-log support.
>> +    (when (null name)
>> +      (setq name (add-log-current-defun)))
>>      ;; 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
>> @@ -323,10 +328,6 @@ which-function
>>                               (funcall
>>                                which-func-imenu-joiner-function
>>                                (reverse (cons (car pair) namestack))))))))))))
>> -
>> -    ;; Try using add-log support.
>> -    (when (null name)
>> -      (setq name (add-log-current-defun)))
>>      ;; Filter the name if requested.
>>      (when name
>>        (if which-func-cleanup-function
>> --
>> 2.19.2
>>
>>
>>
>> From a06b1318f23b3f67ed0e1041f50ccea67d46ea48 Mon Sep 17 00:00:00 2001
>> From: Alex Branham <alex.branham <at> 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): Check
>>   `add-log-current-defun' before imenu. Update `imenu--index-alist' if
>>   needed. Bug #33695
>> ---
>>  lisp/progmodes/which-func.el | 17 +++++++++--------
>>  1 file changed, 9 insertions(+), 8 deletions(-)
>>
>> diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el
>> index 7604be0c25..7cc75e0edb 100644
>> --- a/lisp/progmodes/which-func.el
>> +++ b/lisp/progmodes/which-func.el
>> @@ -272,16 +272,21 @@ which-func-functions
>>
>>  (defun which-function ()
>>    "Return current function name based on point.
>> -Uses `which-func-functions', `imenu--index-alist'
>> -or `add-log-current-defun'.
>> +Uses `which-func-functions', `add-log-current-defun'.
>> +or `imenu--index-alist'
>>  If no function name is found, return nil."
>>    (let ((name
>>  	 ;; Try the `which-func-functions' functions first.
>>  	 (run-hook-with-args-until-success 'which-func-functions)))
>> -
>> +    ;; Try using add-log support.
>> +    (when (null name)
>> +      (setq name (add-log-current-defun)))
>>      ;; 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
>> @@ -323,10 +328,6 @@ which-function
>>                               (funcall
>>                                which-func-imenu-joiner-function
>>                                (reverse (cons (car pair) namestack))))))))))))
>> -
>> -    ;; Try using add-log support.
>> -    (when (null name)
>> -      (setq name (add-log-current-defun)))
>>      ;; Filter the name if requested.
>>      (when name
>>        (if which-func-cleanup-function
>
> From a06b1318f23b3f67ed0e1041f50ccea67d46ea48 Mon Sep 17 00:00:00 2001
> From: Alex Branham <alex.branham <at> 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): Check
>   `add-log-current-defun' before imenu. Update `imenu--index-alist' if
>   needed. Bug #33695
> ---
>  lisp/progmodes/which-func.el | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el
> index 7604be0c25..7cc75e0edb 100644
> --- a/lisp/progmodes/which-func.el
> +++ b/lisp/progmodes/which-func.el
> @@ -272,16 +272,21 @@ which-func-functions
>
>  (defun which-function ()
>    "Return current function name based on point.
> -Uses `which-func-functions', `imenu--index-alist'
> -or `add-log-current-defun'.
> +Uses `which-func-functions', `add-log-current-defun'.
> +or `imenu--index-alist'
>  If no function name is found, return nil."
>    (let ((name
>  	 ;; Try the `which-func-functions' functions first.
>  	 (run-hook-with-args-until-success 'which-func-functions)))
> -
> +    ;; Try using add-log support.
> +    (when (null name)
> +      (setq name (add-log-current-defun)))
>      ;; 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
> @@ -323,10 +328,6 @@ which-function
>                               (funcall
>                                which-func-imenu-joiner-function
>                                (reverse (cons (car pair) namestack))))))))))))
> -
> -    ;; Try using add-log support.
> -    (when (null name)
> -      (setq name (add-log-current-defun)))
>      ;; Filter the name if requested.
>      (when name
>        (if which-func-cleanup-function
[signature.asc (application/pgp-signature, inline)]

Reply sent to Alex Branham <alex.branham <at> gmail.com>:
You have taken responsibility. (Fri, 22 Feb 2019 21:29:02 GMT) Full text and rfc822 format available.

Notification sent to Alex Branham <alex.branham <at> gmail.com>:
bug acknowledged by developer. (Fri, 22 Feb 2019 21:29:02 GMT) Full text and rfc822 format available.

Message #34 received at 33695-done <at> debbugs.gnu.org (full text, mbox):

From: Alex Branham <alex.branham <at> gmail.com>
To: 33695-done <at> debbugs.gnu.org
Subject: Re: [PATCH] Fix which-function reporting outdated information
Date: Fri, 22 Feb 2019 15:28:25 -0600
Committed as 0613e7a38efc3b0534e0ca5c5fa401e2a3bda906 in what will be Emacs 27





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 23 Mar 2019 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 106 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.