From: Alan Donovan via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 71435@debbugs.gnu.org
Subject: bug#71435: interactive xref-find-definitions-at-mouse
Date: Sat, 8 Jun 2024 11:28:34 -0400 [thread overview]
Message-ID: <CAPVWWDW4Nk_2d2F0nAbXOwF5z=h52upSapdJrYsuGjtaPfy0yA@mail.gmail.com> (raw)
[-- 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 --]
next reply other threads:[~2024-06-08 15:28 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-08 15:28 Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-06-08 16:31 ` bug#71435: interactive xref-find-definitions-at-mouse 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAPVWWDW4Nk_2d2F0nAbXOwF5z=h52upSapdJrYsuGjtaPfy0yA@mail.gmail.com' \
--to=bug-gnu-emacs@gnu.org \
--cc=71435@debbugs.gnu.org \
--cc=adonovan@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).