unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Juri Linkov <juri@linkov.net>
Cc: Lars Ingebrigtsen <larsi@gnus.org>, 55169@debbugs.gnu.org
Subject: bug#55169: Can't combine window-min-height with window-height
Date: Tue, 3 May 2022 11:21:26 +0200	[thread overview]
Message-ID: <5e93dcad-4071-b4e2-d408-ba670413eb67@gmx.at> (raw)
In-Reply-To: <86tua7pyfp.fsf@mail.linkov.net>

[-- Attachment #1: Type: text/plain, Size: 893 bytes --]

 >> BTW I do not understand well in which sense your original scenario
 >>
 >>    (pop-to-buffer (generate-new-buffer "*edit string*")
 >>                   '(display-buffer-below-selected
 >>                     (window-min-height . 10)
 >>                     (window-height . fit-window-to-buffer)))
 >>
 >> fails.  Do you mean that the window should be at least ten lines high
 >> despite of the fact that it's fit to an empty buffer?
 >
 > Exactly.  I expected that window-min-height takes precedence over window-height.

We could do something like the untested attached .diff.  But we really
should install it only if at least two or three people confirm that it's
the expected behavior.

Note: ‘shrink-window-if-larger-than-buffer’ does not re-enlarge a window
that already shows the buffer if its height is less than the specified
'window-min-height'.

martin

