GNU bug report logs -
#71435
interactive xref-find-definitions-at-mouse
Previous Next
Reported by: Alan Donovan <adonovan <at> google.com>
Date: Sat, 8 Jun 2024 15:32:02 UTC
Severity: normal
Done: Stefan Kangas <stefankangas <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
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
[Message part 2 (text/html, inline)]
This bug report was last modified 345 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.