From: martin rudalics <rudalics@gmx.at>
To: Alan Mackenzie <acm@muc.de>
Cc: 55412@debbugs.gnu.org, tanzer@swing.co.at, Eli Zaretskii <eliz@gnu.org>
Subject: bug#55412: 28.1; In Emacs 28.1, using ':eval' in 'frame-title-format' doesn't work properly
Date: Sat, 21 May 2022 10:32:51 +0200 [thread overview]
Message-ID: <5b197424-4849-9771-ff1d-41b7a8295ba2@gmx.at> (raw)
In-Reply-To: <Yod8mfQv2TGNmmJp@ACM>
> with_window_selected is not re-entrant, since it uses a static data
> structure. Is this deliberate, or just a case of not yet making it
> re-entrant?
You mean Vwith_window_selected_vector. It's deliberate, just
transferred here from 'format_mode_line_unwind_data' which did the same.
Apparently the overhead for allocating a new vector during redisplay was
deemed as too expensive for making this re-entrant.
> I get nervous when I see "selected_frame = ...;" or "selected_window =
> ....;" outside of do_switch_frame or the corresponding window function,
> since it means selected_{frame,window} have been set without regard to
> all the other things which must be kept in synch with them. At the
> moment, all these "wild" settings of selected_frame are in xdisp.c,
> which I suppose has special reasons for them.
What concerns me is that xdisp.c sets selected_window and selected_frame
in the first place (also due to my attempts to fix Bug#39977). My patch
removes them all. This part of the redisplay code has been mended over
and over again in the past years, adding all those "special reasons" you
mention.
> with_window_selected would add another "wild" setting of selected_frame,
> this one outside of xdisp.c (in window.c) and I ask whether or not this
> is a good thing.
The canonical function to set selected_window is the static
select_window_1 and that's in window.c (with_window_selected sets
selected_window too but that's only a minor optimization).
> I think the root of the problem your patch is trying to solve is that
> the same C code is used for implementing C-x 5 o and lower level,
> temporary, frame switches. If this is the case, a good way of
> proceeding would be to refactor do_switch_frame into a function
> appropriate for lower level C calls, and the remainder for C-x 5 o. For
> example, the call to move_minibuffers_onto_frame is clearly needed for
> C-x 5 o, but is a complicated nuisance for lower level C. With such a
> new extracted C function, we could replace the "selected_frame = ...;"
> in xdisp.c by calls to this function. Maybe.
The redisplay code has to temporarily select a window also when there's
only one frame around in which case do_switch_frame wouldn't enter the
picture at all. with_window_selected handles both cases.
> I don't think redisplay should be calling Fselect_window or
> do_switch_frame at all. Instead we should call (not yet existing) lower
> level functions.
That's what with_window_selected and its unwind form have been designed
for. Basically, any such code has to guarantee invariants like:
- The selected frame's selected window is the selected window.
- Code run within with_window_selected can rely on the fact that the
selected window's buffer is current.
Moreover, the code has to guarantee that selecting a window correctly
sets up point from the window's point and stores the old point in the
previously selected window#s point. And it obviously has to guarantee
that the involved buffers, windows and frames are alive when switching
to and back from them - things redisplay had always problems with
(confer Bug#47244). Not reliably doing all these things in one place
easily produces bugs that show up only in sessions that run for a long
time and are consequently very difficult to debug.
One major advantage of with_window_selected is that then one can debug
functions like 'select-window', 'select-frame' or 'redirect-frame-focus'
without being continuously hassled by redisplay which here accounts for
nine out of ten calls of these functions at least and eventually caused
me to abandon a number of fixes for say Bug#32777, Bug#39977, Bug#24500
and Bug#24803.
martin
next prev parent reply other threads:[~2022-05-21 8:32 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-14 15:45 bug#55412: 28.1; In Emacs 28.1, using ':eval' in 'frame-title-format' doesn't work properly Christian Tanzer
2022-05-14 16:58 ` Eli Zaretskii
2022-05-14 17:07 ` Eli Zaretskii
2022-05-15 9:48 ` Alan Mackenzie
2022-05-15 10:16 ` Eli Zaretskii
2022-05-16 20:52 ` Alan Mackenzie
2022-05-17 13:25 ` Eli Zaretskii
2022-05-18 7:19 ` martin rudalics
2022-05-18 11:35 ` Eli Zaretskii
2022-05-18 15:01 ` martin rudalics
2022-05-18 15:12 ` Alan Mackenzie
2022-05-18 15:49 ` Alan Mackenzie
2022-05-18 16:03 ` Eli Zaretskii
2022-05-18 16:38 ` Alan Mackenzie
2022-05-18 16:51 ` Eli Zaretskii
2022-05-20 8:23 ` martin rudalics
2022-05-20 10:58 ` Eli Zaretskii
2022-05-21 8:32 ` martin rudalics
2022-05-21 8:35 ` Eli Zaretskii
2022-05-20 11:33 ` Alan Mackenzie
2022-05-20 12:10 ` Eli Zaretskii
2022-05-21 8:32 ` martin rudalics [this message]
2022-05-21 8:59 ` Eli Zaretskii
2022-05-19 7:18 ` martin rudalics
2022-05-20 20:39 ` Alan Mackenzie
2022-05-21 11:25 ` tanzer--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-05-21 12:35 ` Eli Zaretskii
2022-05-22 17:34 ` Alan Mackenzie
2022-05-15 9:28 ` martin rudalics
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=5b197424-4849-9771-ff1d-41b7a8295ba2@gmx.at \
--to=rudalics@gmx.at \
--cc=55412@debbugs.gnu.org \
--cc=acm@muc.de \
--cc=eliz@gnu.org \
--cc=tanzer@swing.co.at \
/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.