Subject: Re: bug#37213: Execute set-window-margins. left-margin-width remains 0.

From: Eli Zaretskii <[email-masked]>
Date: Thu, 29 Aug 2019 09:42:17 +0300

> Date: Wed, 28 Aug 2019 19:57:06 +0000
> Cc: [email-masked]
> From: Alan Mackenzie <[email-masked]>
> 
> > I don't think this is a bug.  This variable is for _setting_ the
> > margin width, not for _returning_ its width as set "by other means".
> > See its documentation.
> 
> The documentation says "This variable specifies the width of the left
> margin".  As best, this is unclear.  What you're saying is that the
> variable ceases to specify that width, should the margin be altered by
> other means.
> 
> I maintain that this is either a bug in the documentation, or in the
> code.

I'm okay with clarifying the documentation, but let's first agree what
needs clarifying there.

> If the former, it should explicitly state that the variable is
> write-only, and its read value is undefined.  It should say that the
> function window-margins should be used instead.
> 
> But it might be easier just to amend the code.  There appear to be just
> two ways to set the width of the left margin (or the right margin), so
> if it gets set the second way, why not just set that variable?  Could
> this do any harm?  (Note: I haven't looked at the code, yet.)

Think about it: left-margin-width is a per-buffer variable.  A buffer
can be displayed in zero or more windows, and the margin is a window
property.  How can a single buffer-local variable reflect a value that
can be different in different windows, and can even be meaningless if
the buffer is not displayed in any window?

What happens in the code is that when a buffer is displayed in a
window, this variable is consulted, and the window's margin-width
attribute set accordingly.  The window margins can grow or shrink
thereafter, and the function window-margins then returns this window
attribute's value at any given moment for a specific window.