Subject: bug#61436: Emacs Freezing With Java Files

From: Jens Schmidt <[email-masked]>
Date: Fri, 13 Oct 2023 22:42:04 +0200

Hi Alan,

Alan Mackenzie <[email-masked]> writes:

> To solve the bug, I'm amending the macro c-beginning-of-defun-1 so that
> it only stops at a debug-prompt-regexp position when it also found a {.
> Otherwise it will keep looping until it finds a better position or BOB.

Thanks.

> Then please confirm that the bug is
> indeed fixed.

For the fun of it I tried Hank's initial testcase as well, which is a
bit less straight-forward to set up.  The freezes are indeed gone with
your patch.  But I noticed that which-function-mode, when rapidly moving
through the file, cannot always determine the current function name,
then displaying "[n/a]" in the mode line.

And indeed, when executing the simplified test case

  ./src/emacs -Q -l ~/tmp/init.el +181 ~/tmp/P1.java

and then immediately hitting C-M-a, point jumps to the beginning of the
preceeding catch clause (point=5779 of 18142) instead of BOD.

This behavior is again tied to the `defun-prompt-regexp' used by
Hyperbole - without that regexp C-M-a jumps to the real BOD.