emacs-devel
[Top][All Lists]
Advanced

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

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


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

Thanks for the response. I'll look into line-spacing.

What I'm doing is making a presentation mode (https://bitbucket.org/zck/zpresent.el;, available on Melpa) that presents from Emacs. I want to be able to, for example, make a title slide that looks like this (monospaced font required for this to look right):

+--------------------------------+
|                                |
|                                |
|                                |
|       Title goes here!         |
|                                |
|    $DATE         by $PERSON    |
|                                |
|                                |
+--------------------------------+

I'm certainly open to other ways of making this look right. I don't think doing calculations in pixels would work, unless there's a way to insert text at a specific pixel inside Emacs. And even if there were, that seems like a bunch more work to basically reproduce LaTeX.

On Sat, Apr 15, 2017 at 3:44 AM, Eli Zaretskii <address@hidden> wrote:
> From: Zachary Kanfer <address@hidden>
> Date: Sat, 15 Apr 2017 01:14:43 -0400
>
> (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)))

This doesn't take line-spacing into account, I think.

What are the use cases where you need these metrics of the window?
I'm not sure I understand the need for these facilities; e.g., why not
do all your calculations in pixels?  Or maybe fit-window-to-buffer
will do what you want?


reply via email to

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