[-- Attachment #2: window--display-buffer.diff --]
[-- Type: text/x-patch, Size: 4504 bytes --]

diff --git a/lisp/window.el b/lisp/window.el
index dd297a3169..5643fb9af3 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -7245,8 +7245,12 @@ window--display-buffer
     (let* ((frame (window-frame window))
            (quit-restore (window-parameter window 'quit-restore))
 	   (window-height (assq 'window-height alist))
+           (min-height (or (cdr (assq 'window-min-height alist))
+                           window-min-height))
            (height (cdr window-height))
 	   (window-width (assq 'window-width alist))
+           (min-width (or (cdr (assq 'window-min-width alist))
+                          window-min-width))
            (width (cdr window-width))
            (window-size (assq 'window-size alist))
            (size (cdr window-size))
@@ -7300,26 +7304,31 @@ window--display-buffer
             (setq resize-temp-buffer-window-inhibit 'vertical)))
 	 ((numberp height)
 	  (let* ((new-height
-		  (if (integerp height)
-		      height
-		    (round
-		     (* (window-total-height (frame-root-window window))
-			height))))
+		  (max (if (integerp height)
+		           height
+		         (round
+		          (* (window-total-height (frame-root-window window))
+			     height)))
+                       min-height))
 		 (delta (- new-height (window-total-height window))))
 	    (when (and (window--resizable-p window delta nil 'safe)
 		       (window-combined-p window))
 	      (window-resize window delta nil 'safe)))
           (setq resize-temp-buffer-window-inhibit 'vertical))
          ((and (consp height) (eq (car height) 'body-lines))
-	  (let* ((delta (- (* (frame-char-height frame) (cdr height))
-                           (window-body-height window t))))
-	    (and (window--resizable-p window delta nil 'safe nil nil nil t)
+	  (let* ((delta (max (- (* (frame-char-height frame) (cdr height))
+                                (window-body-height window t))
+                             (- (* (frame-char-height frame) min-height)
+                                (window-pixel-height window)))))
+            (and (window--resizable-p window delta nil 'safe nil nil nil t)
 		 (window-combined-p window)
 	         (window-resize window delta nil 'safe t)))
           (setq resize-temp-buffer-window-inhibit 'vertical))
          ((functionp height)
-	  (ignore-errors (funcall height window))
-          (setq resize-temp-buffer-window-inhibit 'vertical)))
+          (let* ((min-height (cdr (assq 'window-min-height alist)))
+                 (window-min-height min-height))
+            (ignore-errors (funcall height window))
+            (setq resize-temp-buffer-window-inhibit 'vertical))))
 	;; Adjust width of window if asked for.
 	(cond
 	 ((not width)
@@ -7327,26 +7336,31 @@ window--display-buffer
             (setq resize-temp-buffer-window-inhibit 'horizontal)))
 	 ((numberp width)
 	  (let* ((new-width
-		  (if (integerp width)
-		      width
-		    (round
-		     (* (window-total-width (frame-root-window window))
-			width))))
+                  (max
+                   (if (integerp width)
+		       width
+		     (round
+		      (* (window-total-width (frame-root-window window))
+			 width)))
+                   min-width))
 		 (delta (- new-width (window-total-width window))))
 	    (when (and (window--resizable-p window delta t 'safe)
 		       (window-combined-p window t))
 	      (window-resize window delta t 'safe)))
           (setq resize-temp-buffer-window-inhibit 'horizontal))
          ((and (consp width) (eq (car width) 'body-columns))
-	  (let* ((delta (- (* (frame-char-width frame) (cdr width))
-                           (window-body-width window t))))
+	  (let* ((delta (max (- (* (frame-char-width frame) (cdr width))
+                                (window-body-width window t))
+                             (- (* (frame-char-width frame) min-width)
+                                (window-pixel-width window)))))
 	    (and (window--resizable-p window delta t 'safe nil nil nil t)
 		 (window-combined-p window t)
 	         (window-resize window delta t 'safe t)))
           (setq resize-temp-buffer-window-inhibit 'horizontal))
 	 ((functionp width)
-	  (ignore-errors (funcall width window))
-          (setq resize-temp-buffer-window-inhibit 'horizontal)))
+          (let* ((window-min-width min-width))
+	    (ignore-errors (funcall width window))
+            (setq resize-temp-buffer-window-inhibit 'horizontal))))
 
 	;; Preserve window size if asked for.
 	(when (consp preserve-size)

  reply	other threads:[~2022-05-03  9:21 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-28 17:58 bug#55169: Can't combine window-min-height with window-height Juri Linkov
2022-04-29 10:27 ` Lars Ingebrigtsen
2022-04-30  8:03   ` martin rudalics
2022-05-01 17:06     ` Juri Linkov
2022-05-02  7:37       ` martin rudalics
2022-05-02 18:53         ` Juri Linkov
2022-05-03  9:21           ` martin rudalics [this message]
2022-05-03 17:38             ` Juri Linkov
2022-05-04  7:54               ` martin rudalics
2022-05-04 19:29                 ` Juri Linkov
2022-05-05  7:47                   ` martin rudalics
2022-05-05  8:03                     ` Juri Linkov
2022-05-05  9:49                       ` martin rudalics
2022-05-05 16:37                         ` Juri Linkov
2022-05-06  7:02                           ` martin rudalics
2022-05-06  7:52                             ` Juri Linkov
2022-05-06 14:10                               ` martin rudalics
2022-05-06 15:34                                 ` Juri Linkov
2022-05-07  7:58                                   ` martin rudalics
2022-05-08 18:18                                     ` Juri Linkov
2022-05-09  7:24                                       ` martin rudalics
2022-05-09  7:38                                         ` martin rudalics
2022-05-09 18:58                                         ` Juri Linkov
2022-05-10  7:41                                           ` martin rudalics
2022-05-11  7:21                                             ` Juri Linkov
2022-05-11  8:19                                               ` martin rudalics
2022-05-12 17:03                                                 ` Juri Linkov
2022-05-13  7:01                                                   ` martin rudalics
2022-05-13 16:58                                                     ` Juri Linkov
2022-05-14  7:49                                                       ` martin rudalics
2022-05-11  9:03                                           ` Richard Stallman
2022-05-12 16:59                                             ` Juri Linkov
2022-05-18 18:20                                         ` Juri Linkov
2022-05-19  7:18                                           ` martin rudalics
2022-05-19 16:27                                             ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5e93dcad-4071-b4e2-d408-ba670413eb67@gmx.at \
    --to=rudalics@gmx.at \
    --cc=55169@debbugs.gnu.org \
    --cc=juri@linkov.net \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).