all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Resizing windows after display-buffer
@ 2011-04-24 23:45 Chong Yidong
  2011-04-25  0:09 ` Juanma Barranquero
  0 siblings, 1 reply; 4+ messages in thread
From: Chong Yidong @ 2011-04-24 23:45 UTC (permalink / raw
  To: emacs-devel

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.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-04-25 13:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-24 23:45 Resizing windows after display-buffer Chong Yidong
2011-04-25  0:09 ` Juanma Barranquero
2011-04-25  8:35   ` martin rudalics
2011-04-25 13:00     ` Juanma Barranquero

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.