unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#33695: 27.0.50; which-function reports wrong imenu information
@ 2018-12-10 18:58 Alex Branham
  2018-12-11  8:35 ` martin rudalics
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Alex Branham @ 2018-12-10 18:58 UTC (permalink / raw)
  To: 33695

(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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#33695: 27.0.50; which-function reports wrong imenu information
  2018-12-10 18:58 bug#33695: 27.0.50; which-function reports wrong imenu information Alex Branham
@ 2018-12-11  8:35 ` martin rudalics
  2018-12-11 14:32   ` Alex Branham
  2018-12-19 15:42 ` bug#33695: [PATCH] Fix which-function reporting outdated information Alex Branham
  2019-01-10 19:55 ` Alex Branham
  2 siblings, 1 reply; 10+ messages in thread
From: martin rudalics @ 2018-12-11  8:35 UTC (permalink / raw)
  To: Alex Branham, 33695

 > - 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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#33695: 27.0.50; which-function reports wrong imenu information
  2018-12-11  8:35 ` martin rudalics
@ 2018-12-11 14:32   ` Alex Branham
  2018-12-12  8:31     ` martin rudalics
  0 siblings, 1 reply; 10+ messages in thread
From: Alex Branham @ 2018-12-11 14:32 UTC (permalink / raw)
  To: martin rudalics; +Cc: 33695


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





^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#33695: 27.0.50; which-function reports wrong imenu information
  2018-12-11 14:32   ` Alex Branham
@ 2018-12-12  8:31     ` martin rudalics
  2018-12-12 22:53       ` Alex Branham
  0 siblings, 1 reply; 10+ messages in thread
From: martin rudalics @ 2018-12-12  8:31 UTC (permalink / raw)
  To: Alex Branham; +Cc: 33695

 > 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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#33695: 27.0.50; which-function reports wrong imenu information
  2018-12-12  8:31     ` martin rudalics
@ 2018-12-12 22:53       ` Alex Branham
  2018-12-13  9:01         ` martin rudalics
  0 siblings, 1 reply; 10+ messages in thread
From: Alex Branham @ 2018-12-12 22:53 UTC (permalink / raw)
  To: martin rudalics; +Cc: 33695


On Wed 12 Dec 2018 at 02:31, martin rudalics <rudalics@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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#33695: 27.0.50; which-function reports wrong imenu information
  2018-12-12 22:53       ` Alex Branham
@ 2018-12-13  9:01         ` martin rudalics
  0 siblings, 0 replies; 10+ messages in thread
From: martin rudalics @ 2018-12-13  9:01 UTC (permalink / raw)
  To: Alex Branham; +Cc: 33695

 >> 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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#33695: [PATCH] Fix which-function reporting outdated information
  2018-12-10 18:58 bug#33695: 27.0.50; which-function reports wrong imenu information Alex Branham
  2018-12-11  8:35 ` martin rudalics
@ 2018-12-19 15:42 ` Alex Branham
  2019-01-10 19:55 ` Alex Branham
  2 siblings, 0 replies; 10+ messages in thread
From: Alex Branham @ 2018-12-19 15:42 UTC (permalink / raw)
  To: 33695

[-- Attachment #1: Type: text/plain, Size: 2397 bytes --]

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@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




[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-which-function-Do-not-display-outdated-imenu-informa.patch --]
[-- Type: text/x-patch, Size: 2143 bytes --]

From a06b1318f23b3f67ed0e1041f50ccea67d46ea48 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): 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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#33695: [PATCH] Fix which-function reporting outdated information
  2018-12-10 18:58 bug#33695: 27.0.50; which-function reports wrong imenu information Alex Branham
  2018-12-11  8:35 ` martin rudalics
  2018-12-19 15:42 ` bug#33695: [PATCH] Fix which-function reporting outdated information Alex Branham
@ 2019-01-10 19:55 ` Alex Branham
  2019-02-19 21:29   ` Alex Branham
  2019-02-22 21:28   ` Alex Branham
  2 siblings, 2 replies; 10+ messages in thread
From: Alex Branham @ 2019-01-10 19:55 UTC (permalink / raw)
  To: 33695

[-- Attachment #1: Type: text/plain, Size: 4989 bytes --]

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@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@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@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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-which-function-Do-not-display-outdated-imenu-informa.patch --]
[-- Type: text/x-patch, Size: 2143 bytes --]

From a06b1318f23b3f67ed0e1041f50ccea67d46ea48 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): 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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#33695: [PATCH] Fix which-function reporting outdated information
  2019-01-10 19:55 ` Alex Branham
@ 2019-02-19 21:29   ` Alex Branham
  2019-02-22 21:28   ` Alex Branham
  1 sibling, 0 replies; 10+ messages in thread
From: Alex Branham @ 2019-02-19 21:29 UTC (permalink / raw)
  To: 33695

[-- Attachment #1: Type: text/plain, Size: 7533 bytes --]

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@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@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@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@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@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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#33695: [PATCH] Fix which-function reporting outdated information
  2019-01-10 19:55 ` Alex Branham
  2019-02-19 21:29   ` Alex Branham
@ 2019-02-22 21:28   ` Alex Branham
  1 sibling, 0 replies; 10+ messages in thread
From: Alex Branham @ 2019-02-22 21:28 UTC (permalink / raw)
  To: 33695-done

Committed as 0613e7a38efc3b0534e0ca5c5fa401e2a3bda906 in what will be Emacs 27






^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-02-22 21:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-10 18:58 bug#33695: 27.0.50; which-function reports wrong imenu information Alex Branham
2018-12-11  8:35 ` martin rudalics
2018-12-11 14:32   ` Alex Branham
2018-12-12  8:31     ` martin rudalics
2018-12-12 22:53       ` Alex Branham
2018-12-13  9:01         ` martin rudalics
2018-12-19 15:42 ` bug#33695: [PATCH] Fix which-function reporting outdated information Alex Branham
2019-01-10 19:55 ` Alex Branham
2019-02-19 21:29   ` Alex Branham
2019-02-22 21:28   ` Alex Branham

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).