From: Chong Yidong <cyd@stupidchicken.com>
To: emacs-devel@gnu.org
Subject: Resizing windows after display-buffer
Date: Sun, 24 Apr 2011 19:45:16 -0400 [thread overview]
Message-ID: <87oc3v8b8z.fsf@stupidchicken.com> (raw)
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.
next reply other threads:[~2011-04-24 23:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-24 23:45 Chong Yidong [this message]
2011-04-25 0:09 ` Resizing windows after display-buffer Juanma Barranquero
2011-04-25 8:35 ` martin rudalics
2011-04-25 13:00 ` Juanma Barranquero
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87oc3v8b8z.fsf@stupidchicken.com \
--to=cyd@stupidchicken.com \
--cc=emacs-devel@gnu.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.