(window-total-width) returns the number of columns (characters) that fit in the current window (https://www.gnu.org/software/emacs/manual/html_node/elisp/Window-Sizes.html). This will take the current font into account. My header line or mode line might have a different font from the text area (window body). How can I get the number of columns (characters) that fit there instead?

  • The mode-line fits in a dedicated window ... have you tried measuring that window expressly, e.g., with-selected-window ....?
    – lawlist
    Feb 26, 2020 at 21:06

1 Answer 1

(/ (window-pixel-width)
   (window-font-width nil face))

will return the current window width for a given face.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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