From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Donovan via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#71435: interactive xref-find-definitions-at-mouse Date: Mon, 10 Jun 2024 13:26:59 -0400 Message-ID: References: <86y17fbdkw.fsf@gnu.org> <87jzix1g4r.fsf@posteo.net> <865xuh2tpk.fsf@mail.linkov.net> <87frtl1djg.fsf@posteo.net> <86le3c95zk.fsf@gnu.org> Reply-To: Alan Donovan Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000961f14061a8c7518" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29297"; mail-complaints-to="usenet@ciao.gmane.io" Cc: philipk@posteo.net, 71435@debbugs.gnu.org, stefankangas@gmail.com, juri@linkov.net To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jun 10 19:29:05 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sGipN-0007GJ-Jx for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 10 Jun 2024 19:29:05 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sGip5-000583-00; Mon, 10 Jun 2024 13:28:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sGip3-00057i-Gb for bug-gnu-emacs@gnu.org; Mon, 10 Jun 2024 13:28:45 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sGip3-0004Mz-8e for bug-gnu-emacs@gnu.org; Mon, 10 Jun 2024 13:28:45 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sGipJ-0001rf-WA for bug-gnu-emacs@gnu.org; Mon, 10 Jun 2024 13:29:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Donovan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 10 Jun 2024 17:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71435 X-GNU-PR-Package: emacs Original-Received: via spool by 71435-submit@debbugs.gnu.org id=B71435.17180405177105 (code B ref 71435); Mon, 10 Jun 2024 17:29:01 +0000 Original-Received: (at 71435) by debbugs.gnu.org; 10 Jun 2024 17:28:37 +0000 Original-Received: from localhost ([127.0.0.1]:48327 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sGiou-0001qW-N8 for submit@debbugs.gnu.org; Mon, 10 Jun 2024 13:28:37 -0400 Original-Received: from mail-pl1-f169.google.com ([209.85.214.169]:35967) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sGios-0001q2-Ar for 71435@debbugs.gnu.org; Mon, 10 Jun 2024 13:28:35 -0400 Original-Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1f61742a024so11315ad.0 for <71435@debbugs.gnu.org>; Mon, 10 Jun 2024 10:28:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718040431; x=1718645231; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=IA3urorU7v8cvsYdpDZt7SQqgVfyHQ1Gbwcdzk82KeU=; b=YnIJ0N78DpAlhi4vi385U9MkUEPfi1OcB2GRpByoSZI1Q+bGgxYXBswq0nomkheMs4 8AOYeUqoY/HrIwoOtovGIB1C3lQ7B/cF6fC+4eMJcujiHQjLPUj+Vs+wNB7Jh/qKinZ6 syKgD08op9AnKVfMoWQk6/gO/62RFAbsi3tN04p0Un1x4KClsbPmuCXWpfP8x5C1y2fC 2npNlxBvzb9Kw+0H8HpqPT9s7zdFYBFWvgaTV0CrGx6mhx9Q2lXlnmh4GyceNWMeuavA OQ/czzDGBCbWWwJBcbO8GP9TGR6Wcparl2WIuWO2x6sTpEryZAMIhZuYphIP12qXlUdE lIEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718040431; x=1718645231; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IA3urorU7v8cvsYdpDZt7SQqgVfyHQ1Gbwcdzk82KeU=; b=tjyPzkGau3/zvGpcM1xiyrc/d/Os9iSBGd4cb1KEqNxy7r7jGrOieEZigt2ImdMYKe +oTW8rdrvTdN2JZXtk+6Ix2z+Ks1J+F9L7LfPQtEoPUrP/ruiC4OT/9CpD53KJ4C0LQq C53lpVNvYBIYEBaA6skqpUkGTfLnls8EDObzlVs3JUSnEg9BAgVwi49X6VHjU4/iAtyj Fs7nNReecRPXtW3lKkms/bTAAe5FY/cWbLKkm8F5QAjB6X9dn2c4NGbpRIEcNJU0AJW0 Ro+e37UKjmPhpessGDjhqA6aYHcRaNoEEMgt7KQoTlSBppbkzJ53AX8hKuIItL3u1GQx V7MQ== X-Forwarded-Encrypted: i=1; AJvYcCWs3Iu7VyHseAf14zDQ0nQ9V0wSijoGu2UEnnXVxBHuz/Qme6Pf++ADaddE2CG4+Wfx3eS0fh33h7y/fADM8GK5xM2Z5N4= X-Gm-Message-State: AOJu0Yy5t/EHsMeKmi/faBLH4zf4N4aEh4xvDUCmhrbkzbqGTw6xpd2t xzmlwZC9K3RQMtIrZxBxJ8wHKKxebCfWREb3fnr9p4XjhM2zZ4DJwixhyaiqAQncHDKevPXlaoQ c6pQMtT/0iBCPSW9z5NP0mxllWuztuesN59lQ X-Google-Smtp-Source: AGHT+IHyV/auThAU7fdk/N4nkjTL+lduxepiaBRNI4k1CeDNNbN4KqBVBMUupIvD6TcRx5hK3SbtFGU5NPdL1qguYP8= X-Received: by 2002:a17:902:694b:b0:1f6:5bba:8ea3 with SMTP id d9443c01a7336-1f6f0c368f3mr5200675ad.25.1718040430700; Mon, 10 Jun 2024 10:27:10 -0700 (PDT) In-Reply-To: <86le3c95zk.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:287058 Archived-At: --000000000000961f14061a8c7518 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 =E2=8C=98 key on Mac. (global-set-key (kbd "s-") #'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 =E2=8C=98-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 =E2=8C=98-click on fmt goes to the declaration of Println. On Mon, 10 Jun 2024 at 11:23, Eli Zaretskii wrote: > > From: Alan Donovan > > Date: Mon, 10 Jun 2024 10:39:04 -0400 > > Cc: Juri Linkov , Stefan Kangas , > > > Eli Zaretskii , 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. > --000000000000961f14061a8c7518 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I can reliably reproduce the problem using this scrip= t:



