summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2021-05-20 11:37:59 +0800
committerJSDurand <mmemmew@gmail.com>2021-05-20 11:37:59 +0800
commitc1862c35c090d328ed107dfbf7b7fcf42ec6f492 (patch)
tree399ea813d7680f6b9d5eefa7bc297150c2d723b6
parent7d9de1e5e49f67ba95052c24c34d7a8a87342e13 (diff)
Add a function to fit window to buffer
* common.el: This originated from the novel package.
-rw-r--r--common.el16
1 files changed, 16 insertions, 0 deletions
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