From ffbe561ee5acb0b9edc5f4c995c287fb2485c315 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 15 Sep 2018 09:44:30 -0400 Subject: [PATCH] Don't call modification hooks unprepared Inhibit modification hooks when performing message coalescing because in that case, we aren't doing the necessary preparation for running modification hooks (i.e., we pass PREPARE=false for the insert_1_both and del_range_both calls). See also Bug#30823 and Bug#21824. * src/xdisp.c (message_dolog): Let-bind inhibit-modification-hooks to t around del_range_both calls. --- src/xdisp.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/xdisp.c b/src/xdisp.c index 47286e25c80..93cd54a3240 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -10417,6 +10417,13 @@ message_dolog (const char *m, ptrdiff_t nbytes, bool nlflag, bool multibyte) ptrdiff_t this_bol, this_bol_byte, prev_bol, prev_bol_byte; printmax_t dups; + /* Since we call del_range_both passing false for PREPARE, + we aren't prepared to run modification hooks (we could + end up calling modification hooks from another buffer and + only with AFTER=t, Bug#21824). */ + ptrdiff_t count = SPECPDL_INDEX (); + specbind (Qinhibit_modification_hooks, Qt); + insert_1_both ("\n", 1, 1, true, false, false); scan_newline (Z, Z_BYTE, BEG, BEG_BYTE, -2, false); @@ -10462,6 +10469,8 @@ message_dolog (const char *m, ptrdiff_t nbytes, bool nlflag, bool multibyte) -XFIXNAT (Vmessage_log_max) - 1, false); del_range_both (BEG, BEG_BYTE, PT, PT_BYTE, false); } + + unbind_to (count, Qnil); } BEGV = marker_position (oldbegv); BEGV_BYTE = marker_byte_position (oldbegv); -- 2.39.2