emacs-devel
[Top][All Lists]
Advanced

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

Is there a built-in way to tell how many lines are in a window in a give


From: Zachary Kanfer
Subject: Is there a built-in way to tell how many lines are in a window in a given face?
Date: Sat, 15 Apr 2017 01:14:43 -0400

If I want to know how wide a window is, in terms of characters of a given face, I can use #'window-max-chars-per-line (https://www.gnu.org/software/emacs/manual/html_node/elisp/Window-Sizes.html#index-window_002dmax_002dchars_002dper_002dline).

But if I want to know how tall a window is in terms of characters of a given face, I don't think there's a built-in method to do so. At least, I can't seem to find it.

So I wrote one. This would be nice to get into Emacs if I haven't missed any existing functionality. My code :

(defun zck--window-max-lines-per-window (face &optional window)
  "Calculate how many lines of text with face FACE can fit in WINDOW."
  (truncate (window-body-height window t)
            (window-font-height window face)))

reply via email to

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