emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#32029: closed (PATCH: xref-find-definitions-at-mou


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#32029: closed (PATCH: xref-find-definitions-at-mouse)
Date: Sat, 07 Jul 2018 09:03:01 +0000

Your message dated Sat, 07 Jul 2018 12:02:43 +0300
with message-id <address@hidden>
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
address@hidden)


-- 
32029: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=32029
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: PATCH: xref-find-definitions-at-mouse Date: Mon, 2 Jul 2018 01:18:50 +0200 User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.8.0
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




--- End Message ---
--- Begin Message --- Subject: Re: bug#32029: [PATCH] xref-find-definitions-at-mouse Date: Sat, 07 Jul 2018 12:02:43 +0300
> From: Tobias Gerdin <address@hidden>
> Date: Tue, 3 Jul 2018 23:37:23 +0200
> 
> A new version below.

Thanks, pushed to the master branch.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]