From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: Resizing windows after display-buffer Date: Sun, 24 Apr 2011 19:45:16 -0400 Message-ID: <87oc3v8b8z.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1303688729 1269 80.91.229.12 (24 Apr 2011 23:45:29 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 24 Apr 2011 23:45:29 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 25 01:45:25 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QE8zU-0005D7-MI for ged-emacs-devel@m.gmane.org; Mon, 25 Apr 2011 01:45:24 +0200 Original-Received: from localhost ([::1]:55739 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QE8zU-0002jw-8d for ged-emacs-devel@m.gmane.org; Sun, 24 Apr 2011 19:45:24 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:52104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QE8zP-0002jo-AI for emacs-devel@gnu.org; Sun, 24 Apr 2011 19:45:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QE8zO-0005zm-6S for emacs-devel@gnu.org; Sun, 24 Apr 2011 19:45:19 -0400 Original-Received: from vm-emlprdomr-06.its.yale.edu ([130.132.50.147]:34585) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QE8zO-0005zb-2c for emacs-devel@gnu.org; Sun, 24 Apr 2011 19:45:18 -0400 Original-Received: from furball (dhcp128036226127.central.yale.edu [128.36.226.127]) (authenticated bits=0) by vm-emlprdomr-06.its.yale.edu (8.14.4/8.14.4) with ESMTP id p3ONjGlg025083 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Sun, 24 Apr 2011 19:45:17 -0400 Original-Received: by furball (Postfix, from userid 1000) id 6215B16055B; Sun, 24 Apr 2011 19:45:16 -0400 (EDT) X-Scanned-By: MIMEDefang 2.71 on 130.132.50.147 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 130.132.50.147 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:138691 Archived-At: Not long ago, we discussed generalizing temp-buffer-resize-mode so that it isn't just for Help buffers. I propose doing this not with a minor mode, but by adding a defcustom, display-buffer-fit-window-to-buffer. See attached patch; window--display-buffer-2 (a subroutine of display-buffer) will check this and call fit-window-to-buffer. This should make temp-buffer-resize-mode unnecessary. It will also hopefully allow us to eliminate most calls to fit-window-to-buffer in the Lisp tree (which are completely unregulated AFAICT), instead putting the decision to fit displayed windows into one customizable location. Thoughts/suggestions? *** lisp/window.el 2011-04-19 13:44:55 +0000 --- lisp/window.el 2011-04-24 23:35:43 +0000 *************** *** 1038,1043 **** --- 1038,1059 ---- (raise-frame frame)) window)) + (defcustom display-buffer-fit-window-to-buffer nil + "Whether `display-buffer' should resize windows. + If the value is nil, no resizing is done. + + If the value is non-nil, it should be a cons cell (MIN . MAX). + Any time `display-buffer' displays a buffer in another window, it + calls `fit-window-to-buffer', using MIN and MAX as the minimum + and maximum window heights. Integers specify numbers of lines, + while floating point numbers specify fractions of the frame + height. + + This variable has no effect when `display-buffer-function' is + non-nil, unless the specified function handles it explicitly." + :type '(choice (const nil) cons) + :group 'display) + (defun window--display-buffer-2 (buffer window &optional dedicated) "Display BUFFER in WINDOW and make its frame visible. Set `window-dedicated-p' to DEDICATED if non-nil. *************** *** 1046,1052 **** (set-window-buffer window buffer) (when dedicated (set-window-dedicated-p window dedicated)) ! (window--display-buffer-1 window))) (defvar display-buffer-mark-dedicated nil "If non-nil, `display-buffer' marks the windows it creates as dedicated. --- 1062,1075 ---- (set-window-buffer window buffer) (when dedicated (set-window-dedicated-p window dedicated)) ! (prog1 (window--display-buffer-1 window) ! (when (consp display-buffer-fit-window-to-buffer) ! (let ((min (car display-buffer-fit-window-to-buffer)) ! (max (cdr display-buffer-fit-window-to-buffer)) ! (frame-height (frame-height (window-frame window)))) ! (if (floatp min) (setq min (round (* min frame-height)))) ! (if (floatp max) (setq max (round (* max frame-height)))) ! (fit-window-to-buffer window max min)))))) (defvar display-buffer-mark-dedicated nil "If non-nil, `display-buffer' marks the windows it creates as dedicated.