Subject: bug#35592: Use display-buffer-in-direction for completion-like windows

From: Juri Linkov <[email-masked]>
Date: Wed, 08 May 2019 00:30:24 +0300

> Would these work despite of the 'fit-window-to-buffer' problem you
> reported earlier?

Actually I see no problem anymore with using display-buffer-in-direction
in the following patch.

Only a small plea: could you please add an alias ‘(direction . bottom)’
as a shorthand for ‘(direction . below) (window . main)’

Similarly:
top = (direction . above) (window . main)
bottom = (direction . below) (window . main)
leftmost = (direction . left) (window . main)
rightmost = (direction . right) (window . main)

diff --git a/lisp/proced.el b/lisp/proced.el
index ce379a7c6a..5e026aa386 100644
--- a/lisp/proced.el
+++ b/lisp/proced.el
@@ -1744,9 +1744,11 @@ proced-with-processes-buffer
        (save-window-excursion
          ;; Analogous to `dired-pop-to-buffer'
          ;; Don't split window horizontally.  (Bug#1806)
-         (let (split-width-threshold)
-           (pop-to-buffer (current-buffer)))
-         (fit-window-to-buffer (get-buffer-window) nil 1)
+         (display-buffer (current-buffer)
+                         '((display-buffer-in-direction)
+                           (direction . bottom)
+                           (window . main)
+                           (window-height . fit-window-to-buffer)))
          ,@body))))
 
 (defun proced-send-signal (&optional signal process-alist)
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index b9f98cdc4c..edf92ba94e 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -252,7 +252,11 @@ widget-choose
 	   (define-key map [?\M--] 'negative-argument)
 	   (save-window-excursion
 	     (let ((buf (get-buffer " widget-choose")))
-	       (fit-window-to-buffer (display-buffer buf))
+	       (display-buffer buf
+			       '((display-buffer-in-direction)
+				 (direction . bottom)
+				 (window . main)
+				 (window-height . fit-window-to-buffer)))
 	       (let ((cursor-in-echo-area t)
 		     (arg 1))
                  (while (not value)