Subject: Re: bug#71068: 30.0.50; Incorrect xref positions for eglot-execute

From: Eshel Yaron <[email-masked]>
Date: Mon, 03 Jun 2024 07:47:29 +0200

Hi Dmitry,

Dmitry Gutov <[email-masked]> writes:

> On 26/05/2024 11:00, Eshel Yaron wrote:
>> +    (or (and (re-search-forward (format cl--generic-find-defgeneric-regexp name)
>> +                                nil t)
>> +             (or (funcall search ":method[ \t\n]+"
>> +                          (save-excursion (end-of-defun) (point)))
>> +                 (not (goto-char (point-min)))))
>> +        (funcall search base-re)
>
> Should the second clause also be wrapped in some save-excursion or similar?

Do you mean the (funcall search base-re) part?  If so, then no, it
doesn't need save-excursion because it just calls re-search-forward,
which doesn't move point when the search fails.

> And I'd probably change the order (looking for the variations on
> defmethod first), but that's not too important.

Actually I think neither order is quite correct for all cases, because the
regex we construct is currently too lax: if we're searching for a method
definition with no specializers, it also matches definitions with
specializers.  So ISTM that this needs some more work to get right.
If no one beats me to it, I'll look into it when I have some time.

Best,

Eshel