emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-25 0cee66c: Facultatively ignore margins when splitt


From: Martin Rudalics
Subject: [Emacs-diffs] emacs-25 0cee66c: Facultatively ignore margins when splitting and resizing windows (Bug#24193)
Date: Tue, 16 Aug 2016 07:20:37 +0000 (UTC)

branch: emacs-25
commit 0cee66c3f1e92702774e670b32f3dded1a4c3957
Author: Martin Rudalics <address@hidden>
Commit: Martin Rudalics <address@hidden>

    Facultatively ignore margins when splitting and resizing windows (Bug#24193)
    
    Provide a new window parameter 'min-margins' which allows to
    ignore the actual widths of a window's margins when splitting or
    resizing that window horizontally.  This should serve as a
    workaround for handling the problems raised by Bug#24193.
    
    * lisp/window.el (window--min-size-1): Handle new window
    parameter 'min-margins'.
    (split-window): Fix text of error messages.
    * doc/lispref/windows.texi (Window Parameters): Describe new
    parameter 'min-margins'.
---
 doc/lispref/windows.texi |   21 +++++++++++++++++++++
 lisp/window.el           |   25 ++++++++++++++++++-------
 2 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index 55d90bd..386584b 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -4349,6 +4349,27 @@ window when it deletes the window passed to it as 
argument.
 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.
+
address@hidden @code{min-margins}
+The value of this parameter is a cons cell whose @sc{car} and @sc{cdr},
+if address@hidden, specify the minimum values (in columns) for the left
+and right margin of this window.  When present, Emacs will use these
+values instead of the actual margin widths for determining whether a
+window can be split or shrunk horizontally.
+
+Emacs never auto-adjusts the margins of any window after splitting or
+resizing it.  It is sole responsibility of the application that has set
+this parameter to adjust the margins of this window as well as those of
+any new window that inherits this window's margins due to a split.
+Both, @code{window-configuration-change-hook} and
address@hidden (@pxref{Window Hooks}), should be
+employed for this purpose.
+
+This parameter was introduced in Emacs version 25.1 to support
+applications that use large margins to center buffer text within a
+window and should be used, with due care, exclusively by those
+applications.  It might 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..8505bef 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -1383,10 +1383,21 @@ ignore width restrictions for WINDOW."
          (let* ((char-size (frame-char-size window t))
                 (fringes (window-fringes window))
                 (margins (window-margins window))
+                 ;; Let the 'min-margins' parameter override the actual
+                 ;; widths of the margins.  We allow any number to
+                 ;; replace the values specified by `window-margins'.
+                 ;; See bug#24193 for the rationale of this parameter.
+                 (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))))
@@ -4774,7 +4785,7 @@ frame.  The selected window is not changed by this 
function."
                        (window-sizable-p
                         parent (- (+ new-pixel-size divider-width)) horizontal
                         (setq ignore 'preserved) t))
-             (error "Window %s too small for splitting (1)" parent)))
+             (error "Window %s too small for splitting" parent)))
           ((and (> (+ new-pixel-size divider-width
                       (window-min-size window horizontal nil t))
                    old-pixel-size)
@@ -4783,7 +4794,7 @@ frame.  The selected window is not changed by this 
function."
                        window horizontal (setq ignore 'preserved) t))
                    old-pixel-size))
            ;; SIZE unspecified, no resizing.
-           (error "Window %s too small for splitting (2)" window))))
+           (error "Window %s too small for splitting" window))))
         ((and (>= pixel-size 0)
               (or (>= pixel-size old-pixel-size)
                   (< new-pixel-size
@@ -4791,7 +4802,7 @@ frame.  The selected window is not changed by this 
function."
          ;; SIZE specified as new size of old window.  If the new size
          ;; is larger than the old size or the size of the new window
          ;; would be less than the safe minimum, signal an error.
-         (error "Window %s too small for splitting (3)" window))
+         (error "Window %s too small for splitting" window))
         (resize
          ;; SIZE specified, resizing.
          (unless (or (window-sizable-p
@@ -4801,13 +4812,13 @@ frame.  The selected window is not changed by this 
function."
                       parent (- (+ new-pixel-size divider-width)) horizontal
                       (setq ignore 'preserved) t))
            ;; If we cannot resize the parent give up.
-           (error "Window %s too small for splitting (4)" parent)))
+           (error "Window %s too small for splitting" parent)))
         ((or (< new-pixel-size
                 (window-safe-min-pixel-size window horizontal))
              (< (- old-pixel-size new-pixel-size)
                 (window-safe-min-pixel-size window horizontal)))
          ;; SIZE specification violates minimum size restrictions.
-         (error "Window %s too small for splitting (5)" window)))
+         (error "Window %s too small for splitting" window)))
 
        (window--resize-reset frame horizontal)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]