From 2b80340bf3585f976d88da94ee9d40eb03230c6b Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 19 Sep 2019 17:10:00 +0300 Subject: [PATCH] Fix calls to insert-*-hooks when JIT font lock is active * src/insdel.c (signal_after_change): Save and restore interval_insert_behind_hooks and interval_insert_in_front_hooks across calls to various other hooks, to prevent their clobbering by those other hooks. (Bug#37455) --- src/buffer.h | 6 ++++++ src/insdel.c | 11 ++++++++++- src/textprop.c | 5 ++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/buffer.h b/src/buffer.h index 82d9350bfc2..280d4e9098e 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -1139,6 +1139,12 @@ extern struct buffer buffer_local_flags; that don't have such names. */ extern struct buffer buffer_local_symbols; + +/* verify_interval_modification saves insertion hooks here + to be run later by report_interval_modification. */ +extern Lisp_Object interval_insert_behind_hooks; +extern Lisp_Object interval_insert_in_front_hooks; + extern void delete_all_overlays (struct buffer *); extern void reset_buffer (struct buffer *); diff --git a/src/insdel.c b/src/insdel.c index 1da8d551c73..093b841d6d6 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -2201,7 +2201,7 @@ signal_after_change (ptrdiff_t charpos, ptrdiff_t lendel, ptrdiff_t lenins) { ptrdiff_t count = SPECPDL_INDEX (); struct rvoe_arg rvoe_arg; - Lisp_Object tmp; + Lisp_Object tmp, save_insert_behind_hooks, save_insert_in_from_hooks; if (inhibit_modification_hooks) return; @@ -2237,6 +2237,12 @@ signal_after_change (ptrdiff_t charpos, ptrdiff_t lendel, ptrdiff_t lenins) return; } + /* Save and restore the insert-*-hooks, because other hooks like + after-change-functions, called below, could clobber them if they + manipulate text properties. */ + save_insert_behind_hooks = interval_insert_behind_hooks; + save_insert_in_from_hooks = interval_insert_in_front_hooks; + if (!NILP (combine_after_change_list)) Fcombine_after_change_execute (); @@ -2259,6 +2265,9 @@ signal_after_change (ptrdiff_t charpos, ptrdiff_t lendel, ptrdiff_t lenins) rvoe_arg.errorp = 0; } + interval_insert_behind_hooks = save_insert_behind_hooks; + interval_insert_in_front_hooks = save_insert_in_from_hooks; + if (buffer_has_overlays ()) report_overlay_modification (make_fixnum (charpos), make_fixnum (charpos + lenins), diff --git a/src/textprop.c b/src/textprop.c index 44c333256a6..d36b9e14a69 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -58,9 +58,8 @@ enum property_set_type /* verify_interval_modification saves insertion hooks here to be run later by report_interval_modification. */ -static Lisp_Object interval_insert_behind_hooks; -static Lisp_Object interval_insert_in_front_hooks; - +Lisp_Object interval_insert_behind_hooks; +Lisp_Object interval_insert_in_front_hooks; /* Signal a `text-read-only' error. This function makes it easier to capture that error in GDB by putting a breakpoint on it. */ -- 2.39.5