Subject: bug#39972: 28.0.50; which-function no longer returning current Java method in Emacs 27

From: Alan Mackenzie <[email-masked]>
Date: Thu, 21 May 2020 20:19:35 +0000

Hello, Eli.

On Thu, May 21, 2020 at 22:14:24 +0300, Eli Zaretskii wrote:
> > Date: Thu, 21 May 2020 17:42:11 +0000
> > Cc: Philipp Stephani <[email-masked]>, [email-masked]
> > From: Alan Mackenzie <[email-masked]>

> > > Is it possible to come up with something simpler for emacs-27?

> > I think the change (in master) to CC Mode's value of
> > add-log-current-defun could be put into emacs-27 on its own.  This should
> > be safe.

> > The patch which made this change (bug #39972) was:
> > 5989432d15feb4439e759d2c0e28233ca22a7604
> > "CC Mode: Fix bug #39972, by fixing c-display-defun-name for nested
> > defuns"
> > Date:   Wed May 20 19:02:26 2020 +0000.

> > What do you say to putting this into emacs-27?

> If it fixes the problem reported in this bug report, it's fine by me
> to cherry-pick it to emacs-27.

I've just tried it, and it almost fixes the problem.  :-(

With that commit cherry-picked to emacs-27, visit the Java file:

class Foo {
    void bar() {
    // body
    }
}

, and enable which-function-mode.  When point is within class Foo or bar,
which-function-mode reports "class Foo" or "bar" correctly.

But when point is _after_ the terminating brace of class Foo, "bar" is
wrongly reported.  I now remember that this is the reason for my
amendment to which-func.el.

Sorry to trouble you with such a minor point, but I'm unable to decide
myself whether such a small bug should prevent the cherry-picking of
5989432 into emacs-27.  I'm leaning towards doing the cherry-pick.

So, please help me by making the decision.  Thanks!

> Thanks.

-- 
Alan Mackenzie (Nuremberg, Germany).