bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#64596: 30.0.50; On FIXME: in src/buffer.c:1481 (force-mode-line-upda


From: Ihor Radchenko
Subject: bug#64596: 30.0.50; On FIXME: in src/buffer.c:1481 (force-mode-line-update)
Date: Fri, 14 Jul 2023 11:53:02 +0000

Eli Zaretskii <eliz@gnu.org> writes:

>> AFAIU, the purpose of disabling redisplay optimizations is avoiding the
>> situation when the modification flag is unset in the buffer, but the
>> buffer was actually modified, and has to be redrawn.
>
> No, it's more subtle.  In a nutshell, it is meant to prevent redisplay
> from applying certain optimizations (search xdisp.c for the uses of
> this flag).  These optimizations are based on various assumptions,
> such as that the current glyph matrix of the window is up-to-date.
> Setting the prevent_redisplay_optimizations_p flag tells the display
> engine that those assumptions are (or might be) false.

I'm afraid that the very existence of prevent_redisplay_optimizations_p
flag is a mistake hiding bugs with redisplay optimizations logic.

Currently, redisplay_internal has a number of conditions used to
determine if one or another optimization is safe to use + assertion that
!prevent_redisplay_optimizations_p.

When some code outside xdisp.c sets this flag, it is nothing but a
statement: "I was lazy enough to update xdisp.c properly, so I just
force bypassing optimizations".

> Updating the mode line usually requires more thorough redisplay,
> especially when the only reason for that is that some Lisp called
> force-mode-line-update -- without setting that flag, the display
> engine could easily decide that the window doesn't need to be redrawn.

I have explored xdisp a bit and AFAIU, once we are in redisplay_window,
mode line will be updated as long as update_mode_line is set (at least
to UPDATE_SOME), except when current window is MINI_WINDOW_P (this code
branch is not prevented by prevent_redisplay_optimizations_p though) or
when we give up redisplaying.

Calling redisplay_window may be prevented via needs_no_redisplay, unless
we have buffer->text->redisplay, which is set in bset_update_mode_line.
[ setting buffer->text->redisplay is rather awkward way to single mode
line update though ]

redisplay_window may also be postponed for frames that are not visible
or that are obscured, but it appears to be by design and not influenced
by prevent_redisplay_optimizations_p anyway 😕

So, I see not why calling bset_update_mode_line is not sufficient to
force mode line update in all windows associated with a single buffer.

>> If my understanding is correct,
>> current_buffer->prevent_redisplay_optimizations_p = true does not belong
>> to `force-mode-line-update', but rather to `restore-buffer-modified-p'.
>
> The purpose of force-mode-line-update is to do what its name says,
> regardless of whether the buffer was modified or not, and how it was
> modified.  The idea is that Lisp programs which change something that
> they know must affect the mode line call this function to make sure
> the mode line is redrawn with up-to-date information.  By contrast,
> buffer modifications could be such that don't affect redisplay at all,
> or allow redisplay to use some shortcuts and redraw only a very small
> portion of the window.

Then, why do we need to call Fforce_mode_line_update in
set-buffer-modified-p? Wouldn't calling bset_redisplay be better?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]