diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi index 55d90bd..7c07dd1 100644 --- a/doc/lispref/windows.texi +++ b/doc/lispref/windows.texi @@ -4349,6 +4349,24 @@ Window Parameters The fourth element is the buffer whose display caused the creation of this parameter. @code{quit-restore-window} deletes the specified window only if it still shows that buffer. + +@item @code{min-margins} +The value of this parameter is a cons cell specifying the minimum values +(in columns) for the left and right margin of this window. When +present, Emacs will use these values instead of the real margin widths +for determining whether a window can be split or shrunk. + +Emacs does not auto-adjust the margins of any window after splitting or +resizing it. It is sole responsibility of the application that sets +this parameter to adjust the margins of this window as well as those of +any new window created by a split. The hooks to achieve that are +@code{window-configuration-change-hook} and +@code{window-size-change-functions} (@pxref{Window Hooks}). + +This parameter was introduced in Emacs version 25.1 as a conspiracy hack +for applications that use large margins to center buffer text within a +window and should be used with extreme care. It can be replaced by an +improved solution in future versions of Emacs. @end table There are additional parameters @code{window-atom} and @code{window-side}; diff --git a/lisp/window.el b/lisp/window.el index f7a547b..ca8141b 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -1383,10 +1383,17 @@ window--min-size-1 (let* ((char-size (frame-char-size window t)) (fringes (window-fringes window)) (margins (window-margins window)) + (min-margins (window-parameter window 'min-margins)) + (left-min-margin (and min-margins + (numberp (car min-margins)) + (car min-margins))) + (right-min-margin (and min-margins + (numberp (cdr min-margins)) + (cdr min-margins))) (pixel-width (+ (window-safe-min-size window t t) - (* (or (car margins) 0) char-size) - (* (or (cdr margins) 0) char-size) + (* (or left-min-margin (car margins) 0) char-size) + (* (or right-min-margin(cdr margins) 0) char-size) (car fringes) (cadr fringes) (window-scroll-bar-width window) (window-right-divider-width window))))