From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#55169: Can't combine window-min-height with window-height Date: Mon, 9 May 2022 09:24:52 +0200 Message-ID: References: <86y1zp5but.fsf@mail.linkov.net> <87czh0gp6m.fsf@gnus.org> <9753db0e-05f2-5927-80fb-50d17f16441d@gmx.at> <86czgxi3nn.fsf@mail.linkov.net> <86tua7pyfp.fsf@mail.linkov.net> <5e93dcad-4071-b4e2-d408-ba670413eb67@gmx.at> <868rriil03.fsf@mail.linkov.net> <0e9b53c4-b283-ca20-fa8a-995f2b58ed59@gmx.at> <865ymlje5o.fsf@mail.linkov.net> <8ae5e6ac-25f5-3feb-b05b-fbdb71e7ac1d@gmx.at> <864k24v0vo.fsf@mail.linkov.net> <865ymkrmze.fsf@mail.linkov.net> <86v8ujcd2r.fsf@mail.linkov.net> <3f7b273c-59f4-5486-728e-a0c8e09190a7@gmx.at> <86bkwahe5g.fsf@mail.linkov.net> <86mtfrj3bh.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32933"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen , 55169@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 09 09:26:12 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nnxmW-0008Sh-1R for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 09 May 2022 09:26:12 +0200 Original-Received: from localhost ([::1]:53556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nnxmU-0006p4-Mk for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 09 May 2022 03:26:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nnxmM-0006ov-Se for bug-gnu-emacs@gnu.org; Mon, 09 May 2022 03:26:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33733) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nnxmM-0008Mn-JX for bug-gnu-emacs@gnu.org; Mon, 09 May 2022 03:26:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nnxmM-0005Ai-Gj for bug-gnu-emacs@gnu.org; Mon, 09 May 2022 03:26:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 09 May 2022 07:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55169 X-GNU-PR-Package: emacs Original-Received: via spool by 55169-submit@debbugs.gnu.org id=B55169.165208110319807 (code B ref 55169); Mon, 09 May 2022 07:26:02 +0000 Original-Received: (at 55169) by debbugs.gnu.org; 9 May 2022 07:25:03 +0000 Original-Received: from localhost ([127.0.0.1]:55863 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnxlO-00059L-9E for submit@debbugs.gnu.org; Mon, 09 May 2022 03:25:02 -0400 Original-Received: from mout.gmx.net ([212.227.15.15]:36617) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nnxlM-00058n-5i for 55169@debbugs.gnu.org; Mon, 09 May 2022 03:25:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1652081093; bh=oiMQ32t1vdWHFJAxU0mSAj/Ioep0Iy7d6XzEYwbpgRI=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=AME0LyI6fB1DjaMuWXeXp5Mzn3lZi/sUEHysyQkU2mFnQtk7R62jQnKNyY+4fcdT/ j6lMJkxv6MiCph36jKSD8Y1ylpLVGXuGFqAR3mzzr1IwniFNTV8mekOFYHSAxu5XCv 6R7QRDkzBWgFEiIsIS7tetfdBHRpKOob6zXYkBhI= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [192.168.1.101] ([212.95.5.60]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N7R1T-1nrOVE2TRF-017jm7; Mon, 09 May 2022 09:24:53 +0200 Content-Language: en-US In-Reply-To: <86mtfrj3bh.fsf@mail.linkov.net> X-Provags-ID: V03:K1:aUOy2pe9Wg+AAfJNpQa7uOdzZ8xSup1HEWWedw933wkZQbQ/Crf SJex75QeZkM5z6kExpHr/JbSIgsr58lEXZRQVR5UzF/f8F1scT29d6nL7FvLP7Vn+od6xqA y0qguEa/8+BicjJYlf6OJZDAk2f32e0HInwKpKQXyDOsrnl9DwXBtsNbTYvO+/p/EvSuRZy eid2cbciAQUTclJTO513Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:vvqR6OAVLC8=:F9/aF5SiwATHQeEDr6nsa4 YNwPvuKSM3EkuExXdpnu/7d0evTbczj8gYvzKUKtFz7iwyY3GNTXSDVYXfO+9/ILzd6v16Akp ryYCvsrwpAdczxtSH0VDYOAHzNEdgcgPoLrQhxZEPj4uQBBxO3L23WnRAhtWO6cJEOQCaLj83 GXcnxmlWLE1qfrbIuRlVZSzTJmAliaMeU5r1zkfq0WswhGVGXZq1p8zE+81IwimrlwJJWrttI Zrv6/qpedgFFNZF8FuQFYMCWModt5PwgasqV3KKJCcD3FaSCBImHa/dY9mTAaaJslLStGsZ4t D7zaRT7XvbFucb7LzPUjmGGjL7Bob7Jm7FJ+2JzFuPTOnLps2omVASn5jISjxAg1gs7oWgcJ1 mRbz1FeDplThIjlPw4w1ub2jMFGQdhhPSACNItLwqFYFbB/Y3nCBaUFKMbEdW+XKJz5bkdsRn fpq4AIbmOFaRPfXPNnXOK1qpFE1a2Q4+aU7UnJ18zYGO6XB8FFZxRlsGIBd/oRiooJ3NTZk7i iQkkpY2Q+U31mlQKwFEeKqFl5rYkIrPY8FoPd+4b+3rdU7ajGvd9SyGDpYh/e5Iiq9eJYmDt/ ivcEdGfk9s+JHzdK8l4J073LxAFctzrFWRhY8yMO4n9jOOfSo7czhKC7OkJHW54SQuxVmeM3W UBue5nqk6E0AOalm/63cJFDczb4DesPitJJi+Cv5/Lv2CPCNiSdSwIcASSzxdj6C9p45LJY47 OENhgTXNquTb/shAXlZNA5+vKTrxRwxFM15KV2AKCrVzrQIuxRx3rAdQTCjYYOyidJbY4Z8u X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:231695 Archived-At: >>> (pop-to-buffer (generate-new-buffer "*edit string*") >>> '(display-buffer-below-selected >>> (window-height . (lambda (window) >>> (fit-window-to-buffer window nil 10))))) >> >> Sounds too complicated IMO. > > Actually a lambda is already supported, so no changes are required. We have to find a suitable way to explain that in the manual. > A special case for fit-window-to-buffer, shrink-window-* and other similar > could be implemented only when you are sure that a `window-min-height' entry > is not going to be used for other purposes besides of using it as an argument > of a window-height entry. You said that this is the case for 'fit-window-to-buffer' and that function is the canonical client for a 'window-height' function. So why bother about the rest? > BTW, fit-window-to-buffer has also other arguments: MAX-WIDTH and MIN-WIDTH. > Would they be useful for a window-width entry? Maybe. But let's talk about MAX-HEIGHT first. >> And if we really want to, we can always add a MIN-HEIGHT argument to >> 'shrink-window-if-larger-than-buffer' and handle it the same way. > > This is very much needed, thanks. See below (this should also fix the lie about the return value). martin (defun shrink-window-if-larger-than-buffer (&optional window min-height) "Shrink height of WINDOW if its buffer doesn't need so many lines. More precisely, shrink WINDOW vertically to be as small as possible, while still showing the full contents of its buffer. WINDOW must be a live window and defaults to the selected one. The optional argument MIN-HEIGHT specifies the minimum number of lines to which WINDOW may be shrunk and defaults to `window-min-height'. Do nothing if the buffer contains more lines than the present height of WINDOW, some of WINDOW's contents are scrolled out of view, shrinking WINDOW would also shrink another window, or WINDOW is the root window of its frame. Return non-nil if WINDOW was shrunk, nil otherwise." (interactive) (setq window (window-normalize-window window t)) ;; Make sure that WINDOW is vertically combined and `point-min' is ;; visible (for whatever reason that's needed). The remaining issues ;; should be taken care of by `fit-window-to-buffer'. (when (and (window-combined-p window) (pos-visible-in-window-p (point-min) window)) (let ((old-height (window-pixel-height window))) (fit-window-to-buffer window (window-total-height window) nil min-height) (/= old-height (window-pixel-height window)))))