Subject: Re: bug#19194: 24.4.50; `window-body-width' is not dynamic relative to font size changes

From: Eli Zaretskii <[email-masked]>
Date: Wed, 26 Nov 2014 18:04:38 +0200

> From: Joe Corneli <[email-masked]>
> Date: Wed, 26 Nov 2014 13:47:14 +0000
> 
> Adjusting the font size, I would expect that the window's "body width"
> would change -- more characters can be fit into the same amount of
> screen space.  Current behaviour does not match this expectation.
> 
> M-: (window-body-width) RET  [Note result.]
> C-x C--
> M-: (window-body-width) RET  [Result is the same.]
> 
> The function is described:
> 
> "This function returns the width, in columns, of the body of window
> window."

That's not what it says in Emacs 24.4.  It says this:

  If PIXELWISE is nil, return the largest integer smaller than WINDOW's
  pixel width divided by the character width of WINDOW's frame.

IOW, the function is explicitly documented to measure columns in
canonical character units.  It functions as designed.

> If for some reason the "nominal" number of columns needs to calculated
> with reference to the default font, then there should be another
> function to return the "actual" number of columns.
> 
> ( I note one practical implication of the underlying issue here:
> https://github.com/kiwanami/emacs-calfw/issues/45 )

I've read that, and since I don't know what Calfw is or what it does,
it is hard for me to interpret your use case.  If you explain it in
small words, I'm sure a solution will be found, as Emacs has more than
enough functions to give you the width in any units you want, provided
that they are uniform (i.e., don't expect that to work when teh window
uses variable size fonts).

One simple technique is to measure everything in pixels, but I don't
know at this point whether this will solve your use case.