[Top][All Lists]

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

Re: split-window-right doesn't work with wide margins

From: martin rudalics
Subject: Re: split-window-right doesn't work with wide margins
Date: Wed, 20 Jan 2016 20:43:57 +0100

> `git bisect` points to commit 3477e27 `Complete pixelwise frame/window
> resizing, add horizontal scrollbar support.'

I remember now.  The situation is as follows: There is a common function
‘window-min-size’ which reports the minimum possible size for each
window.  In the horizontal case this includes the window's margins.
This function is used in virtually all size sanity checks, when resizing
windows or frames, adding scroll bars, fringes or margins, or splitting
windows as in the case at hand.

Now we have two choices: Either we do count margins in this function.
Then ‘split-window’ will fail as indicated in this report.  Or we do not
count them.  Then we will have to automatically cut margins down as we
did previously.  This will, however, affect user-set margins that are
_not_ continuously refreshed via a hook.

Suppose, for example, that you have a window on the left with user-set
margins and drag the divider of that window to the left in order to show
more contents of the window on the right.  In this case you may lose the
margins in the window on the left and Emacs won't restore them when you
drag the divider back.

>> Or write a ‘split-window-function’ which, when a window shall be split
>> horizontally, first resets the margins of the original window to a small
>> value, calls the orginal ‘split-window’ and restores the margins to some
>> suitable value afterwards.
> I found a variable `split-window-preferred-function`, which is probably
> what you mean? Would it be possible to give that variable a buffer-local
> value and set it to a function that first resets the window margins and
> then calls the default value of `split-window-preferred-function`?

No.  ‘split-window-preferred-function’ only affects ‘display-buffer’.
It does not affect ‘split-window’.  I attached a possible solution which
is far from ideal.  I hope you get the idea.  A similar solution would
be needed for ‘split-window-preferred-function’.  Essentially you would
have to rewrite ‘split-window-sensibly’ with a reset/restore mechanism
around the (window-splittable-p window t) and (split-window-right)
forms.  Slightly more tricky ...

Sooner or later we should find a way to dynamically insert some stretch
space on the left and right of a window body without affecting the value
of ‘window-margins’.


Attachment: window-margins.el
Description: application/emacs-lisp

reply via email to

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