emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master ffbe561: Don't call modification hooks unprepared


From: Noam Postavsky
Subject: [Emacs-diffs] master ffbe561: Don't call modification hooks unprepared
Date: Sat, 15 Sep 2018 10:09:37 -0400 (EDT)

branch: master
commit ffbe561ee5acb0b9edc5f4c995c287fb2485c315
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    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 47286e2..93cd54a 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);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]