bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#33870: 27.0.50; xref-goto-xref not configurable


From: João Távora
Subject: bug#33870: 27.0.50; xref-goto-xref not configurable
Date: Mon, 07 Jan 2019 14:21:55 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (windows-nt)

Juri Linkov <address@hidden> writes:

> Hi João
>
>> Any simplification to the implementation that keeps the
>> "keep original window intent" behavior across xref
>> intermediate buffers is very welcome.
>
> Thanks for the explanation.  Now I understand better the intent in
> xref--show-pos-in-buf. Generally, I'd like to see the “keep original
> window intent” behavior in more places, e.g. in *Occur*, *grep*, etc.
> Based on your explanation, I've been able to write the patch that does
> the following:

Hi again, Juri

After re-reading your patch more closely and giving it some more
testing, I've discovered it breaks an existing use case:

   Emacs -Q
   C-x 2 ;; split-window-horizontally
   C-x 4 . ;; xref-find-definitions-other-window
   xref-backend-definitions RET
   C-n RET ;; in the resulting *xref* buffer
   
Expected xref.el to appear in the bottom window which was my original
intent when I said "other window".  In the current master this works OK,
in your patch it doesn't.

But don't worry, I've fixed that.  In the patch that I attach to this
message, none of the current UI changes is changed, but the xref window
should now be configurable as is the original request of this bug.

I've also renamed window.el's window--display-buffer to
window-display-buffer throughout Emacs (i.e. made it public).

After we merge this, we can continue the discussion about the changing
the xref UI in the other bug you opened, bug#33992

>From 424fe397c86026469a3853e86ca486d549f58100 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= <address@hidden>
Date: Mon, 7 Jan 2019 14:16:35 +0000
Subject: [PATCH] Make xref's choice of windows easier to configure

Fixes: bug#33870

Allow for the usual user configuration strategies involving
display-buffer-alist, etc. while maintaining the "keep original window
intent" of xref-find-definitions, xref-find-references, etc.

* lisp/windmove.el (windmove-display-in-direction): Use
window--display-buffer.

* lisp/window.el (display-buffer-in-atom-window):
(window--make-major-side-window):
(display-buffer-in-side-window):
(display-buffer-in-side-window):
(display-buffer-in-side-window):
(display-buffer-use-some-frame):
(display-buffer-same-window):
(display-buffer-reuse-window):
(display-buffer-reuse-mode-window):
(display-buffer-pop-up-frame):
(display-buffer-pop-up-window):
(display-buffer-in-child-frame):
(display-buffer-below-selected):
(display-buffer-below-selected):
(display-buffer-below-selected):
(display-buffer-below-selected):
(display-buffer-at-bottom):
(display-buffer-in-previous-window):
(display-buffer-use-some-window): Use window-display-buffer.
(window-display-buffer): Rename from window--display-buffer.

* lisp/progmodes/xref.el (xref--show-pos-in-buf): Use
window-display-buffer.
---
 lisp/progmodes/xref.el |  5 ++---
 lisp/windmove.el       |  2 +-
 lisp/window.el         | 46 +++++++++++++++++++++---------------------
 3 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 87ce2299c5..20eaa51bef 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -482,9 +482,8 @@ xref--show-pos-in-buf
                   (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))))))
+                 `(,(lambda (buf alist)
+                      (window-display-buffer buf xref--original-window 'reuse 
alist)))))))
     (with-selected-window
         (with-selected-window
             ;; Just before `display-buffer', place ourselves in the
diff --git a/lisp/windmove.el b/lisp/windmove.el
index 65270d9bbe..54f0098de7 100644
--- a/lisp/windmove.el
+++ b/lisp/windmove.el
@@ -626,7 +626,7 @@ windmove-display-in-direction
                     (type 'reuse))
                 (unless window
                   (setq window (split-window nil nil dir) type 'window))
-               (setq new-window (window--display-buffer buffer window type 
alist)))))
+               (setq new-window (window-display-buffer buffer window type 
alist)))))
           display-buffer-overriding-action)
     (message "[display-%s]" dir)))
 
