emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 94b3208: Make window choice in xref commands config


From: João Távora
Subject: [Emacs-diffs] master 94b3208: Make window choice in xref commands configurable
Date: Wed, 6 Feb 2019 17:52:03 -0500 (EST)

branch: master
commit 94b320849e9655db110ed74ca73974c78f95428a
Author: Juri Linkov <address@hidden>
Commit: João Távora <address@hidden>

    Make window choice in xref commands configurable
    
    Previously, it wasn't easy to tell xref.el commands like
    xref-find-definitions or xref-find-definitions-other-window how to
    choose a window for the *xref* buffer or how to find windows for
    displaying the results after choosing a candidate.  This patch makes
    that task easier, but keeps the current behaviour intact.
    
    Co-authored-by: João Távora <address@hidden>
    
    * lisp/progmodes/xref.el (xref--show-pos-in-buf): Simplify.
---
 lisp/progmodes/xref.el | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 87ce229..9522d7e 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -474,27 +474,17 @@ and finally return the window."
           (or (eq xref--original-window-intent 'frame)
               pop-up-frames))
          (action
-          (cond ((memq
-                  xref--original-window-intent
-                  '(window frame))
+          (cond ((eq xref--original-window-intent 'frame)
                  t)
+                ((eq xref--original-window-intent 'window)
+                 '(display-buffer-same-window))
                 ((and
                   (window-live-p xref--original-window)
                   (or (not (window-dedicated-p xref--original-window))
                       (eq (window-buffer xref--original-window) buf)))
-                 `(,(lambda (buf _alist)
-                      (set-window-buffer xref--original-window buf)
-                      xref--original-window))))))
-    (with-selected-window
-        (with-selected-window
-            ;; Just before `display-buffer', place ourselves in the
-            ;; original window to suggest preserving it. Of course, if
-            ;; user has deleted the original window, all bets are off,
-            ;; just use the selected one.
-            (or (and (window-live-p xref--original-window)
-                     xref--original-window)
-                (selected-window))
-          (display-buffer buf action))
+                 `((display-buffer-in-previous-window)
+                   (previous-window . ,xref--original-window))))))
+    (with-selected-window (display-buffer buf action)
       (xref--goto-char pos)
       (run-hooks 'xref-after-jump-hook)
       (let ((buf (current-buffer)))



reply via email to

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