1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-28 07:45:00 +00:00

Merge from savannah/emacs-30

ef5466c267 Avoid aborts when buffer is modified during its redisplay
cb421286d2 Fix c++-ts-mode indentation for templace (bug#72263)
This commit is contained in:
Po Lu 2024-08-03 16:55:35 +08:00
commit 4915131630
3 changed files with 49 additions and 4 deletions

View File

@ -466,7 +466,8 @@ MODE is either `c' or `cpp'."
,@(when (eq mode 'cpp)
'(((node-is "access_specifier") parent-bol 0)
;; Indent the body of namespace definitions.
((parent-is "declaration_list") parent-bol c-ts-mode-indent-offset)))
((parent-is "declaration_list") parent-bol c-ts-mode-indent-offset)
((parent-is "template_declaration") parent-bol 0)))
;; int[5] a = { 0, 0, 0, 0 };

View File

@ -20007,6 +20007,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;
@ -20100,6 +20101,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);
@ -21132,14 +21134,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);
}

View File

@ -458,6 +458,34 @@ namespace test {
}
=-=-=
Name: Namespace and template (bug#72263)
=-=
namespace A {
T myfunction1(const char *fname)
{
}
template <class T>
T myfunction2(const char *fname)
{
}
}
=-=
namespace A {
T myfunction1(const char *fname)
{
}
template <class T>
T myfunction2(const char *fname)
{
}
}
=-=-=
Code:
(lambda ()
(c-ts-mode)