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

From: Alex Branham <[email-masked]>
Date: Wed, 12 Dec 2018 16:53:59 -0600

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