unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: larsi@gnus.org, esabof@gmail.com, 14582@debbugs.gnu.org
Subject: bug#14582: 24.3.50.1; Strange overlay behavior, when window-start is inside an overlay.
Date: Tue, 01 Feb 2022 20:18:06 +0200	[thread overview]
Message-ID: <83pmo678o1.fsf@gnu.org> (raw)
In-Reply-To: <87h79j2srb.fsf@web.de> (message from Michael Heerdegen on Tue, 01 Feb 2022 04:03:04 +0100)

> From: Michael Heerdegen <michael_heerdegen@web.de>
> Cc: larsi@gnus.org,  esabof@gmail.com,  14582@debbugs.gnu.org
> Date: Tue, 01 Feb 2022 04:03:04 +0100
> 
> I think I mean the same.  I guess the original recipe only explicitly
> sets window-start to ensure the recipe reliably works regardless of the
> number of display lines and such things.
> 
> Anyway, this here works for me:
> 
> Open emacs -Q (I'm in X), and evaluate (with M-:) the follow piece of code:
> 
> #+begin_src emacs-lisp
> (progn
>   (dotimes (_ 33) (insert "\
> \(defun foo ()
>   1
>   2)\n"))
>   (goto-char (point-max))
>   (sit-for 1)
>   (scroll-down)
>   (sit-for 1)
>   (hs-minor-mode)
>   (hs-hide-all))
> #+end_src
> 
> That gives me a display of *scratch* where the first visible window line
> displays "...)" instead of expected "(defun xyz nil...)".

Yes, it's basically the same issue.

So please tell me: why do you expect Emacs to move the window-start so
that the window displays starting at "(defun ...)" in the above case?
What would be the trigger for making that change in the window-start
position?

It's a good-faith question.  The display engine doesn't know anything
about the semantics and the intended effect of hiding the bodies of
the functions by putting the invisible property there; in fact, the
display engine doesn't even know what a function's body is, nor where
it begins and ends.  The original window-start position was inside a
function's body, and the call to hs-hide-all causes that position to
be displayed as the ellipsis, that's all.  There's nothing here to
cause the display engine to move window-start.  So it doesn't, because
it, by design, tries not to move the window-start fixed as much as
possible.

Perhaps your mental model of redisplay is that it determines the
window-start position _after_ it applies the various text properties
and overlays, which affect what will be visible on display.  In which
case it would have noticed that after hiding the function bodies the
visual line will start at "(defun ...", and would therefore start the
window's display there.  But that's not how redisplay works: it in
fact first determines where to put window-start, and only after that
redisplays the window using that window-start position.  And if that
causes the window-start position to be covered by some display or
invisible property or some overlay, it's all fine from the POV of the
display engine -- precisely _because_ it isn't any of its business to
understand what those properties and overlays mean and what effect
they want to produce.

hs-minor-mode _does_ know what effect it wants to produce, so it's
hs-minor-mode that needs to adjust window-start if it happens to wind
up in the part of text that is about to be hidden on display.





  reply	other threads:[~2022-02-01 18:18 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-09  9:13 bug#14582: 24.3.50.1; Strange overlay behavior, when window-start is inside an overlay E Sabof
2013-06-09 17:06 ` Eli Zaretskii
2013-06-09 17:37   ` E Sabof
2013-06-09 17:52     ` Eli Zaretskii
2013-06-09 18:16       ` E Sabof
2013-06-09 18:25         ` Eli Zaretskii
2013-06-09 18:40           ` E Sabof
2013-06-09 18:49             ` E Sabof
2022-01-30 21:37             ` Lars Ingebrigtsen
2022-01-31  0:36               ` Michael Heerdegen
2022-01-31 14:57                 ` Eli Zaretskii
2022-01-31 18:42                   ` Michael Heerdegen
2022-01-31 19:08                     ` Eli Zaretskii
2022-02-01  3:03                       ` Michael Heerdegen
2022-02-01 18:18                         ` Eli Zaretskii [this message]
2022-02-02  1:12                           ` Michael Heerdegen
2022-02-02  3:34                             ` Eli Zaretskii
2022-02-02  4:02                               ` Michael Heerdegen
2022-02-02 12:31                                 ` Eli Zaretskii
2022-02-03 17:40                                   ` Eli Zaretskii
2022-02-04  1:37                                     ` Michael Heerdegen
2022-02-04 13:56                                       ` Eli Zaretskii
2022-02-06  2:54                                         ` Michael Heerdegen
2022-02-06 10:28                                           ` Eli Zaretskii
2022-02-08  0:29                                             ` Michael Heerdegen
2022-02-08  3:34                                               ` Eli Zaretskii
2022-02-08  4:05                                                 ` Michael Heerdegen
2022-02-08 12:23                                                   ` Eli Zaretskii
2022-02-09  0:20                                                     ` Michael Heerdegen
2022-02-09  3:53                                                     ` Michael Heerdegen
2022-02-09 13:47                                                       ` Eli Zaretskii
2022-02-10  1:07                                                         ` Michael Heerdegen
2022-02-10  6:15                                                           ` Eli Zaretskii
2022-02-11  4:42                                                             ` Michael Heerdegen
2022-02-11  8:46                                                               ` Eli Zaretskii
2022-02-12  0:25                                                                 ` Michael Heerdegen
2022-02-12  7:28                                                                   ` Eli Zaretskii
2022-02-12 22:53                                                                     ` Michael Heerdegen
2022-02-13 11:43                                                                       ` Eli Zaretskii
2022-02-27  3:54                                                                         ` Michael Heerdegen
2022-02-27  8:08                                                                           ` Eli Zaretskii
2022-02-27 23:19                                                                             ` Michael Heerdegen
2022-02-28 13:10                                                                               ` Eli Zaretskii
2022-01-31 15:30                 ` Lars Ingebrigtsen

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=83pmo678o1.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=14582@debbugs.gnu.org \
    --cc=esabof@gmail.com \
    --cc=larsi@gnus.org \
    --cc=michael_heerdegen@web.de \
    /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).