diff --git a/lisp/window.el b/lisp/window.el
index 37d82c060c..cf923f7dc6 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -700,7 +700,7 @@ display-buffer-in-atom-window
        (set-window-parameter window 'window-atom 'main))
       (set-window-parameter new 'window-atom side)
       ;; Display BUFFER in NEW and return NEW.
-      (window--display-buffer
+      (window-display-buffer
        buffer new 'window alist display-buffer-mark-dedicated))))
 
 (defun window--atom-check-1 (window)
@@ -985,7 +985,7 @@ window--make-major-side-window
       (with-current-buffer buffer
         (setq window--sides-shown t))
       ;; Install BUFFER in new window and return WINDOW.
-      (window--display-buffer buffer window 'window alist 'side))))
+      (window-display-buffer buffer window 'window alist 'side))))
 
 (defun display-buffer-in-side-window (buffer alist)
   "Display BUFFER in a side window of the selected frame.
@@ -1113,7 +1113,7 @@ display-buffer-in-side-window
                 ;; Reuse `this-window'.
                  (with-current-buffer buffer
                    (setq window--sides-shown t))
-                (window--display-buffer
+                (window-display-buffer
                   buffer this-window 'reuse alist dedicated))
            (and (or (not max-slots) (< slots max-slots))
                 (or (and next-window
@@ -1131,7 +1131,7 @@ display-buffer-in-side-window
                   (set-window-parameter window 'window-slot slot)
                    (with-current-buffer buffer
                      (setq window--sides-shown t))
-                  (window--display-buffer
+                  (window-display-buffer
                     buffer window 'window alist dedicated))
            (and best-window
                 ;; Reuse `best-window'.
@@ -1140,7 +1140,7 @@ display-buffer-in-side-window
                   (set-window-parameter best-window 'window-slot slot)
                    (with-current-buffer buffer
                      (setq window--sides-shown t))
-                   (window--display-buffer
+                   (window-display-buffer
                    buffer best-window 'reuse alist dedicated)))))))))
 
 (defun window-toggle-side-windows (&optional frame)
@@ -6748,7 +6748,7 @@ window--even-window-sizes
            (/ (- (window-total-height window) (window-total-height)) 2))
         (error nil))))))
 
