From c822e562aaa51af2fc6ffc7708124fec6bb333e4 Mon Sep 17 00:00:00 2001 From: Pip Cet Date: Sat, 15 Jun 2019 15:12:14 +0000 Subject: [PATCH] Update current buffer when changing text properties. * src/textprop.c (add_text_properties_1, set_text_properties) (set_text_properties_1, Fremove_text_properties): --- src/textprop.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/textprop.c b/src/textprop.c index ae42c44185..46de372b61 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -1141,6 +1141,15 @@ DEFUN ("previous-single-property-change", Fprevious_single_property_change, add_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object, enum property_set_type set_type) { + if (BUFFERP (object) && XBUFFER (object) != current_buffer) + { + ptrdiff_t count = SPECPDL_INDEX (); + record_unwind_current_buffer (); + set_buffer_internal (XBUFFER (object)); + return unbind_to (count, add_text_properties_1 (start, end, properties, + object, set_type)); + } + INTERVAL i, unchanged; ptrdiff_t s, len; bool modified = false; @@ -1342,6 +1351,15 @@ face(s) are retained. This is done by setting the `face' property to set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object, Lisp_Object coherent_change_p) { + if (BUFFERP (object) && XBUFFER (object) != current_buffer) + { + ptrdiff_t count = SPECPDL_INDEX (); + record_unwind_current_buffer (); + set_buffer_internal (XBUFFER (object)); + return unbind_to (count, set_text_properties (start, end, properties, + object, coherent_change_p)); + } + INTERVAL i; bool first_time = true; @@ -1412,6 +1430,17 @@ set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties, set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object, INTERVAL i) { + if (BUFFERP (object) && XBUFFER (object) != current_buffer) + { + ptrdiff_t count = SPECPDL_INDEX (); + record_unwind_current_buffer (); + set_buffer_internal (XBUFFER (object)); + + set_text_properties_1 (start, end, properties, object, i); + unbind_to (count, Qnil); + return; + } + INTERVAL prev_changed = NULL; ptrdiff_t s = XFIXNUM (start); ptrdiff_t len = XFIXNUM (end) - s; @@ -1494,6 +1523,15 @@ DEFUN ("remove-text-properties", Fremove_text_properties, Use `set-text-properties' if you want to remove all text properties. */) (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object) { + if (BUFFERP (object) && XBUFFER (object) != current_buffer) + { + ptrdiff_t count = SPECPDL_INDEX (); + record_unwind_current_buffer (); + set_buffer_internal (XBUFFER (object)); + return unbind_to (count, Fremove_text_properties (start, end, properties, + object)); + } + INTERVAL i, unchanged; ptrdiff_t s, len; bool modified = false; @@ -1606,6 +1644,16 @@ DEFUN ("remove-list-of-text-properties", Fremove_list_of_text_properties, Return t if any property was actually removed, nil otherwise. */) (Lisp_Object start, Lisp_Object end, Lisp_Object list_of_properties, Lisp_Object object) { + if (BUFFERP (object) && XBUFFER (object) != current_buffer) + { + ptrdiff_t count = SPECPDL_INDEX (); + record_unwind_current_buffer (); + set_buffer_internal (XBUFFER (object)); + return unbind_to (count, Fremove_list_of_text_properties (start, end, + list_of_properties, + object)); + } + INTERVAL i, unchanged; ptrdiff_t s, len; bool modified = false; -- 2.20.1