GNU bug report logs - #65578
Eglot with mouse

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Mon, 28 Aug 2023 07:35:01 UTC

Severity: normal

Fixed in version 30.1

Done: Dmitry Gutov <dmitry <at> gutov.dev>

Bug is archived. No further changes may be made.

Full log


Message #17 received at 65578 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dmitry <at> gutov.dev>
To: Juri Linkov <juri <at> linkov.net>
Cc: 65578 <at> debbugs.gnu.org,
 João Távora <joaotavora <at> gmail.com>
Subject: Re: bug#65578: Eglot with mouse
Date: Mon, 28 Aug 2023 20:00:12 +0300
On 28/08/2023 19:42, Juri Linkov wrote:
>>> xref-find-definitions-at-mouse uses save-excursion with
>>> mouse-set-point before calling xref-backend-identifier-at-point.
>>> But the same save-excursion with mouse-set-point can't be added
>>> around xref-find-definitions because save-excursion will restore
>>> the original position after visiting the found identifier.
>> Could we do that without additional save-excursion?
>>
>> diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
>> index 0666b18cba1..0c3e34fe0a5 100644
>> --- a/lisp/progmodes/xref.el
>> +++ b/lisp/progmodes/xref.el
>> @@ -1637,7 +1637,9 @@ xref-find-definitions-at-mouse
>>              (mouse-set-point event)
>>              (xref-backend-identifier-at-point (xref-find-backend)))))
>>       (if identifier
>> -        (xref-find-definitions identifier)
>> +        (progn
>> +          (mouse-set-point event)
>> +          (xref-find-definitions identifier))
>>         (user-error "No identifier here"))))
> The problem with this solution is that when it doesn't find
> the identifier then it leaves point at the wrong place.

I'm not sure is a big problem, but we could save the original position 
and restore it in case of error too:

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 0666b18cba1..fb7380dee77 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -1635,9 +1635,18 @@ xref-find-definitions-at-mouse
   (let ((identifier
          (save-excursion
            (mouse-set-point event)
-           (xref-backend-identifier-at-point (xref-find-backend)))))
+           (xref-backend-identifier-at-point (xref-find-backend))))
+        (buf (current-buffer))
+        (pos (point)))
     (if identifier
-        (xref-find-definitions identifier)
+        (condition-case err
+          (progn
+            (mouse-set-point event)
+            (xref-find-definitions identifier))
+          (user-error
+           (set-buffer buf)
+           (goto-char pos)
+           (user-error (message (error-message-string err)))))
       (user-error "No identifier here"))))

 ;;;###autoload





This bug report was last modified 1 year and 323 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.