Subject: Re: bug#54343: 28.0.91; find-function goes to a wrong place for erc

From: "J.P." <[email-masked]>
Date: Sun, 13 Mar 2022 13:12:12 -0700

Lars Ingebrigtsen <[email-masked]> writes:

> So I've now added that in Emacs 29, too.

Looks like the "def" part is missing from "defgeneric":

  diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
  index 777334a7a7..208d68d1ab 100644
  --- a/lisp/emacs-lisp/find-func.el
  +++ b/lisp/emacs-lisp/find-func.el
  @@ -61,7 +61,7 @@ find-function-regexp
   [...]
  -cl-\\(?:defun\\|defmethod\\)\\|\
  +cl-\\(?:defun\\|defmethod\\|generic\\)\\|\
                               ~~~~~~~

I'd used both in back-to-back examples (both def- and plain generic),
which was clearly a typo landmine (sorry).

> so perhaps longer term it would be nice if it was rewritten. And
> perhaps the logic should be "first look for these things, and if we
> don't find them, then look for these other things". That is, a
> priority thing.)

I was thinking much the same, albeit in a less evolved manner. The
alternate function form for the CDRs of `find-function-regexp-alist'
members may prove useful to do the prioritizing. Perhaps it'd even be
worthwhile to incorporate more refined strategies, when available, such
as the finders provided by cl-generic.el[1].

>> Just a benign optimization involving some culling of redundant code in
>> `erc--switch-to-buffer'. This email contains the latest version, with a
>> slightly revised commit message:
>>
>>   https://lists.gnu.org/archive/html/bug-gnu-emacs/2022-01/msg02081.html
>
> I think that makes sense?  But I haven't tested the patch.

I'm testing it indirectly (in yet another bug) but will add a unit test
for good measure and ping you in the other thread. Thanks.

[1] https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/emacs-lisp/cl-generic.el?id=dd91aac5#n995