emacs-devel
[Top][All Lists]
Advanced

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

Re: Window splitting issues with margins


From: Joost Kremers
Subject: Re: Window splitting issues with margins
Date: Mon, 16 Nov 2015 21:11:41 +0100

> Op 16 nov. 2015 om 19:56 heeft martin rudalics <address@hidden> het volgende 
> geschreven:
> > Columns
> > that have such an associated SYM property are not considered reducible
> > by `window-splittable-p'.
> 
> As I tried to explain before: ‘window-splittable-p’ is hardly the
> function we care about here.  We care about ‘split-window’ itself.

Actually, I care about window-splittable-p, not about split-window. 
split-window is not a problem, because after it's done its work, 
window-configuration-change-hook is run, where writeroom-mode can (and in fact 
already does) adjust the window margins.

The problem with window-splittable-p is that it decides whether a window can be 
split horizontally *before* writeroom-mode has a chance to adjust the margins. 
Since in the cases I'm talking about, most of the window width is taken up by 
the margins, window-splittable-p thinks that the window is rather narrow (80 
characters, the width of the text area), while in fact it is quite wide (over 
200 chars) and could be split horizontally (because most of those 200 chars are 
not used for anything except keeping the text width small).

> > It would still have to be possible for modes like writeroom-mode to set
> > the margin to a specific width without setting a property, but those
> > margins would be considered reducible by `window-splittable-p'.
> > Furthermore, it shouldn't be possible to set a width that is smaller
> > than what other modes have set. This could either be enforced by the API
> > or writeroom-mode would have to ensure this itself.
> 
> There are two issues involved:
> 
> (1) ‘linum-mode’ sets the margin to some small, fixed value defeating
> ‘writeroom-mode’.  I think this can be fixed by having ‘writeroom-mode’
> set a ‘margins-min-width’ window parameter and have either
> ‘set_window_margins’ or modes like ‘linum-mode’ respect that value.

Actually, it's the other way around: linum-mode should set margins-min-width 
and writeroom-mode should respect that value. writeroom-mode's goal is to set 
the text width to a certain value. It doesn't care about the margins, except 
that it needs them in order achieve this goal. If the margins need to be set to 
0 to achieve the desired text width, that's fine. It's linum-mode that requires 
a minimum width for the left margin, because it needs to display something 
there.

Of course I'd be happy to update writeroom-mode to make it respect a minimum 
margin width set by some other package, but right now, I don't see any way of 
doing that.

> (2) When a window is split via ‘split-window-right’ or is shrunk
> horizontally, ‘writeroom-mode’ probably should reset its margins (and
> the window parameter) to some lower value.  It should do that via
> ‘window-configuration-change-hook’ (when splitting) and
> ‘window-size-change-functions’ (when the window is resized).  When the
> splitting is undone or the window is sized back, ‘writeroom-mode’ will
> probably want to enlarge the margins again.

Like I said, writeroom-mode already adjusts the margins when the window 
configuration changes.

There are indeed two issues, though I would formulate them somewhat differently:

(1) Different packages that use the margins have no way of interoperating 
without running into trouble at some point.

(2) When the margins are used to narrow the text width, window-splittable-p 
should take that into consideration when deciding if a window can be split 
horizontally. Right now, it doesn't.

I think (2) is a relatively minor issue. The worst thing that happens is that a 
window is split vertically that could have been split horizontally, e.g., when 
a help window is popped up. Still, I think it would be fairly easy to fix once 
issue (1) is taken care of.

(1) is a more serious issue, and one thing (though not the only thing) that 
needs to be recognised in order to find a way to deal with it is that the 
margins can be used for two fundamentally different types of purposes. On the 
one hand, they can be used to display some useful information about the buffer 
being shown in the window. On the other hand, they can be used to adjust the 
width of the text area. The crucial difference is that for the former purpose, 
the margins should not be reduced when the window width changes, while for the 
latter purpose, they can be adjusted freely. (Put differently, in the former 
case, the margins trump the text width, while in the latter, the text width 
trumps the margins).


-- 
Joost Kremers
Life has its moments




reply via email to

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