;; reproducer for use in emacs -Q= :
;; invoke load-file on this file,
;; then follow the interactive st= eps 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/gop= ls/doc/emacs.md#configuring-project-for-go-modules-in-emacs

(req= uire 'project) ; 0.11.0

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

(cl-defmethod project-r= oot ((project (head go-module)))
=C2=A0 (cdr project))

(add-hook = 'project-find-functions #'project-find-go-module)
;; -----
; Use your favorite modifier; s is super, aka =E2=8C=98 key on Mac.
(g= lobal-set-key (kbd "s-<mouse-1>") #'xref-find-definitio= ns-at-mouse)

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

;; Create a new Go bu= ffer.
(with-current-buffer (find-file "/tmp/a.go")
=C2=A0 (= eglot-ensure)
=C2=A0 (insert "package main\n\nimport \"fmt\&qu= ot;\n\nfunc main() {\n\tfmt.Println()\n}\n")
=C2=A0 (set-buffer (cu= rrent-buffer)))

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

On Mon, 10 Jun 2024 at 11:23= , Eli Zaretskii <eliz@gnu.org> wr= ote:
> From: = Alan Donovan <a= donovan@google.com>
> Date: Mon, 10 Jun 2024 10:39:04 -0400
> Cc: Juri Linkov <juri@linkov.net>, Stefan Kangas <stefankangas@gmail.com>,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0Eli Zaretskii <eliz@gnu.org>, 71435@debbugs.gnu.org
>
> > ?? This works for me:
> >=C2=A0 (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.=C2=A0 I just tried, and the mouse click shows the<= br> definition of identifier at mouse click, not at point.

> So perhaps my request should instead have been expressed as a bug repo= rt: 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.
--000000000000961f14061a8c7518--