all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Per Weijnitz <per.weijnitz@gmail.com>
To: emacs-devel@gnu.org
Subject: Change to allow xrefs to be shown in the current window
Date: Fri, 11 May 2018 01:49:32 +0200	[thread overview]
Message-ID: <CAFfcjjPiQWw35dyPSaXjya6FR3iCZTykGQqKHEUYCRAdC=Vwug@mail.gmail.com> (raw)

Hi! I added another possible value for xref-show-xrefs-function in
xref.el. In master, it can be set to value xref--show-xref-buffer,
which shows the result list from xref-find-references in another
window. The proposed, new value xref--show-xref-same-window shows the
result list in the current window. I added it because I prefer that
presentation over the other.

Would this patch be of interest to you?


Proposed Changelog entry:
    * lisp/progmodes/xref.el: changed xref--show-xref-buffer and added
xref--show-xref and xref--show-xref-same-window.


I made the following diff from master, updated May 11 2018:

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 9a437b6..28bbc5b 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -762,25 +762,36 @@ xref--analyze
                   #'equal))

 (defun xref--show-xref-buffer (xrefs alist)
+  "Show xref results in another window.
+Use with xref-show-xrefs-function."
+  (xref--show-xref xrefs alist nil))
+
+(defun xref--show-xref-current-window (xrefs alist)
+  "Show xref results in the current window.
+Use with xref-show-xrefs-function."
+  (xref--show-xref xrefs alist 'current-window))
+
+(defun xref--show-xref (xrefs alist mode)
   (let ((xref-alist (xref--analyze xrefs)))
     (with-current-buffer (get-buffer-create xref-buffer-name)
       (setq buffer-undo-list nil)
       (let ((inhibit-read-only t)
             (buffer-undo-list t))
         (erase-buffer)
         (xref--insert-xrefs xref-alist)
         (xref--xref-buffer-mode)
-        (pop-to-buffer (current-buffer))
+       (cond ((eq mode 'current-window) (switch-to-buffer (current-buffer)))
+             (t (pop-to-buffer (current-buffer))))
         (goto-char (point-min))
         (setq xref--original-window (assoc-default 'window alist)
               xref--original-window-intent (assoc-default
'display-action alist))
         (current-buffer)))))

 ^L
 ;; This part of the UI seems fairly uncontroversial: it reads the
 ;; identifier and deals with the single definition case.
 ;; (FIXME: do we really want this case to be handled like that in
 ;; "find references" and "find regexp searches"?)
 ;;
 ;; The controversial multiple definitions case is handed off to
 ;; xref-show-xrefs-function.


Best regards /Per



                 reply	other threads:[~2018-05-10 23:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFfcjjPiQWw35dyPSaXjya6FR3iCZTykGQqKHEUYCRAdC=Vwug@mail.gmail.com' \
    --to=per.weijnitz@gmail.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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.