emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Add xref-find-references-other-window and xref-find-references-other-fra


From: David Morgan
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

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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]