From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Zachary Kanfer Newsgroups: gmane.emacs.devel 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 Message-ID: References: <838tn2glmt.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11433a0c534b0b054d3a63a3 X-Trace: blaine.gmane.org 1492288063 26938 195.159.176.226 (15 Apr 2017 20:27:43 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 15 Apr 2017 20:27:43 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Apr 15 22:27:38 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1czUIE-0006tJ-Ar for ged-emacs-devel@m.gmane.org; Sat, 15 Apr 2017 22:27:38 +0200 Original-Received: from localhost ([::1]:57990 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1czUIK-0003Rj-9L for ged-emacs-devel@m.gmane.org; Sat, 15 Apr 2017 16:27:44 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1czUID-0003Rd-5R for emacs-devel@gnu.org; Sat, 15 Apr 2017 16:27:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1czUIB-0007nr-Se for emacs-devel@gnu.org; Sat, 15 Apr 2017 16:27:37 -0400 Original-Received: from mail-qt0-x22a.google.com ([2607:f8b0:400d:c0d::22a]:34327) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1czUIA-0007lj-4L; Sat, 15 Apr 2017 16:27:34 -0400 Original-Received: by mail-qt0-x22a.google.com with SMTP id c45so81472513qtb.1; Sat, 15 Apr 2017 13:27:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=KwuDdE+tDGmM6ugtfkF6h7l59t6DRlz4+z+YYU+w6w8=; b=etgnsr020gBw7WZg9JmV4NG7OnnsjxN5xhIXhI0H5A7X2uD+5tpCJOWeEKSmUJ26pt E1/3s+9sdLg8vuak+AupUe2shnOI1VPXwfSIBKD0JN2Cn6RFcG8174rXVFRYxaQn71vu hTacdWlsjA02iB5eFRDKRJoFdJtoZ+9ADATtO+4u7gM0EEf+MD2avXhwD9lfupTdoPMl MPXe2UbTt6XDdYstDqA+ttODiitmK9sEt8C9yhASrgY6BLnJmFqVfShlTWOeMm0ThmnX 30BfE6e/Y+/F/pAsVl2YcRlV9TE3V5X0w8a7SwVF9mzY+eWxaOuy5Q41hsV4NlTKndMS E8qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=KwuDdE+tDGmM6ugtfkF6h7l59t6DRlz4+z+YYU+w6w8=; b=Uq1J3+E26fcuyU3ToE6O8hSaZDrZ1PHhC6hHW4Y0vXadxe1y0tvTCIeDtV7kc5ALth Q/Lzi3L0HoF6cOetTkZwnvGiWzff9bjRd8mcE/dyipt2WJJyD0HqXF6UFj3xrroNSFe4 nfT0rPMEA7eBHoxJHrwKRYu46g5bJFPdBj8ukpkEclBzclrgDSJlWj9D7EFqBJjbsMiJ /FRpwBq6bQlsaOQRh1mbqfMJhSPrblrstVZcEP9n5osKyjInHYpXMLIgZRaGq8M23q7e sKJelkHTnPj9NinNrYJ9gaXwM8/BbWSg9J8QI3GHB1CVlZhexpvNKJFzr5+oT1wrRL8b /dsg== X-Gm-Message-State: AN3rC/6Wa484Jw+2AxZjdt0KiCGwnR7B39D+XHgDOjeuM2KO7BRKCKPp ViHeGZiGnvxs0sC/Srs0yEwbkzMpgH3ZBTg= X-Received: by 10.200.36.212 with SMTP id t20mr3505991qtt.269.1492288053397; Sat, 15 Apr 2017 13:27:33 -0700 (PDT) Original-Received: by 10.140.28.98 with HTTP; Sat, 15 Apr 2017 13:27:12 -0700 (PDT) In-Reply-To: <838tn2glmt.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::22a X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:213980 Archived-At: --001a11433a0c534b0b054d3a63a3 Content-Type: text/plain; charset=UTF-8 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 wrote: > > From: Zachary Kanfer > > 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? > --001a11433a0c534b0b054d3a63a3 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thanks for the response. I'll look into lin= e-spacing.

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

+---------------------------= -----+
|=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |
|=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 |
|=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 |
|=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Title goes here!=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |
|=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |
|=C2=A0=C2=A0=C2=A0 $DATE=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 by $PERSON=C2=A0=C2=A0=C2=A0 |
|=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 |
|=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |
+= --------------------------------+

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

On Sat, Apr 15, 2017 at 3:44 AM, Eli Zaretskii <eliz@gnu= .org> wrote:
> From: Zachary Kanfer <zkanfer@gmail.com>
> Date: Sat, 15 Apr 2017 01:14:43 -0400
>
> (defun zck--window-max-lines-per-window (face &optional windo= w)
> "Calculate how many lines of text with face FACE can fit in WINDO= W."
> (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<= br> do all your calculations in pixels?=C2=A0 Or maybe fit-window-to-buffer
will do what you want?

--001a11433a0c534b0b054d3a63a3--