From c1862c35c090d328ed107dfbf7b7fcf42ec6f492 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Thu, 20 May 2021 11:37:59 +0800 Subject: Add a function to fit window to buffer * common.el: This originated from the novel package. --- common.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/common.el b/common.el index c8b4fcc..1a062e8 100644 --- a/common.el +++ b/common.el @@ -151,6 +151,22 @@ windows. And ALIST is completely ignored. \(fn BUFFER ALIST)")) +;;;###autoload +(defvar durand-window-max-height 0.3 + "Maximal height of the bottom window. +The window is placed at the bottom.") + +;;;###autoload +(defun durand-fit-window-to-buffer-with-max (window) + "Fit WINDOW to its buffer. +This is a thin wrapper around `fit-window-to-buffer'. It passes +the window to the function with max-height equal to +`durand-window-max-height'." + (fit-window-to-buffer window + (floor + (* durand-window-max-height + (frame-height (window-frame window)))))) + ;; (defun durand-display-in-one-window (buffer _alist) ;; "Display BUFFER in one window. ;; ALIST is an association list of action symbols and values. See -- cgit v1.2.3-18-g5258