From: Tobias Gerdin Date: Sat, 7 Jul 2018 08:59:56 +0000 (+0300) Subject: New function 'xref-find-definitions-at-mouse' X-Git-Tag: emacs-27.0.90~4715 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=455a236d415d3ca9a25564cd3f295f5e5e0bb7b4;p=emacs.git New function 'xref-find-definitions-at-mouse' * lisp/progmodes/xref.el (xref-find-definitions-at-mouse): New function. (Bug32029) Copyright-paperwork-exempt: yes --- diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 9a437b6f690..7bd1668cf4e 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -873,6 +873,19 @@ 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 at or around mouse click. +This command is intended to be bound to a mouse event." + (interactive "e") + (let ((identifier + (save-excursion + (mouse-set-point event) + (xref-backend-identifier-at-point (xref-find-backend))))) + (if identifier + (xref-find-definitions identifier) + (user-error "No identifier here")))) + (declare-function apropos-parse-pattern "apropos" (pattern)) ;;;###autoload