Subject: Re: bug#24193: 25.1; `window-min-size' fails for horizontal width when margins >= body text

From: martin rudalics <[email-masked]>
Date: Tue, 09 Aug 2016 11:49:08 +0200

> 1. emacs -Q
 > 2. in a frame 80 columns wide...
 > 3. M-: (set-window-margins nil 20 20)
 > 4. C-x 3
 >      => "Window #<window 1 on *scratch*> too small for splitting (2)"
 > 5. M-: (window-min-size nil t)
 >      => 42
 >
 > Expected results:
 >
 > Window should split horizontally. Minimum window width should not be dictated by margin width.
 >
 > Actual results:
 >
 > Margin width dictates minimum window width and prevents window splitting.

Correct.  The Elisp manual states

  -- Function: window-min-size &optional window horizontal ignore
           pixelwise
      This function returns the minimum size of WINDOW.  WINDOW must be
      a valid window and defaults to the selected one.  The optional
      argument HORIZONTAL non-`nil' means to return the minimum number
      of columns of WINDOW; otherwise return the minimum number of
      WINDOW's lines.

      The return value makes sure that all components of WINDOW remain
      fully visible if WINDOW's size were actually set to it.  With
      HORIZONTAL `nil' it includes the mode and header line, the
      horizontal scroll bar and the bottom divider, if present.  With
      HORIZONTAL non-`nil' it includes the margins and fringes, the
      vertical scroll bar and the right divider, if present.

If you want to make a smaller window you have to explicitly specify its
size:

(defun split-window-right-ignore (&optional size)
   (interactive)
   (split-window-right (or size (/ (window-total-width) 2))))

(define-key ctl-x-map "3" 'split-window-right-ignore)

martin