unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jim Porter <jporterbugs@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 55696@debbugs.gnu.org, jeff.kowalski@gmail.com
Subject: bug#55696: 28.1; eshell fails to respect text-scale-increase
Date: Fri, 3 Jun 2022 13:30:01 -0700	[thread overview]
Message-ID: <0278e759-237b-a32b-4b1f-fbdacf39c8ef@gmail.com> (raw)
In-Reply-To: <831qw6dzra.fsf@gnu.org>

On 6/2/2022 11:31 PM, Eli Zaretskii wrote:
> Thanks, but I'm not too happy with adding such a function to Emacs.  I
> understand why it could make sense for Eshell, or any other package
> that uses fixed-size characters, like terminal emulators in term.el.
> But in general, it makes no sense in Emacs to ask how many lines of a
> given non-default font can fit in a window, because you cannot
> guarantee that a single font will be used in the entire window -- it
> is enough to have some of the text having the bold or italic face
> attribute, or have some non-ASCII characters that will be displayed in
> a different font, to disrupt the results.

While I don't have a strong opinion that this function should exist, I 
think the scenario where it *could* be useful is to "make layout 
decisions", as the Lisp manual says (for `window-max-chars-per-line'). 
If you were making some UI in a Lisp program that wanted things to fit 
in a window all at once, you'd likely know what face would get used (and 
it might not be the default face). Then, you could use both 
`window-max-chars-per-line' and `window-max-lines' to figure out how 
much space you have.

If that's not convincing, then let's do something more like what you 
suggest below.

> We could perhaps make window-body-width and window-body-height
> optionally pay attention to the remapping of the default face, which
> should handle the case such as this one.  Would that be acceptable for
> you?

That works fine for me. I was actually surprised that these functions 
didn't account for face remapping.

Since window-body-(width|height) are C functions, it would be a bit more 
work to implement this, but I'm sure someone familiar with writing 
C-based Lisp functions wouldn't have much trouble. I could probably 
figure out how to do it myself with a bit of digging too.

>> +  (with-selected-window (window-normalize-window window t)
>> +    (let ((window-height (window-body-height window t))
>> +	  (font-height (window-font-height window face)))
>> +      (/ window-height font-height))))
> 
> Is integer division here really TRT?  Shouldn't we round to the
> nearest integer instead of truncating?

I think integer division is right, but there's an argument either way. I 
see this function as asking the question, "How many lines can fully fit 
in this window without scrolling?" If I had a GUI terminal window open 
and it could fit 20.5 lines, I'd expect the $LINES variable in my shell 
to be 20. That way, a program that consults that variable would know 
that the 21st line is at least partly off-screen.





  reply	other threads:[~2022-06-03 20:30 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-29  3:43 bug#55696: 28.1; eshell fails to respect text-scale-increase Jeff Kowalski
2022-06-03  4:41 ` Jim Porter
2022-06-03  6:31   ` Eli Zaretskii
2022-06-03 20:30     ` Jim Porter [this message]
2022-06-04  6:20       ` Eli Zaretskii
2022-06-05  4:49         ` Jim Porter
2022-06-05  9:13           ` Eli Zaretskii
2022-06-05 18:12             ` Jim Porter
2022-06-05 19:00               ` Eli Zaretskii
2022-06-05 19:59                 ` Jim Porter
2022-06-06 12:43                   ` Eli Zaretskii
2022-06-07  3:04                     ` Jim Porter
2022-06-07 10:55                       ` Eli Zaretskii
2022-06-08  8:07                       ` martin rudalics
2022-06-08 23:20                         ` Jim Porter
2022-06-09  7:24                           ` Eli Zaretskii
2022-06-09 15:55                             ` Jim Porter
2022-06-09 16:48                               ` Eli Zaretskii
2022-06-09 22:14                                 ` Jim Porter
2022-06-10  5:52                                   ` Eli Zaretskii
2022-06-10 15:44                                     ` Jim Porter
2022-06-10 15:58                                       ` Eli Zaretskii
2022-06-10 16:44                                         ` Jim Porter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0278e759-237b-a32b-4b1f-fbdacf39c8ef@gmail.com \
    --to=jporterbugs@gmail.com \
    --cc=55696@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=jeff.kowalski@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).