Subject: Re: bug#10960: linum-mode does not work properly when changing font size

From: Eli Zaretskii <[email-masked]>
Date: Sun, 11 Mar 2012 19:14:07 +0200

> From: Stefan Monnier <[email-masked]>
> Cc: [email-masked],  [email-masked],  [email-masked]
> Date: Sun, 11 Mar 2012 10:37:45 -0400
> 
> The way I see it, set-window-margins can only set the margin's size
> either to "no margin" or to a fixed size given as an integer.

That's correct, but all set-window-margins does is set two attributes
of the window object.  How to use that is entirely up to the display
engine.

When the time comes to display the window, the margins come into play
through the pixel coordinates where we draw the fringe bitmap.  The
code which computes those coordinates eventually calls
window_box_left_offset or window_box_right_offset, which call
window_box_width.  The latter is the single place in the code, AFAICS,
that converts the margin width from character cell units to pixel
units.

> So you'd have to let the Elisp code somehow figure out the *display*
> size of the margin's text (either in pixels or in
> char-cell-equivalent), and I don't know of any way Elisp can do that
> currently.

I didn't suggest to do this in Lisp.  (I don't think Lisp programs
should control the display at this low level.)  What I suggested is to
modify the calculation of the fringe pixel position based on how many
pixels are actually needed for the glyphs (character glyphs, stretch
glyphs, image glyphs, etc.) displayed in the fringe.  Isn't that what
you wanted?