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: martin rudalics
Subject: Re: Window splitting issues with margins
Date: Fri, 13 Nov 2015 09:04:25 +0100

> linum-mode seems to assume that no-one else is using the margins

... the left margin only, to be precise ...

> and
> simply sets the left margin to the width it needs for itself. It'd be
> great if linum-mode (or any other mode of course) would be able to
> specify that it needs the left margin to be at least n characters wide
> and if there were an easy way for other packages to respect this.

The number of characters used by ‘linum-mode’ can vary dynamically
according to the size of the buffer.  If ‘linum-mode’ is non-nil in a
buffer, the left margin width of any window showing that buffer
specifies the number of characters needed by ‘linum-mode’.

> If it would also be possible to specify a margin width without locking
> it, then this could help with the issue I posted about. If it's known
> that parts of the margins are reserved, while others are not, the
> window-splitting functions know what part of the margins they can safely
> assume will be adjusted.
>
> Perhaps an example to make things clearer: assume a window width of 200
> characters. I want my text to be 80 chars wide and centered, so the left
> and right margins need to be (200-80)/2 = 60 each. Package X sets the
> margins to 60, but doesn't lock them. linum-mode says it needs a left
> margin of at least 4, so a width of 4 chars is locked. Now, the window
> is split and window-splittable-p must determine if the window can be
> split horizontally. Currently, it will base its judgement on the width
> of the text area, which is 80, the result being `nil' for 'no, the
> window cannot be split horizontally'. If a mode could "lock" part of the
> margin, it would know that it can assume a width of 200-4 = 196 and
> return `t' for 'yes, the window can be split horizontally'. The window
> is split and package X (through `window-configuration-change-hook')
> adjusts the margins.

I doubt it's easily possible for a package X to share the left margin
with ‘linum-mode’.  The latter has

(set-window-margins win width (cdr (window-margins win)))

so it simply doesn't care about other packages using the left margin.

martin




reply via email to

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