I am trying to calculate how many characters are being displayed in a window, but the information I get from (window-text-width) isn't updated if I call (text-scale-increase). Why?

A typical session might be

(window-text-width) ; => 90
(text-scale-increase 1) ; => t
(window-text-width) ; => 90

Quoting from C-hig (elisp)Frame Font

Each frame has a “default font” which specifies the default character size for that frame. This size is meant when retrieving or changing the size of a frame in terms of columns or lines (see Size Parameters). It is also used when resizing (see Window Sizes) or splitting (see Splitting Windows) windows.

Note that this value is frame specific, not buffer specific, so the buffer-local remapping of the default face performed by text-scale-increase does not have any effect on this.

Note also that a buffer may have a range of disparate character widths on display, in which case, even if the default character size was on a per buffer basis, a single value would still not (necessarily) be applicable to all characters.


It does not do what you expect (and request) because the Emacs maintainers rejected that possibility. I even provided a patch to realize it, as soon as text-scaling was made available.

See this message in bug thread #8379.

Fortunately, you can get what you want by using library face-remap+.el. It gives you user option text-scale-resize-window:

text-scale-resize-window is a variable defined in face-remap+.el.

Its value is t


Non-nil means text scaling resizes the window or frame accordingly. For example, if you use C-x C-- (text-scale-decrease) to make the text smaller, then the window or frame is made smaller by a similar factor.

If the window is not alone in its frame, then the window is resized. Otherwise, the frame is resized (provided you also use library fit-frame.el). The frame is always resized both horizontally and vertically.

You can customize this variable.

  • Ah, I see! Thank you for the libraries, they will be very useful! You solved my problem. (I marked @phils answer as correct though because of the way the question was posed.)
    – Tássio
    Sep 13 '17 at 3:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.