From: Eli Zaretskii <eliz@gnu.org>
To: pipcet@gmail.com
Cc: 36312@debbugs.gnu.org
Subject: bug#36312: 27.0.50; (message) in display spec condition causes emacs_abort()
Date: Fri, 21 Jun 2019 11:39:31 +0300 [thread overview]
Message-ID: <83a7ebpc1o.fsf@gnu.org> (raw)
In-Reply-To: <83fto3pf25.fsf@gnu.org> (message from Eli Zaretskii on Fri, 21 Jun 2019 10:34:26 +0300)
> Date: Fri, 21 Jun 2019 10:34:26 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: 36312@debbugs.gnu.org
>
> Why not do something like that in a post-command-hook instead? The
> position of point is already up to date then, and retrieving face
> properties at point is trivial. What am I missing?
>
> There's also pre-redisplay-hook.
>
> > So far, what I'm thinking about is a hook that's run _after_ redisplay
> > to let an overlay know that redisplay just happened and the face used
> > for the text around the overlay changed.
>
> I don't understand why you think you must run after redisplay. If
> redisplay changes the faces (probably via JIT font-lock?), and you
> must have the corresponding change in your image without any delays
> (though if you use a timer, you seem to not mind a delay), then why
> not register a function with jit-lock-register, and do that from
> there? And if you indeed don't mind a short delay, then I think
> post-command-hook should be your friend.
>
> > But I'd appreciate any suggestions (the immediate application is to
> > define character-like image-based glyphs that "look like text", but
> > there might be others).
>
> You seem to be thinking about font-lock like use cases, so plugging
> yourself into jit-lock would be my first suggestion.
>
> In any case, (ab)using 'when' in display specs for running code that
> doesn't affect the value of that same display spec is to be avoided,
> IMO, as that is not what these features is for.
FTR, I wanted to draw your attention to some problematic aspects of
using 'when' in display specs as a kind of "redisplay hook".
First aspect that you need to be aware of is that when the display
spec is being evaluated, there's no 100% guarantee that the value of
point is what will eventually be displayed. In some, admittedly rare,
situations, when redisplay is finished, it turns out that point is not
in a fully visible screen line. In such cases, the display engine can
decide to move point to bring it back into the viewport. It then
performs another redisplay cycle, but that is not guaranteed to
re-evaluate your display spec, because Emacs might find a redisplay
optimization which avoids that (typically, moving point only needs to
consider point's line).
More generally, if a window is redrawn, the display engine might
decide not to redisplay the line where you have your display spec, but
instead either scroll the display (i.e. reuse the results of the
previous redisplay cycle), or even bypass that line altogether,
because it decides that this line is outside of the region affected by
the last command.
Another problematic aspect is that the display specs are evaluated for
purposes other than displaying the results. There are features in
Emacs that need to perform text layout calculations without displaying
the text whose layout they consider. One popular example is C-n/C-p,
which calls vertical-motion internally. vertical-motion then invokes
the display engine in a special mode which performs text layout
calculations and measures the text dimensions without displaying that
text, just because it needs to figure out, for example, what character
or buffer position is on display directly below or above the given
screen coordinates. The result of this is that your 'when' form will
be called in contexts other than redisplay, and if you fire timers or
other functions inside that form, you will find that your code is
invoked more than once per command, in different contexts you didn't
necessarily expect, and with point whose value may not be up to date.
To continue the same example, vertical-motion invokes the display
routine before it moves point, precisely _because_ it needs to perform
layout calculations to decide where to move point.
prev parent reply other threads:[~2019-06-21 8:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-20 16:06 bug#36312: 27.0.50; (message) in display spec condition causes emacs_abort() Pip Cet
2019-06-20 18:11 ` Eli Zaretskii
2019-06-20 19:32 ` Pip Cet
2019-06-21 7:34 ` Eli Zaretskii
2019-06-21 8:13 ` Pip Cet
2019-06-21 8:39 ` Eli Zaretskii [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83a7ebpc1o.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=36312@debbugs.gnu.org \
--cc=pipcet@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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.