all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#71435: interactive xref-find-definitions-at-mouse
@ 2024-06-08 15:28 Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-06-08 16:31 ` Eli Zaretskii
  2024-06-09 16:46 ` Juri Linkov
  0 siblings, 2 replies; 16+ messages in thread
From: Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-06-08 15:28 UTC (permalink / raw)
  To: 71435

[-- Attachment #1: Type: text/plain, Size: 1149 bytes --]

Many editors allow a mouse-click operation on an identifier, plus a
suitable modifier key, to jump to the declaration of the symbol. Emacs
provides xref-find-definitions-at-mouse, but I couldn't find a way to make
it work in response to a click. So I wrote this variant that works nicely
for me. Notably, it is an (interactive) command, and it doesn't use
save-excursion.

(defun xref-find-definitions-at-mouse-2 (event)
  "Find the definition of identifier at or around mouse click.
This command is intended to be bound to a mouse event."
  (interactive "e")
  (let ((identifier
          (progn
           (mouse-set-point event)
           (xref-backend-identifier-at-point (xref-find-backend)))))
    (if identifier
       (xref-find-definitions identifier)
      (user-error "No identifier here"))))

;; cmd-click -> jump to definition
(global-set-key (kbd "s-<mouse-1>") #'xref-find-definitions-at-mouse-2)

Could this functionality (not necessarily this code) be added to
Emacs's xref package? I am not enough of an Emacs expert to know whether I
was simply "holding it wrong", so perhaps this is merely a documentation
problem.

thanks
alan

[-- Attachment #2: Type: text/html, Size: 1424 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#71435: interactive xref-find-definitions-at-mouse
  2024-06-08 15:28 bug#71435: interactive xref-find-definitions-at-mouse Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-06-08 16:31 ` Eli Zaretskii
  2024-06-09 18:29   ` Stefan Kangas
  2024-06-09 16:46 ` Juri Linkov
  1 sibling, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2024-06-08 16:31 UTC (permalink / raw)
  To: Alan Donovan; +Cc: 71435

> Date: Sat, 8 Jun 2024 11:28:34 -0400
> From:  Alan Donovan via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> Many editors allow a mouse-click operation on an identifier, plus a suitable modifier key, to jump to the
> declaration of the symbol. Emacs provides xref-find-definitions-at-mouse, but I couldn't find a way to make it
> work in response to a click.

??? This works for me:

  (global-set-key [C-down-mouse-1] 'xref-find-definitions-at-mouse)





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#71435: interactive xref-find-definitions-at-mouse
  2024-06-08 15:28 bug#71435: interactive xref-find-definitions-at-mouse Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-06-08 16:31 ` Eli Zaretskii
@ 2024-06-09 16:46 ` Juri Linkov
  1 sibling, 0 replies; 16+ messages in thread
From: Juri Linkov @ 2024-06-09 16:46 UTC (permalink / raw)
  To: 71435; +Cc: adonovan

> ;; cmd-click -> jump to definition
> (global-set-key (kbd "s-<mouse-1>") #'xref-find-definitions-at-mouse-2)
>
> Could this functionality (not necessarily this code) be added to Emacs's
> xref package? I am not enough of an Emacs expert to know whether I was
> simply "holding it wrong", so perhaps this is merely a documentation
> problem.

There is the "Find Definition" item in the context menu enabled by context-menu-mode.





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#71435: interactive xref-find-definitions-at-mouse
  2024-06-08 16:31 ` Eli Zaretskii
@ 2024-06-09 18:29   ` Stefan Kangas
  2024-06-09 18:58     ` Eli Zaretskii
  2024-06-10  6:11     ` Philip Kaludercic
  0 siblings, 2 replies; 16+ messages in thread
From: Stefan Kangas @ 2024-06-09 18:29 UTC (permalink / raw)
  To: Eli Zaretskii, Alan Donovan; +Cc: 71435

Eli Zaretskii <eliz@gnu.org> writes:

>> Date: Sat, 8 Jun 2024 11:28:34 -0400
>> From:  Alan Donovan via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>>
>> Many editors allow a mouse-click operation on an identifier, plus a suitable modifier key, to jump to the
>> declaration of the symbol. Emacs provides xref-find-definitions-at-mouse, but I couldn't find a way to make it
>> work in response to a click.
>
> ??? This works for me:
>
>   (global-set-key [C-down-mouse-1] 'xref-find-definitions-at-mouse)

Should we consider adding such a key binding by default?

Is that a feature that users want?





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#71435: interactive xref-find-definitions-at-mouse
  2024-06-09 18:29   ` Stefan Kangas
@ 2024-06-09 18:58     ` Eli Zaretskii
  2024-06-10  6:11     ` Philip Kaludercic
  1 sibling, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2024-06-09 18:58 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 71435, adonovan

> From: Stefan Kangas <stefankangas@gmail.com>
> Date: Sun, 9 Jun 2024 14:29:59 -0400
> Cc: 71435@debbugs.gnu.org
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> Date: Sat, 8 Jun 2024 11:28:34 -0400
> >> From:  Alan Donovan via "Bug reports for GNU Emacs,
> >>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> >>
> >> Many editors allow a mouse-click operation on an identifier, plus a suitable modifier key, to jump to the
> >> declaration of the symbol. Emacs provides xref-find-definitions-at-mouse, but I couldn't find a way to make it
> >> work in response to a click.
> >
> > ??? This works for me:
> >
> >   (global-set-key [C-down-mouse-1] 'xref-find-definitions-at-mouse)
> 
> Should we consider adding such a key binding by default?

Not by default, IMO.  Mouse-click potential for bindings is at premium
(in particular, C-down-mouse-1 is already taken), so I think we should
leave it up to the user to bind it (and most probably give up some
existing binding).





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#71435: interactive xref-find-definitions-at-mouse
  2024-06-09 18:29   ` Stefan Kangas
  2024-06-09 18:58     ` Eli Zaretskii
@ 2024-06-10  6:11     ` Philip Kaludercic
  2024-06-10  6:32       ` Juri Linkov
  1 sibling, 1 reply; 16+ messages in thread
From: Philip Kaludercic @ 2024-06-10  6:11 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Eli Zaretskii, 71435, Alan Donovan

Stefan Kangas <stefankangas@gmail.com> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> Date: Sat, 8 Jun 2024 11:28:34 -0400
>>> From:  Alan Donovan via "Bug reports for GNU Emacs,
>>>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>>>
>>> Many editors allow a mouse-click operation on an identifier, plus a suitable modifier key, to jump to the
>>> declaration of the symbol. Emacs provides xref-find-definitions-at-mouse, but I couldn't find a way to make it
>>> work in response to a click.
>>
>> ??? This works for me:
>>
>>   (global-set-key [C-down-mouse-1] 'xref-find-definitions-at-mouse)
>
> Should we consider adding such a key binding by default?
>
> Is that a feature that users want?

Perhaps one could add a global minor mode and mention it in the menu bar?

-- 
	Philip Kaludercic on peregrine





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#71435: interactive xref-find-definitions-at-mouse
  2024-06-10  6:11     ` Philip Kaludercic
@ 2024-06-10  6:32       ` Juri Linkov
  2024-06-10  7:07         ` Philip Kaludercic
  0 siblings, 1 reply; 16+ messages in thread
From: Juri Linkov @ 2024-06-10  6:32 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Eli Zaretskii, 71435, Stefan Kangas, Alan Donovan

>>>> Many editors allow a mouse-click operation on an identifier, plus a suitable modifier key, to jump to the
>>>> declaration of the symbol. Emacs provides xref-find-definitions-at-mouse, but I couldn't find a way to make it
>>>> work in response to a click.
>>>
>>> ??? This works for me:
>>>
>>>   (global-set-key [C-down-mouse-1] 'xref-find-definitions-at-mouse)
>>
>> Should we consider adding such a key binding by default?
>>
>> Is that a feature that users want?
>
> Perhaps one could add a global minor mode and mention it in the menu bar?

I'd rather enable context-menu-mode by default.





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#71435: interactive xref-find-definitions-at-mouse
  2024-06-10  6:32       ` Juri Linkov
@ 2024-06-10  7:07         ` Philip Kaludercic
  2024-06-10 14:39           ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 16+ messages in thread
From: Philip Kaludercic @ 2024-06-10  7:07 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Eli Zaretskii, 71435, Stefan Kangas, Alan Donovan

Juri Linkov <juri@linkov.net> writes:

>>>>> Many editors allow a mouse-click operation on an identifier, plus a suitable modifier key, to jump to the
>>>>> declaration of the symbol. Emacs provides xref-find-definitions-at-mouse, but I couldn't find a way to make it
>>>>> work in response to a click.
>>>>
>>>> ??? This works for me:
>>>>
>>>>   (global-set-key [C-down-mouse-1] 'xref-find-definitions-at-mouse)
>>>
>>> Should we consider adding such a key binding by default?
>>>
>>> Is that a feature that users want?
>>
>> Perhaps one could add a global minor mode and mention it in the menu bar?
>
> I'd rather enable context-menu-mode by default.

If that is up to the discussion, I'd vote for that as well!

-- 
	Philip Kaludercic on peregrine





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#71435: interactive xref-find-definitions-at-mouse
  2024-06-10  7:07         ` Philip Kaludercic
@ 2024-06-10 14:39           ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-06-10 14:44             ` Stefan Kangas
  2024-06-10 15:23             ` Eli Zaretskii
  0 siblings, 2 replies; 16+ messages in thread
From: Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-06-10 14:39 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Eli Zaretskii, 71435, Stefan Kangas, Juri Linkov

[-- Attachment #1: Type: text/plain, Size: 1523 bytes --]

> ?? This works for me:
>  (global-set-key [C-down-mouse-1] 'xref-find-definitions-at-mouse)

Ah, I remember the problem now: if the point is at position A and the mouse
click occurs at some unrelated position B, plain old
xref-find-definitions-at-mouse will use position A as the basis of the
query, which is most surprising: it might be a non-identifier, in
which case you get an error, or it might be an unrelated identifier, in
which case you navigate to the wrong place.

So perhaps my request should instead have been expressed as a bug report:
xref-find-definitions-at-mouse uses the point instead of the mouse event
position.





On Mon, 10 Jun 2024 at 03:07, Philip Kaludercic <philipk@posteo.net> wrote:

> Juri Linkov <juri@linkov.net> writes:
>
> >>>>> Many editors allow a mouse-click operation on an identifier, plus a
> suitable modifier key, to jump to the
> >>>>> declaration of the symbol. Emacs provides
> xref-find-definitions-at-mouse, but I couldn't find a way to make it
> >>>>> work in response to a click.
> >>>>
> >>>> ??? This works for me:
> >>>>
> >>>>   (global-set-key [C-down-mouse-1] 'xref-find-definitions-at-mouse)
> >>>
> >>> Should we consider adding such a key binding by default?
> >>>
> >>> Is that a feature that users want?
> >>
> >> Perhaps one could add a global minor mode and mention it in the menu
> bar?
> >
> > I'd rather enable context-menu-mode by default.
>
> If that is up to the discussion, I'd vote for that as well!
>
> --
>         Philip Kaludercic on peregrine
>

[-- Attachment #2: Type: text/html, Size: 2746 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#71435: interactive xref-find-definitions-at-mouse
  2024-06-10 14:39           ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-06-10 14:44             ` Stefan Kangas
  2024-06-10 15:23             ` Eli Zaretskii
  1 sibling, 0 replies; 16+ messages in thread
From: Stefan Kangas @ 2024-06-10 14:44 UTC (permalink / raw)
  To: Alan Donovan, Philip Kaludercic; +Cc: Eli Zaretskii, 71435, Juri Linkov

Alan Donovan <adonovan@google.com> writes:

>> ?? This works for me:
>>  (global-set-key [C-down-mouse-1] 'xref-find-definitions-at-mouse)
>
> Ah, I remember the problem now: if the point is at position A and the mouse
> click occurs at some unrelated position B, plain old
> xref-find-definitions-at-mouse will use position A as the basis of the
> query, which is most surprising: it might be a non-identifier, in
> which case you get an error, or it might be an unrelated identifier, in
> which case you navigate to the wrong place.
>
> So perhaps my request should instead have been expressed as a bug report:
> xref-find-definitions-at-mouse uses the point instead of the mouse event
> position.

I can't reproduce that in emacs -Q.





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#71435: interactive xref-find-definitions-at-mouse
  2024-06-10 14:39           ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-06-10 14:44             ` Stefan Kangas
@ 2024-06-10 15:23             ` Eli Zaretskii
  2024-06-10 17:26               ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2024-06-10 15:23 UTC (permalink / raw)
  To: Alan Donovan; +Cc: philipk, 71435, stefankangas, juri

> From: Alan Donovan <adonovan@google.com>
> Date: Mon, 10 Jun 2024 10:39:04 -0400
> Cc: Juri Linkov <juri@linkov.net>, Stefan Kangas <stefankangas@gmail.com>, 
> 	Eli Zaretskii <eliz@gnu.org>, 71435@debbugs.gnu.org
> 
> > ?? This works for me:
> >  (global-set-key [C-down-mouse-1] 'xref-find-definitions-at-mouse)
> 
> Ah, I remember the problem now: if the point is at position A and the mouse click occurs at some unrelated
> position B, plain old xref-find-definitions-at-mouse will use position A as the basis of the query

I cannot reproduce thus.  I just tried, and the mouse click shows the
definition of identifier at mouse click, not at point.

> So perhaps my request should instead have been expressed as a bug report: xref-find-definitions-at-mouse
> uses the point instead of the mouse event position.

Please show a recipe for reproducing this, and please also tell what
version of Emacs are you using and on which platform.

Thanks.





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#71435: interactive xref-find-definitions-at-mouse
  2024-06-10 15:23             ` Eli Zaretskii
@ 2024-06-10 17:26               ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-06-10 17:43                 ` Philip Kaludercic
  2024-06-10 17:55                 ` Eli Zaretskii
  0 siblings, 2 replies; 16+ messages in thread
From: Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-06-10 17:26 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: philipk, 71435, stefankangas, juri

[-- Attachment #1: Type: text/plain, Size: 2594 bytes --]

I can reliably reproduce the problem using this script:



;; reproducer for use in emacs -Q:
;; invoke load-file on this file,
;; then follow the interactive steps at the very end.

(emacs-version) ; 29.3
(require 'eglot) ; 1.17.0

;; --- these steps are documented at
;;
https://github.com/golang/tools/blob/master/gopls/doc/emacs.md#configuring-project-for-go-modules-in-emacs

(require 'project) ; 0.11.0

(defun project-find-go-module (dir)
  (when-let ((root (locate-dominating-file dir "go.mod")))
    (cons 'go-module root)))

(cl-defmethod project-root ((project (head go-module)))
  (cdr project))

(add-hook 'project-find-functions #'project-find-go-module)
;; -----

; Use your favorite modifier; s is super, aka ⌘ key on Mac.
(global-set-key (kbd "s-<mouse-1>") #'xref-find-definitions-at-mouse)

;; This file comes from github.com/dominikh/go-mode.el@master.
(load-file "~/w/go-mode.el/go-mode.el")

;; Create a new Go buffer.
(with-current-buffer (find-file "/tmp/a.go")
  (eglot-ensure)
  (insert "package main\n\nimport \"fmt\"\n\nfunc main()
{\n\tfmt.Println()\n}\n")
  (set-buffer (current-buffer)))

;; You should now be in a Go buffer in go-mode with eglot enabled.
;;
;; Now: position the point in "fmt", and then ⌘-click on "Println".
;; For me, Emacs navigates to the declaration of "fmt", not "Println".
;; The converse is true as well: with the point in Println,
;; a ⌘-click on fmt goes to the declaration of Println.

On Mon, 10 Jun 2024 at 11:23, Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Alan Donovan <adonovan@google.com>
> > Date: Mon, 10 Jun 2024 10:39:04 -0400
> > Cc: Juri Linkov <juri@linkov.net>, Stefan Kangas <stefankangas@gmail.com>,
>
> >       Eli Zaretskii <eliz@gnu.org>, 71435@debbugs.gnu.org
> >
> > > ?? This works for me:
> > >  (global-set-key [C-down-mouse-1] 'xref-find-definitions-at-mouse)
> >
> > Ah, I remember the problem now: if the point is at position A and the
> mouse click occurs at some unrelated
> > position B, plain old xref-find-definitions-at-mouse will use position A
> as the basis of the query
>
> I cannot reproduce thus.  I just tried, and the mouse click shows the
> definition of identifier at mouse click, not at point.
>
> > So perhaps my request should instead have been expressed as a bug
> report: xref-find-definitions-at-mouse
> > uses the point instead of the mouse event position.
>
> Please show a recipe for reproducing this, and please also tell what
> version of Emacs are you using and on which platform.
>
> Thanks.
>

[-- Attachment #2: Type: text/html, Size: 3685 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#71435: interactive xref-find-definitions-at-mouse
  2024-06-10 17:26               ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-06-10 17:43                 ` Philip Kaludercic
  2024-06-10 18:47                   ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-06-10 17:55                 ` Eli Zaretskii
  1 sibling, 1 reply; 16+ messages in thread
From: Philip Kaludercic @ 2024-06-10 17:43 UTC (permalink / raw)
  To: Alan Donovan; +Cc: Eli Zaretskii, 71435, stefankangas, juri

Alan Donovan <adonovan@google.com> writes:

> I can reliably reproduce the problem using this script:
>
>
>
> ;; reproducer for use in emacs -Q:
> ;; invoke load-file on this file,
> ;; then follow the interactive steps at the very end.
>
> (emacs-version) ; 29.3
> (require 'eglot) ; 1.17.0
>
> ;; --- these steps are documented at
> ;;
> https://github.com/golang/tools/blob/master/gopls/doc/emacs.md#configuring-project-for-go-modules-in-emacs
>
> (require 'project) ; 0.11.0
>
> (defun project-find-go-module (dir)
>   (when-let ((root (locate-dominating-file dir "go.mod")))
>     (cons 'go-module root)))
>
> (cl-defmethod project-root ((project (head go-module)))
>   (cdr project))
>
> (add-hook 'project-find-functions #'project-find-go-module)
> ;; -----
>
> ; Use your favorite modifier; s is super, aka ⌘ key on Mac.
> (global-set-key (kbd "s-<mouse-1>") #'xref-find-definitions-at-mouse)
>
> ;; This file comes from github.com/dominikh/go-mode.el@master.
> (load-file "~/w/go-mode.el/go-mode.el")
>
> ;; Create a new Go buffer.
> (with-current-buffer (find-file "/tmp/a.go")
>   (eglot-ensure)
>   (insert "package main\n\nimport \"fmt\"\n\nfunc main()
> {\n\tfmt.Println()\n}\n")
>   (set-buffer (current-buffer)))
>
> ;; You should now be in a Go buffer in go-mode with eglot enabled.
> ;;
> ;; Now: position the point in "fmt", and then ⌘-click on "Println".
> ;; For me, Emacs navigates to the declaration of "fmt", not "Println".
> ;; The converse is true as well: with the point in Println,
> ;; a ⌘-click on fmt goes to the declaration of Println.

Given that I have a working Go setup installed, I tried this out: With
Emacs 30 on GNU/Linux fmt and Println both jump to the correct location.

The most recent commit might have fixed the issue you are having:

commit 128ed5c9f17fab87fdb679326035aa2598612658
Author: Dmitry Gutov <dmitry@gutov.dev>
Date:   Thu Aug 31 03:21:11 2023 +0300

    Add one more mouse-set-point call to functions xref-find-*-at-mouse
    
    * lisp/progmodes/xref.el (xref-find-definitions-at-mouse)
    (xref-find-references-at-mouse): Call mouse-set-point to ensure
    that the search is initiated at the same place where
    xref-backend-identifier-at-point was called (bug#65578).

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 3f75f8d7132..dbafa00c3ad 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -1638,7 +1638,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"))))
 
 ;;;###autoload
@@ -1652,6 +1654,7 @@ xref-find-references-at-mouse
            (xref-backend-identifier-at-point (xref-find-backend)))))
     (if identifier
         (let ((xref-prompt-for-identifier nil))
+          (mouse-set-point event)
           (xref-find-references identifier))
       (user-error "No identifier here"))))
 
There is a more recent version of Xref on ELPA, could you try installing
that as well, and see if that changes anything?

> On Mon, 10 Jun 2024 at 11:23, Eli Zaretskii <eliz@gnu.org> wrote:
>
>> > From: Alan Donovan <adonovan@google.com>
>> > Date: Mon, 10 Jun 2024 10:39:04 -0400
>> > Cc: Juri Linkov <juri@linkov.net>, Stefan Kangas <stefankangas@gmail.com>,
>>
>> >       Eli Zaretskii <eliz@gnu.org>, 71435@debbugs.gnu.org
>> >
>> > > ?? This works for me:
>> > >  (global-set-key [C-down-mouse-1] 'xref-find-definitions-at-mouse)
>> >
>> > Ah, I remember the problem now: if the point is at position A and the
>> mouse click occurs at some unrelated
>> > position B, plain old xref-find-definitions-at-mouse will use position A
>> as the basis of the query
>>
>> I cannot reproduce thus.  I just tried, and the mouse click shows the
>> definition of identifier at mouse click, not at point.
>>
>> > So perhaps my request should instead have been expressed as a bug
>> report: xref-find-definitions-at-mouse
>> > uses the point instead of the mouse event position.
>>
>> Please show a recipe for reproducing this, and please also tell what
>> version of Emacs are you using and on which platform.
>>
>> Thanks.
>>

-- 
	Philip Kaludercic on peregrine





^ permalink raw reply related	[flat|nested] 16+ messages in thread

* bug#71435: interactive xref-find-definitions-at-mouse
  2024-06-10 17:26               ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-06-10 17:43                 ` Philip Kaludercic
@ 2024-06-10 17:55                 ` Eli Zaretskii
  1 sibling, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2024-06-10 17:55 UTC (permalink / raw)
  To: Alan Donovan; +Cc: philipk, 71435, stefankangas, juri

> From: Alan Donovan <adonovan@google.com>
> Date: Mon, 10 Jun 2024 13:26:59 -0400
> Cc: philipk@posteo.net, juri@linkov.net, stefankangas@gmail.com, 
> 	71435@debbugs.gnu.org
> 
> I can reliably reproduce the problem using this script:
> 
> ;; reproducer for use in emacs -Q:
> ;; invoke load-file on this file,
> ;; then follow the interactive steps at the very end.
> 
> (emacs-version) ; 29.3
> (require 'eglot) ; 1.17.0
> 
> ;; --- these steps are documented at
> ;;
> https://github.com/golang/tools/blob/master/gopls/doc/emacs.md#configuring-project-for-go-modules-in-emacs
> 
> 
> (require 'project) ; 0.11.0
> 
> (defun project-find-go-module (dir)
>   (when-let ((root (locate-dominating-file dir "go.mod")))
>     (cons 'go-module root)))
> 
> (cl-defmethod project-root ((project (head go-module)))
>   (cdr project))
> 
> (add-hook 'project-find-functions #'project-find-go-module)
> ;; -----
> 
> ; Use your favorite modifier; s is super, aka ⌘ key on Mac.
> (global-set-key (kbd "s-<mouse-1>") #'xref-find-definitions-at-mouse)
> 
> ;; This file comes from github.com/dominikh/go-mode.el@master.
> (load-file "~/w/go-mode.el/go-mode.el")
> 
> ;; Create a new Go buffer.
> (with-current-buffer (find-file "/tmp/a.go")
>   (eglot-ensure)
>   (insert "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println()\n}\n")
>   (set-buffer (current-buffer)))

All that is needed to reproduce such a basic problem?

Are you sure it isn't project-find-go-module that interferes here, for
example?

IOW, please try to systematically remove stuff from the recipe until
you find the culprit.  My guess is that it is some of the 3rd-party
stuff you load, not Emacs.





^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#71435: interactive xref-find-definitions-at-mouse
  2024-06-10 17:43                 ` Philip Kaludercic
@ 2024-06-10 18:47                   ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-06-10 18:59                     ` Stefan Kangas
  0 siblings, 1 reply; 16+ messages in thread
From: Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-06-10 18:47 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Eli Zaretskii, 71435, stefankangas, juri

[-- Attachment #1: Type: text/plain, Size: 391 bytes --]

On Mon, 10 Jun 2024 at 13:43, Philip Kaludercic <philipk@posteo.net> wrote:

> Given that I have a working Go setup installed, I tried this out: With
> Emacs 30 on GNU/Linux fmt and Println both jump to the correct location.
>
> The most recent commit might have fixed the issue you are having:
>

I applied that neat little patch, and it fixed it. Many thanks, and sorry
to take your time.

[-- Attachment #2: Type: text/html, Size: 679 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* bug#71435: interactive xref-find-definitions-at-mouse
  2024-06-10 18:47                   ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-06-10 18:59                     ` Stefan Kangas
  0 siblings, 0 replies; 16+ messages in thread
From: Stefan Kangas @ 2024-06-10 18:59 UTC (permalink / raw)
  To: Alan Donovan, Philip Kaludercic; +Cc: Eli Zaretskii, 71435-done, juri

Alan Donovan <adonovan@google.com> writes:

> On Mon, 10 Jun 2024 at 13:43, Philip Kaludercic <philipk@posteo.net> wrote:
>
>> Given that I have a working Go setup installed, I tried this out: With
>> Emacs 30 on GNU/Linux fmt and Println both jump to the correct location.
>>
>> The most recent commit might have fixed the issue you are having:
>
> I applied that neat little patch, and it fixed it. Many thanks, and sorry
> to take your time.

Thanks for testing.

I'm consequently closing this bug report.





^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-06-10 18:59 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-08 15:28 bug#71435: interactive xref-find-definitions-at-mouse Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-08 16:31 ` Eli Zaretskii
2024-06-09 18:29   ` Stefan Kangas
2024-06-09 18:58     ` Eli Zaretskii
2024-06-10  6:11     ` Philip Kaludercic
2024-06-10  6:32       ` Juri Linkov
2024-06-10  7:07         ` Philip Kaludercic
2024-06-10 14:39           ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-10 14:44             ` Stefan Kangas
2024-06-10 15:23             ` Eli Zaretskii
2024-06-10 17:26               ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-10 17:43                 ` Philip Kaludercic
2024-06-10 18:47                   ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-10 18:59                     ` Stefan Kangas
2024-06-10 17:55                 ` Eli Zaretskii
2024-06-09 16:46 ` Juri Linkov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.