all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Change to allow xrefs to be shown in the current window
@ 2018-05-10 23:49 Per Weijnitz
  0 siblings, 0 replies; only message in thread
From: Per Weijnitz @ 2018-05-10 23:49 UTC (permalink / raw)
  To: emacs-devel

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



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-05-10 23:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-10 23:49 Change to allow xrefs to be shown in the current window Per Weijnitz

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.