unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Carlos Pita <carlosjosepita2@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 38181@debbugs.gnu.org
Subject: bug#38181: Actual height of mode-line not taken into account
Date: Mon, 18 Oct 2021 20:35:48 -0300	[thread overview]
Message-ID: <CAEOO5TdvErqGDoW3vDEWr4f=LThtnSaDuYxTQwS1A6ZKkzx8fg@mail.gmail.com> (raw)
In-Reply-To: <831r4idw8s.fsf@gnu.org>

(Sorry if it ends up being a dup but I'm resending this because I'd
previously sent it with an attached screencast and it seems that it's
not being accepted by the bug tracker. In any case, it was the wrong
cast :P. Please let me know if there's a policy wrt screencasts,
even the right ones. I think it could be useful in this case but it's
not that important.)

Hi,

Here is one more example that tries to capture the essence of another
popup dialog in org that is giving me headaches. It's fixed by
applying Martin's patch, it's not "fixed" with the
redisplay-before-fit workaround (although the redisplay does make a
difference as shown below) and it's "fixed" with the
redisplay-after-creation workaround.
1) I run emacs -q and execute this simple code that opens a window
with 30 numbers, each in its own line:

(progn
  (switch-to-buffer-other-window "popup")
  (erase-buffer)
  (insert (mapconcat #'number-to-string (number-sequence 1 30) "\n"))
  (fit-window-to-buffer))

The window properly fits the numbers, which are all visible  (please
ensure your screen and frame is large enough). Now I close the window
and make the modeline bigger as in Jonas' example:

(setq-default
 mode-line-format
 (cons (propertize " " 'display
                   (create-image "/* XPM */ static char * image[] = {
\"3 60 1 1\",
\"0 c #00aaff\",
\"000\",\n\"000\",\n\"000\",\n\"000\",\n\"000\",
\"000\",\n\"000\",\n\"000\",\n\"000\",\n\"000\",
\"000\",\n\"000\",\n\"000\",\n\"000\",\n\"000\",
\"000\",\n\"000\",\n\"000\",\n\"000\",\n\"000\",
\"000\",\n\"000\",\n\"000\",\n\"000\",\n\"000\",
\"000\",\n\"000\",\n\"000\",\n\"000\",\n\"000\",
\"000\",\n\"000\",\n\"000\",\n\"000\",\n\"000\",
\"000\",\n\"000\",\n\"000\",\n\"000\",\n\"000\",
\"000\",\n\"000\",\n\"000\",\n\"000\",\n\"000\",
\"000\",\n\"000\",\n\"000\",\n\"000\",\n\"000\",
\"000\",\n\"000\",\n\"000\",\n\"000\",\n\"000\",
\"000\",\n\"000\",\n\"000\",\n\"000\",\n\"000\"
};" 'xpm t :ascent 'center))
       mode-line-format))

2) If I run the code above one more time, that is:

(progn
  (switch-to-buffer-other-window "popup")
  (erase-buffer)
  (insert (mapconcat #'number-to-string (number-sequence 1 30) "\n"))
  (fit-window-to-buffer))

The numbers are only partially visible, the window looks as if I had
scrolled the buffer down to the bottom. Scrolling up it's easy to see
that not all of the numbers fit the window. I guess this is expected
because of the miscalculations regarding the modeline height.

3) Now I add a redisplay before the fit:

(progn
  (switch-to-buffer-other-window "popup")
  (erase-buffer)
  (insert (mapconcat #'number-to-string (number-sequence 1 30) "\n"))
  (redisplay t)
  (fit-window-to-buffer))

Again, only about half of the numbers are visible and the window looks
as if its buffer has been scrolled down. But now by scrolling up I can
check that all the numbers fit the window. So the height of the window
is right but there is that unnecessary scrolling down of the contents.

4) Now I repeat with the forced redisplay even earlier:

(progn
  (switch-to-buffer-other-window "popup")
  (redisplay t)
  (erase-buffer)
  (insert (mapconcat #'number-to-string (number-sequence 1 30) "\n"))
  (fit-window-to-buffer))

This seems to work around the issue.

I believe that in 3 there is some miscalculation during the insertion
of text into the buffer that forces a scroll, but I'm having a hard
time trying to explain that. Anyway, it's another case the
redisplay-before-fit advice can't cope with.

Best regards,
Carlos





  reply	other threads:[~2021-10-18 23:35 UTC|newest]

Thread overview: 97+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-12 16:52 bug#38181: Actual height of mode-line not taken into account Jonas Bernoulli
2019-11-13  8:03 ` martin rudalics
2019-11-15 13:50   ` Eli Zaretskii
2019-11-15 13:48 ` Eli Zaretskii
2019-11-15 14:24   ` Jonas Bernoulli
2019-11-15 15:11     ` Eli Zaretskii
2019-11-15 23:51       ` Jonas Bernoulli
2019-11-16  8:38         ` Eli Zaretskii
2019-11-16 14:54           ` Jonas Bernoulli
2019-11-16 15:59             ` Eli Zaretskii
2019-11-17 16:17               ` Jonas Bernoulli
2019-11-15 19:38   ` Eli Zaretskii
2019-11-16  8:20     ` martin rudalics
2019-11-16  8:35       ` Eli Zaretskii
2019-11-16  8:57         ` martin rudalics
2019-11-16 10:57           ` Eli Zaretskii
2019-11-16 19:28             ` martin rudalics
2019-11-16 19:44               ` Eli Zaretskii
2019-11-17  8:55                 ` martin rudalics
2019-11-17 17:26                   ` Eli Zaretskii
2019-11-17 18:15                     ` martin rudalics
2019-11-17 18:35                       ` Eli Zaretskii
2019-11-18  9:44                         ` martin rudalics
2019-11-18 15:42                           ` Eli Zaretskii
2019-11-18 18:45                             ` martin rudalics
2020-05-02 18:06                     ` martin rudalics
2020-05-04 13:46                       ` Eli Zaretskii
2020-05-04 15:04                         ` martin rudalics
2020-05-04 17:05                           ` martin rudalics
2020-05-05  8:32                             ` martin rudalics
2020-05-05 14:58                               ` Eli Zaretskii
2020-05-05 16:57                                 ` martin rudalics
2020-05-05 17:11                                   ` Eli Zaretskii
2020-05-06  6:50                                     ` martin rudalics
2020-05-06  9:27                                       ` Eli Zaretskii
2020-05-06  9:44                                         ` martin rudalics
2020-05-06 14:16                                         ` Eli Zaretskii
2020-05-07  8:34                                           ` martin rudalics
2020-05-07 12:41                                             ` Eli Zaretskii
2020-05-06 14:44                                   ` Eli Zaretskii
2020-05-07  8:34                                     ` martin rudalics
2020-05-10 14:33                                       ` Eli Zaretskii
2020-05-11  8:30                                         ` martin rudalics
2020-05-15 15:00                                           ` Eli Zaretskii
2020-05-16  8:44                                             ` martin rudalics
2020-05-16 10:46                                               ` Eli Zaretskii
2019-11-16 15:27           ` Jonas Bernoulli
2019-11-16 16:19             ` Eli Zaretskii
2019-11-16 19:30               ` martin rudalics
2019-11-16 19:45                 ` Eli Zaretskii
2019-11-17  9:01                   ` martin rudalics
2019-11-17 17:22                     ` Eli Zaretskii
2019-11-17 18:16                       ` martin rudalics
2019-11-17 18:39                         ` Eli Zaretskii
2019-11-18  9:45                           ` martin rudalics
2019-11-18 15:46                             ` Eli Zaretskii
2019-11-18 18:46                               ` martin rudalics
2019-11-17 16:21               ` Jonas Bernoulli
2019-11-16 19:30             ` martin rudalics
2021-10-15  5:13 ` Carlos Pita
2021-10-15  7:05   ` martin rudalics
2021-10-15  7:26     ` Carlos Pita
2021-10-15  7:54       ` Eli Zaretskii
2021-10-15  8:18         ` Carlos Pita
2021-10-15  8:35       ` martin rudalics
2021-10-15  8:45         ` Carlos Pita
     [not found]         ` <CAEOO5TdaV=tdj23afEcqJGZf4JM3VVQ6TFt4F3q6k6d=f4_36w@mail.gmail.com>
     [not found]           ` <776a35b7-1920-2987-88ae-6dcab958a8e4@gmx.at>
2021-10-15  9:07             ` Carlos Pita
2021-10-16  7:55               ` martin rudalics
2021-10-16 11:23                 ` Carlos Pita
2021-10-16 16:48                   ` martin rudalics
2021-10-16 18:00                     ` Carlos Pita
2021-10-16 19:41                       ` martin rudalics
2021-10-16 19:57                         ` Carlos Pita
2021-10-16 21:27                           ` Carlos Pita
2021-10-17  6:06                             ` Eli Zaretskii
2021-10-17  6:45                               ` Carlos Pita
2021-10-17  8:34                               ` martin rudalics
2021-10-17  8:34                             ` martin rudalics
2021-10-17  8:33                           ` martin rudalics
2021-10-18  9:34                             ` martin rudalics
2021-10-18 15:56                               ` Carlos Pita
2021-10-18 17:44                                 ` martin rudalics
2021-10-18 18:27                                   ` Eli Zaretskii
2021-10-18 23:35                                     ` Carlos Pita [this message]
2021-10-19  0:11                                       ` Carlos Pita
2021-10-19  9:25                                     ` martin rudalics
2021-10-19 12:22                                       ` Eli Zaretskii
2021-10-22  9:04                                       ` martin rudalics
2021-10-22 14:55                                         ` Carlos Pita
2021-11-07 18:48                                           ` Carlos Pita
     [not found]                                     ` <CAEOO5TemeSrLkudEBRbMaLrCXq7A0y5uv+SdcfZwMo77onMMoA@mail.gmail.com>
2021-10-19 10:09                                       ` martin rudalics
2021-10-15  7:51   ` Eli Zaretskii
2021-10-15  8:00     ` Carlos Pita
2021-10-15 10:40       ` Eli Zaretskii
2021-10-15 18:33         ` Carlos Pita
2021-10-15 19:08           ` Eli Zaretskii
2021-10-15 20:09             ` Carlos Pita

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='CAEOO5TdvErqGDoW3vDEWr4f=LThtnSaDuYxTQwS1A6ZKkzx8fg@mail.gmail.com' \
    --to=carlosjosepita2@gmail.com \
    --cc=38181@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /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).