-(defun window--display-buffer (buffer window type &optional alist dedicated)
+(defun window-display-buffer (buffer window type &optional alist dedicated)
   "Display BUFFER in WINDOW.
 TYPE must be one of the symbols `reuse', `window' or `frame' and
 is passed unaltered to `display-buffer-record-window'.  ALIST is
@@ -7190,7 +7190,7 @@ display-buffer-use-some-frame
                 frame nil (cdr (assq 'inhibit-same-window alist))))))
     (when window
       (prog1
-          (window--display-buffer
+          (window-display-buffer
            buffer window 'reuse alist display-buffer-mark-dedicated)
         (unless (cdr (assq 'inhibit-switch-frame alist))
           (window--maybe-raise-frame frame))))))
@@ -7204,7 +7204,7 @@ display-buffer-same-window
   (unless (or (cdr (assq 'inhibit-same-window alist))
              (window-minibuffer-p)
              (window-dedicated-p))
-    (window--display-buffer buffer (selected-window) 'reuse alist)))
+    (window-display-buffer buffer (selected-window) 'reuse alist)))
 
 (defun display-buffer--maybe-same-window (buffer alist)
   "Conditionally display BUFFER in the selected window.
@@ -7252,7 +7252,7 @@ display-buffer-reuse-window
                              (get-buffer-window-list buffer 'nomini
                                                      frames))))))
     (when (window-live-p window)
-      (prog1 (window--display-buffer buffer window 'reuse alist)
+      (prog1 (window-display-buffer buffer window 'reuse alist)
        (unless (cdr (assq 'inhibit-switch-frame alist))
          (window--maybe-raise-frame (window-frame window)))))))
 
@@ -7316,7 +7316,7 @@ display-buffer-reuse-mode-window
                                 derived-mode-same-frame
                                 derived-mode-other-frame))))
         (when (window-live-p window)
-          (prog1 (window--display-buffer buffer window 'reuse alist)
+          (prog1 (window-display-buffer buffer window 'reuse alist)
             (unless (cdr (assq 'inhibit-switch-frame alist))
               (window--maybe-raise-frame (window-frame window)))))))))
 
@@ -7356,7 +7356,7 @@ display-buffer-pop-up-frame
               (with-current-buffer buffer
                 (setq frame (funcall fun)))
               (setq window (frame-selected-window frame)))
-      (prog1 (window--display-buffer
+      (prog1 (window-display-buffer
              buffer window 'frame alist display-buffer-mark-dedicated)
        (unless (cdr (assq 'inhibit-switch-frame alist))
          (window--maybe-raise-frame frame))))))
@@ -7386,7 +7386,7 @@ display-buffer-pop-up-window
                                (window--try-to-split-window
                                 (get-lru-window frame t) alist))))
 
-      (prog1 (window--display-buffer
+      (prog1 (window-display-buffer
              buffer window 'window alist display-buffer-mark-dedicated)
        (unless (cdr (assq 'inhibit-switch-frame alist))
          (window--maybe-raise-frame (window-frame window)))))))
@@ -7452,7 +7452,7 @@ display-buffer-in-child-frame
         (setq frame (make-frame parameters))
         (setq window (frame-selected-window frame))))
 
-    (prog1 (window--display-buffer
+    (prog1 (window-display-buffer
            buffer window 'frame alist display-buffer-mark-dedicated)
       (unless (cdr (assq 'inhibit-switch-frame alist))
        (window--maybe-raise-frame frame)))))
@@ -7476,7 +7476,7 @@ display-buffer-below-selected
              (eq buffer (window-buffer window))
             (or (not (numberp min-height))
                 (>= (window-height window) min-height)
-                ;; 'window--display-buffer' can resize this window if
+                ;; 'window-display-buffer' can resize this window if
                 ;; and only if it has a 'quit-restore' parameter
                 ;; certifying that it always showed BUFFER before.
                 (let ((height (window-height window))
@@ -7484,7 +7484,7 @@ display-buffer-below-selected
                   (and quit-restore
                        (eq (nth 1 quit-restore) 'window)
                        (window-resizable-p window (- min-height height)))))
-            (window--display-buffer buffer window 'reuse alist))
+            (window-display-buffer buffer window 'reuse alist))
        (and (not (frame-parameter nil 'unsplittable))
              (or (not (numberp min-height))
                 (window-sizable-p nil (- min-height)))
@@ -7492,7 +7492,7 @@ display-buffer-below-selected
                   split-width-threshold)
                (setq window (window--try-to-split-window
                              (selected-window) alist)))
-             (window--display-buffer
+             (window-display-buffer
               buffer window 'window alist display-buffer-mark-dedicated))
        (and (setq window (window-in-direction 'below))
              (not (window-dedicated-p window))
@@ -7500,7 +7500,7 @@ display-buffer-below-selected
                 ;; A window that showed another buffer before cannot
                 ;; be resized.
                 (>= (window-height window) min-height))
-            (window--display-buffer
+            (window-display-buffer
               buffer window 'reuse alist display-buffer-mark-dedicated)))))
 
 (defun display-buffer--maybe-at-bottom (buffer alist)
@@ -7533,20 +7533,20 @@ display-buffer-at-bottom
         (setq bottom-window window))))
      nil nil 'nomini)
     (or (and bottom-window-shows-buffer
-            (window--display-buffer
+            (window-display-buffer
              buffer bottom-window 'reuse alist display-buffer-mark-dedicated))
        (and (not (frame-parameter nil 'unsplittable))
             (let (split-width-threshold)
               (setq window (window--try-to-split-window bottom-window alist)))
-            (window--display-buffer
+            (window-display-buffer
              buffer window 'window alist display-buffer-mark-dedicated))
        (and (not (frame-parameter nil 'unsplittable))
             (setq window (split-window-no-error (window-main-window)))
-            (window--display-buffer
+            (window-display-buffer
              buffer window 'window alist display-buffer-mark-dedicated))
        (and (setq window bottom-window)
             (not (window-dedicated-p window))
-            (window--display-buffer
+            (window-display-buffer
              buffer window 'reuse alist display-buffer-mark-dedicated)))))
 
 (defun display-buffer-in-previous-window (buffer alist)
@@ -7603,7 +7603,7 @@ display-buffer-in-previous-window
        (setq best-window window)))
     ;; Return best or second best window found.
     (when (setq window (or best-window second-best-window))
-      (window--display-buffer buffer window 'reuse alist))))
+      (window-display-buffer buffer window 'reuse alist))))
 
 (defun display-buffer-use-some-window (buffer alist)
   "Display BUFFER in an existing window.
@@ -7643,7 +7643,7 @@ display-buffer-use-some-window
          (error nil)))
 
       (prog1
-         (window--display-buffer buffer window 'reuse alist)
+         (window-display-buffer buffer window 'reuse alist)
        (window--even-window-sizes window)
        (unless (cdr (assq 'inhibit-switch-frame alist))
          (window--maybe-raise-frame (window-frame window)))))))
-- 
2.19.2


reply via email to

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