From: David Morgan <djm_uk@protonmail.com>
To: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Add xref-find-references-other-window and xref-find-references-other-frame to xref.el
Date: Thu, 04 Aug 2022 15:30:52 +0000 [thread overview]
Message-ID: <NHwRXXkCCDvL8e9NN5mFPBnpkQt5gHjfMA_Nb44rEwJwcsVCfmuk4Sb9lyG_kMYtkzSsA3b6y3ULsURaBuSIFbUgEPFzzZjvpiQ3wIWIRkk=@protonmail.com> (raw)
I would like to add the functions xref-find-references-other-window and xref-find-references-other-frame (plus keybindings to xref.el).
We already have xref-find-definitions-other-window (C-x 4 .) and xref-find-definitions-other-frame (C-x 5 .), but xref-find-references (M-?) has no equivalent other-window/frame versions.
Please see the patch below, and let me know if it would be worthwhile to add this.
I am not clear on which other files I need to edit (I think it's etc/NEWS but not ChangeLog.1), or on who would need to provide a commit message (me, or someone with commit access).
Some notes:
1. Following the key bindings for xref-find-definitions-other-*, I have used C-x 4 ? and C-x 5 ? for these. The potential downside to this is that which-key allows ? as an equivalent to C-h (paging/help). So it may be better to change them to "\M-?". I can provide an updated patch if so.
2. Currently the default value for xref-prompt-identifier is '(not xref-find-definitions xref-find-definitions-other-window xref-find-definitions-other-frame). My preference would be to add the existing xref-find-references function to this, along with the two new ones. Would that be a good idea, and if so, would it need to be done separately, or could it be included in this patch?
3. I think this change is small enough to not need copyright assignment to the FSF, but I am happy to do it now anyway.
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index f3db971bcf..04bf319fc4 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -1511,6 +1511,18 @@ is nil, prompt only if there's no usable symbol at point."
(interactive (list (xref--read-identifier "Find references of: ")))
(xref--find-xrefs identifier 'references identifier nil))
+;;;###autoload
+(defun xref-find-references-other-window (identifier)
+ "Like `xref-find-references' but switch to the other window."
+ (interactive (list (xref--read-identifier "Find references of: ")))
+ (xref--find-xrefs identifier 'references identifier 'window))
+
+;;;###autoload
+(defun xref-find-references-other-frame (identifier)
+ "Like `xref-find-references' but switch to the other frame."
+ (interactive (list (xref--read-identifier "Find references of: ")))
+ (xref--find-xrefs identifier 'references identifier 'frame))
+
(defun xref-find-references-and-replace (from to)
"Replace all references to identifier FROM with TO."
(interactive
@@ -1598,6 +1610,8 @@ output of this command when the backend is etags."
;;;###autoload (define-key esc-map [?\C-.] #'xref-find-apropos)
;;;###autoload (define-key ctl-x-4-map "." #'xref-find-definitions-other-window)
;;;###autoload (define-key ctl-x-5-map "." #'xref-find-definitions-other-frame)
+;;;###autoload (define-key ctl-x-4-map "?" #'xref-find-references-other-window)
+;;;###autoload (define-key ctl-x-5-map "?" #'xref-find-references-other-frame)
^L
;;; Helper functions
next reply other threads:[~2022-08-04 15:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-04 15:30 David Morgan [this message]
2022-08-04 19:26 ` Add xref-find-references-other-window and xref-find-references-other-frame to xref.el Philip Kaludercic
2022-08-05 0:12 ` Dmitry Gutov
2022-08-05 11:24 ` David Morgan
2022-08-05 0:15 ` Dmitry Gutov
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='NHwRXXkCCDvL8e9NN5mFPBnpkQt5gHjfMA_Nb44rEwJwcsVCfmuk4Sb9lyG_kMYtkzSsA3b6y3ULsURaBuSIFbUgEPFzzZjvpiQ3wIWIRkk=@protonmail.com' \
--to=djm_uk@protonmail.com \
--cc=emacs-devel@gnu.org \
/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).