GNU bug report logs - #32029
PATCH: xref-find-definitions-at-mouse

Previous Next

Package: emacs;

Reported by: Tobias Gerdin <tgerdin <at> gmail.com>

Date: Sun, 1 Jul 2018 23:52:01 UTC

Severity: wishlist

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#32029: closed (PATCH: xref-find-definitions-at-mouse)
Date: Sat, 07 Jul 2018 09:03:01 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sat, 07 Jul 2018 12:02:43 +0300
with message-id <83k1q7ju4s.fsf <at> gnu.org>
and subject line Re: bug#32029: [PATCH] xref-find-definitions-at-mouse
has caused the debbugs.gnu.org bug report #32029,
regarding PATCH: xref-find-definitions-at-mouse
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
32029: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=32029
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Tobias Gerdin <tgerdin <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: PATCH: xref-find-definitions-at-mouse
Date: Mon, 2 Jul 2018 01:18:50 +0200
Hello,

I find it convenient to be able to go to definitions using the mouse 
(especially when getting to know new code bases). I have the below 
function bound to C-mouse-1 like so:

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

I also find it convenient to be able to get back to where I was using 
only the mouse (enabling keyboard-free navigation):

(global-set-key [C-mouse-3] 'xref-pop-marker-stack)
(global-set-key [C-down-mouse-3] nil)

Finding suitable default keybindings (well, "mouse bindings") is beyond 
the scope of this patch, but what I have above is the same binding as 
other popular IDEs such as IntelliJ and VS Code.

Regards,

Tobias Gerdin

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 9a437b6f69..85a1bc6be4 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -873,6 +873,18 @@ With prefix argument, prompt for the identifier."
   (interactive (list (xref--read-identifier "Find references of: ")))
   (xref--find-xrefs identifier 'references identifier nil))

+;;;###autoload
+(defun xref-find-definitions-at-mouse (event)
+  "Find the definition of identifier around mouse click."
+  (interactive "e")
+  (let* ((backend (xref-find-backend))
+     (identifier (save-excursion
+              (mouse-set-point event)
+              (xref-backend-identifier-at-point backend))))
+    (if identifier
+    (xref--find-definitions identifier nil)
+      (user-error "No identifier here"))))
+
 (declare-function apropos-parse-pattern "apropos" (pattern))

 ;;;###autoload



[Message part 3 (message/rfc822, inline)]
From: Eli Zaretskii <eliz <at> gnu.org>
To: Tobias Gerdin <tgerdin <at> gmail.com>
Cc: 32029-done <at> debbugs.gnu.org, dgutov <at> yandex.ru
Subject: Re: bug#32029: [PATCH] xref-find-definitions-at-mouse
Date: Sat, 07 Jul 2018 12:02:43 +0300
> From: Tobias Gerdin <tgerdin <at> gmail.com>
> Date: Tue, 3 Jul 2018 23:37:23 +0200
> 
> A new version below.

Thanks, pushed to the master branch.


This bug report was last modified 7 years and 35 days ago.

Previous Next


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