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: Juri Linkov
Subject: bug#33870: 27.0.50; xref-goto-xref not configurable
Date: Sun, 06 Jan 2019 01:23:32 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

>> when xref-find-definitions pops up the xref window, usually it
>> contains just 2 lines taking half of the screen where most space is
>> uselessly empty.
>
> We have fit-window-to-buffer for these situations.
>
>> The distinction between internal and public window functions is quite fuzzy.
>
> To my mind, internal functions shouldn't be used outside of the file
> that defines them.

This patch addresses all these concerns.

display-buffer--maybe-at-bottom can be renamed to
display-buffer-maybe-at-bottom without a deprecation alias
because it was added in Emacs 27.

diff --git a/lisp/window.el b/lisp/window.el
index 37d82c060c..015933839d 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -7457,6 +7457,21 @@ display-buffer-in-child-frame
       (unless (cdr (assq 'inhibit-switch-frame alist))
        (window--maybe-raise-frame frame)))))
 
+(defun display-buffer-maybe-below-selected (buffer alist)
+  ;; This is a copy of `display-buffer-fallback-action'
+  ;; where `display-buffer-use-some-window' is replaced
+  ;; with `display-buffer-below-selected'.
+  (let ((alist (append alist `(,(if temp-buffer-resize-mode
+                                   '(window-height . resize-temp-buffer-window)
+                                 '(window-height . fit-window-to-buffer))
+                              ,(when temp-buffer-resize-mode
+                                 '(preserve-size . (nil . t)))))))
+    (or (display-buffer--maybe-same-window buffer alist)
+        (display-buffer-reuse-window buffer alist)
+        (display-buffer--maybe-pop-up-frame buffer alist)
+        (display-buffer-in-previous-window buffer alist)
+        (display-buffer-below-selected buffer alist))))
+
 (defun display-buffer-below-selected (buffer alist)
   "Try displaying BUFFER in a window below the selected window.
 If there is a window below the selected one and that window
@@ -7503,7 +7518,10 @@ display-buffer-below-selected
             (window--display-buffer
               buffer window 'reuse alist display-buffer-mark-dedicated)))))
 
-(defun display-buffer--maybe-at-bottom (buffer alist)
+(defun display-buffer-maybe-at-bottom (buffer alist)
+  ;; This is a copy of `display-buffer-fallback-action'
+  ;; where `display-buffer-use-some-window' is replaced
+  ;; with `display-buffer-at-bottom'.
   (let ((alist (append alist `(,(if temp-buffer-resize-mode
                                    '(window-height . resize-temp-buffer-window)
                                  '(window-height . fit-window-to-buffer))
@@ -7512,6 +7530,7 @@ display-buffer--maybe-at-bottom
     (or (display-buffer--maybe-same-window buffer alist)
         (display-buffer-reuse-window buffer alist)
         (display-buffer--maybe-pop-up-frame buffer alist)
+        (display-buffer-in-previous-window buffer alist)
         (display-buffer-at-bottom buffer alist))))
 
 (defun display-buffer-at-bottom (buffer alist)
diff --git a/lisp/files.el b/lisp/files.el
index 6ccb001e35..0741dbc19e 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -3396,7 +3396,7 @@ hack-local-variables-confirm
 
       ;; Display the buffer and read a choice.
       (save-window-excursion
-       (pop-to-buffer buf '(display-buffer--maybe-at-bottom))
+       (pop-to-buffer buf '(display-buffer-maybe-at-bottom))
        (let* ((exit-chars '(?y ?n ?\s ?\C-g ?\C-v))
               (prompt (format "Please type %s%s: "
                               (if offer-save "y, n, or !" "y or n")
@@ -7053,7 +7053,9 @@ save-buffers-kill-emacs
            (or (not active)
                (with-displayed-buffer-window
                 (get-buffer-create "*Process List*")
-                '(display-buffer--maybe-at-bottom)
+                '(display-buffer-maybe-at-bottom
+                  (window-height . fit-window-to-buffer)
+                  (preserve-size nil . t))
                 #'(lambda (window _value)
                     (with-selected-window window
                       (unwind-protect
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 5760a2e49d..7dede4e616 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1828,18 +1828,12 @@ minibuffer-completion-help
              (display-buffer-mark-dedicated 'soft))
         (with-displayed-buffer-window
           "*Completions*"
-          ;; This is a copy of `display-buffer-fallback-action'
-          ;; where `display-buffer-use-some-window' is replaced
-          ;; with `display-buffer-at-bottom'.
-          `((display-buffer--maybe-same-window
-             display-buffer-reuse-window
-             display-buffer--maybe-pop-up-frame
-             ;; Use `display-buffer-below-selected' for inline completions,
-             ;; but not in the minibuffer (e.g. in `eval-expression')
-             ;; for which `display-buffer-at-bottom' is used.
-             ,(if (eq (selected-window) (minibuffer-window))
-                  'display-buffer-at-bottom
-                'display-buffer-below-selected))
+          ;; Use `display-buffer-maybe-below-selected' for inline completions,
+          ;; but not in the minibuffer (e.g. in `eval-expression')
+          ;; for which `display-buffer-maybe-at-bottom' is used.
+          `((,(if (eq (selected-window) (minibuffer-window))
+                  'display-buffer-maybe-at-bottom
+                'display-buffer-maybe-below-selected))
            ,(if temp-buffer-resize-mode
                 '(window-height . resize-temp-buffer-window)
               '(window-height . fit-window-to-buffer))

reply via email to

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