[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-30 ef5466c2675: Avoid aborts when buffer is modified during its re
From: |
Eli Zaretskii |
Subject: |
emacs-30 ef5466c2675: Avoid aborts when buffer is modified during its redisplay |
Date: |
Thu, 1 Aug 2024 07:02:29 -0400 (EDT) |
branch: emacs-30
commit ef5466c267542970f28548c820783f3257c1b0cf
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>
Avoid aborts when buffer is modified during its redisplay
* src/xdisp.c (redisplay_window): Restore point from saved byte
position only if the buffer was not changed meanwhile.
(Bug#72165)
---
src/xdisp.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/xdisp.c b/src/xdisp.c
index baf181cba1c..1dadb372911 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -19957,6 +19957,7 @@ redisplay_window (Lisp_Object window, bool
just_this_one_p)
int frame_line_height, margin;
bool use_desired_matrix;
void *itdata = NULL;
+ modiff_count lchars_modiff = CHARS_MODIFF, ochars_modiff = lchars_modiff;
SET_TEXT_POS (lpoint, PT, PT_BYTE);
opoint = lpoint;
@@ -20050,6 +20051,7 @@ redisplay_window (Lisp_Object window, bool
just_this_one_p)
end_unchanged = END_UNCHANGED;
SET_TEXT_POS (opoint, PT, PT_BYTE);
+ ochars_modiff = CHARS_MODIFF;
specbind (Qinhibit_point_motion_hooks, Qt);
@@ -21082,14 +21084,28 @@ redisplay_window (Lisp_Object window, bool
just_this_one_p)
TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE);
else if (CHARPOS (opoint) > ZV)
TEMP_SET_PT_BOTH (Z, Z_BYTE);
- else
+ else if (ochars_modiff == CHARS_MODIFF)
TEMP_SET_PT_BOTH (CHARPOS (opoint), BYTEPOS (opoint));
-
+ else
+ {
+ /* If the buffer was modified while we were redisplaying it, we
+ cannot trust the correspondence between character and byte
+ positions. This can happen, for example, if we are
+ redisplaying *Messages* and some Lisp, perhaps invoked by
+ display_mode_lines, signals an error which caused something
+ added/deleted to/from the buffer text. */
+ TEMP_SET_PT_BOTH (CHARPOS (opoint), CHAR_TO_BYTE (CHARPOS (opoint)));
+ }
set_buffer_internal_1 (old);
/* Avoid an abort in TEMP_SET_PT_BOTH if the buffer has become
shorter. This can be caused by log truncation in *Messages*. */
if (CHARPOS (lpoint) <= ZV)
- TEMP_SET_PT_BOTH (CHARPOS (lpoint), BYTEPOS (lpoint));
+ {
+ if (lchars_modiff == CHARS_MODIFF)
+ TEMP_SET_PT_BOTH (CHARPOS (lpoint), BYTEPOS (lpoint));
+ else
+ TEMP_SET_PT_BOTH (CHARPOS (lpoint), CHAR_TO_BYTE (CHARPOS (lpoint)));
+ }
unbind_to (count, Qnil);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-30 ef5466c2675: Avoid aborts when buffer is modified during its redisplay,
Eli Zaretskii <=