unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Add xref-find-references-other-window and xref-find-references-other-frame to xref.el
@ 2022-08-04 15:30 David Morgan
  2022-08-04 19:26 ` Philip Kaludercic
  2022-08-05  0:15 ` Dmitry Gutov
  0 siblings, 2 replies; 5+ messages in thread
From: David Morgan @ 2022-08-04 15:30 UTC (permalink / raw)
  To: emacs-devel@gnu.org

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






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

end of thread, other threads:[~2022-08-05 11:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-04 15:30 Add xref-find-references-other-window and xref-find-references-other-frame to xref.el David Morgan
2022-08-04 19:26 ` Philip Kaludercic
2022-08-05  0:12   ` Dmitry Gutov
2022-08-05 11:24     ` David Morgan
2022-08-05  0:15 ` Dmitry Gutov

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).