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

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

bug#19395: 25.0.50; Setting left fringe to 0 messes up window-width


From: martin rudalics
Subject: bug#19395: 25.0.50; Setting left fringe to 0 messes up window-width
Date: Fri, 19 Dec 2014 18:09:31 +0100

> Given the changes I pushed in commit b197822, you will no longer need
> all this complexity.  Just
>
>     (aref (font-info (face-font 'default)) 11)
>
> (For bullet-proof code, check that this is not zero, and if it is, use
> the 10th member instead; see the docs.)

Very good.  IIUC this means that I could use something like

(defun window-char-width (&optional window)
  "Return default character width for WINDOW.
WINDOW must be a live window and defaults to the selected one."
  (setq window (window-normalize-window window t))
  (with-current-buffer (window-buffer window)
    (let* ((info (font-info (face-font 'default)))
           (width (aref info 11)))
      (if (> width 0)
          width
        (aref info 10)))))

(defun window-char-height (&optional window)
  "Return default character height for WINDOW.
WINDOW must be a live window and defaults to the selected one."
  (setq window (window-normalize-window window t))
  (with-current-buffer (window-buffer window)
    (aref (font-info (face-font 'default)) 3)))

in window.el.  If that is the case, then the doc of `font-info' should
be somehow amended.  It currently says

Return information about a font named NAME on frame FRAME.

and nowhere mentions which buffer must be current or maybe even which
window must be selected.  I'm a bit too lazy to look into this myself.

Thanks a lot for this, martin





reply via email to

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