bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Joe Corneli
Subject: bug#19194: 24.4.50; `window-body-width' is not dynamic relative to font size changes
Date: Thu, 27 Nov 2014 10:54:47 +0000

On Thu, Nov 27 2014, martin rudalics wrote:

> I'm not sure whether we want to define the size of a window in terms of
> the buffer displayed in that window.  One consequence of such a change
> would be that the sum of the total height of two windows might no more
> equal the total height of their parent window.

I think you are totally right.  To keep the buffer and window
distinction properly, my note should probably be read as a feature
request, not a bug report.  The request is for a function such as
`buffer-body-width' that would return the width of the current displayed
buffer in em-length units.

> If you told me how you get the "adjusted font size", I could tell you
> how to scale the value returned by `window-body-width' accordingly.

Sounds promising!  I just pressed C-x C-- which runs `text-scale-adjust'
to the effect: "Decrease the default face height by one step".  The step
is `text-scale-mode-step', unchanged from its default value of 1.2.  The
number of steps looks to be stored buffer-locally as
`text-scale-mode-amount'.

... So a candidate function would be:

(defun buffer-body-width (&optional buffer pixelwise)
  (let ((width (window-body-width (get-buffer-window (or buffer
                                                         (current-buffer)))
                                  pixelwise)))
    (floor (cond 
            ((eq text-scale-mode-amount 0)
             width)
            ((> text-scale-mode-amount 0)
             (/ width (* text-scale-mode-step text-scale-mode-amount)))
            ((< text-scale-mode-amount 0)
             (* width (* -1 text-scale-mode-step text-scale-mode-amount)))))))









reply via email to

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