all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#71435: interactive xref-find-definitions-at-mouse
@ 2024-06-08 15:28 Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-06-08 16:31 ` Eli Zaretskii
  2024-06-09 16:46 ` Juri Linkov
  0 siblings, 2 replies; 16+ messages in thread
From: Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-06-08 15:28 UTC (permalink / raw)
  To: 71435

[-- Attachment #1: Type: text/plain, Size: 1149 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 1424 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-06-10 18:59 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-08 15:28 bug#71435: interactive xref-find-definitions-at-mouse Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-08 16:31 ` Eli Zaretskii
2024-06-09 18:29   ` Stefan Kangas
2024-06-09 18:58     ` Eli Zaretskii
2024-06-10  6:11     ` Philip Kaludercic
2024-06-10  6:32       ` Juri Linkov
2024-06-10  7:07         ` Philip Kaludercic
2024-06-10 14:39           ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-10 14:44             ` Stefan Kangas
2024-06-10 15:23             ` Eli Zaretskii
2024-06-10 17:26               ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-10 17:43                 ` Philip Kaludercic
2024-06-10 18:47                   ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-10 18:59                     ` Stefan Kangas
2024-06-10 17:55                 ` Eli Zaretskii
2024-06-09 16:46 ` Juri Linkov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.