Re: bug#74934: 30.0.92; Unexpected behavior by which-function-mode in erc-mode buffers

"J.P." <[email protected]> Wed, 18 Dec 2024 08:27:04 -0800
Newsgroups gmane.emacs.erc.general
Message-ID <[email protected]>
Eli Zaretskii <[email protected]> writes:

>> Cc: [email protected], [email protected]
>> From: "J.P." <[email protected]>
>> Date: Tue, 17 Dec 2024 18:24:02 -0800
>>=20
>> > steps to reproduce:
>> > emacs --no-init
>> > M-x erc
>> > ;; join some channel.
>> > M-x which-function-mode
>> >
>> > Current behavior:
>> > In erc buffers, which-function-mode displays either "[n/a]" or a strin=
g based on
>> > the chat history in the mode line.
>>=20
>> FTR, I'm able to reproduce it.
>>=20
>> > Expected behavior:
>> > which-function-mode shouldn=E2=80=99t be adding any string to mode lin=
e in erc buffers
>>=20
>> The first of the attached patches should hopefully address the issue.
>
> Is this for the release branch?  That is, is this a recent regression?

No, this is for Emacs master (and ERC 5.6.1). AFAICT, the bug has been
with us since at least Emacs 26.3, although "[n/a]" used to be "[???]".

>
> And if so, what is the second patch for?

For anyone wondering, the second patch is for contributors working on
ERC (I will add a news item). If you load ERC and invoke the function
`erc-imenu-add-devel-patterns' in your config, your next visit to
erc-backend.el should allow you to see something like

  ERC response 311 314
  ERC response 312
  ERC response 313
  ERC response 315 318 323 369
  ERC response 317
  ERC response 319
  ERC response 311

after typing

  M-x imenu <RET> 31 <TAB>

(whereas before you'd see nothing). Hitting RET on the first candidate
should take you to

  (define-erc-response-handler (311 314)
    "WHOIS/WHOWAS notices." nil ...)

As mentioned in the comment, I'd much rather it generate something like

  erc-server-311
  erc-server-314
  ...
  erc-server-311

but I don't know how to do that or if it's even possible. (If anyone out
there has any clues, please share. TIA.)