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

* Re: Add xref-find-references-other-window and xref-find-references-other-frame to xref.el
  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  0:15 ` Dmitry Gutov
  1 sibling, 1 reply; 5+ messages in thread
From: Philip Kaludercic @ 2022-08-04 19:26 UTC (permalink / raw)
  To: David Morgan; +Cc: emacs-devel@gnu.org

David Morgan <djm_uk@protonmail.com> writes:

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

Are these really necessary, considering that the prefix-commands C-x 4
4/C-x 5 5 already exists?  C-x 4 . (as opposed to C-x 4 M-.) is already
a bit confusing, and overriding ?, that some people use instead of C-h
to list the bindings under a prefix might not help.



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

* Re: Add xref-find-references-other-window and xref-find-references-other-frame to xref.el
  2022-08-04 19:26 ` Philip Kaludercic
@ 2022-08-05  0:12   ` Dmitry Gutov
  2022-08-05 11:24     ` David Morgan
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Gutov @ 2022-08-05  0:12 UTC (permalink / raw)
  To: Philip Kaludercic, David Morgan; +Cc: emacs-devel@gnu.org

On 04.08.2022 22:26, Philip Kaludercic wrote:
> David Morgan<djm_uk@protonmail.com>  writes:
> 
>> 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.
> Are these really necessary, considering that the prefix-commands C-x 4
> 4/C-x 5 5 already exists?  C-x 4 . (as opposed to C-x 4 M-.) is already
> a bit confusing, and overriding ?, that some people use instead of C-h
> to list the bindings under a prefix might not help.

I'm inclined to agree.

David, how do you feel about typing the slightly longer sequences 'C-x 4 
4 M-?' and 'C-x 5 5 M-?' rather than having separate commands?



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

* Re: Add xref-find-references-other-window and xref-find-references-other-frame to xref.el
  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:15 ` Dmitry Gutov
  1 sibling, 0 replies; 5+ messages in thread
From: Dmitry Gutov @ 2022-08-05  0:15 UTC (permalink / raw)
  To: David Morgan, emacs-devel@gnu.org

On 04.08.2022 18:30, David Morgan wrote:
> 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?

 From past discussions, omitting xref-find-references from the list was 
an explicit decision by the Emacs maintainers.

We might change that in the future, but for now I don't think we'd have 
the necessary consensus about this change.



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

* Re: Add xref-find-references-other-window and xref-find-references-other-frame to xref.el
  2022-08-05  0:12   ` Dmitry Gutov
@ 2022-08-05 11:24     ` David Morgan
  0 siblings, 0 replies; 5+ messages in thread
From: David Morgan @ 2022-08-05 11:24 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: emacs-devel@gnu.org

------- Original Message -------
On Friday, August 5th, 2022 at 01:12, Dmitry Gutov <dgutov@yandex.ru> wrote:

> On 04.08.2022 22:26, Philip Kaludercic wrote:
>
> > David Morgandjm_uk@protonmail.com writes:
> >
> > > 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.
> > > Are these really necessary, considering that the prefix-commands C-x 4
> > > 4/C-x 5 5 already exists? C-x 4 . (as opposed to C-x 4 M-.) is already
> > > a bit confusing, and overriding ?, that some people use instead of C-h
> > > to list the bindings under a prefix might not help.
>
>
> I'm inclined to agree.
>
> David, how do you feel about typing the slightly longer sequences 'C-x 4
> 4 M-?' and 'C-x 5 5 M-?' rather than having separate commands?

Apologies, I responded to the replies I received, but without CCing the list, so in brief...

I was unaware of switch-to-buffer-obey-display-actions, so thought that other-{window,frame}-prefix didn't work with xref-find-references. Now that I've set that, it does work, which certainly makes having separate commands less useful.



^ permalink raw reply	[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).