aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/coding.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/coding.c b/src/coding.c
index 3e2a8664831..32a775f3468 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -6851,6 +6851,7 @@ decode_coding_object (coding, src_object, from, from_byte, to, to_byte,
6851 Lisp_Object attrs; 6851 Lisp_Object attrs;
6852 Lisp_Object buffer; 6852 Lisp_Object buffer;
6853 int saved_pt = -1, saved_pt_byte; 6853 int saved_pt = -1, saved_pt_byte;
6854 int need_marker_adjustment = 0;
6854 6855
6855 buffer = Fcurrent_buffer (); 6856 buffer = Fcurrent_buffer ();
6856 6857
@@ -6877,6 +6878,14 @@ decode_coding_object (coding, src_object, from, from_byte, to, to_byte,
6877 move_gap_both (from, from_byte); 6878 move_gap_both (from, from_byte);
6878 if (EQ (src_object, dst_object)) 6879 if (EQ (src_object, dst_object))
6879 { 6880 {
6881 struct Lisp_Marker *tail;
6882
6883 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next)
6884 {
6885 tail->need_adjustment
6886 = tail->charpos == (tail->insertion_type ? from : to);
6887 need_marker_adjustment |= tail->need_adjustment;
6888 }
6880 saved_pt = PT, saved_pt_byte = PT_BYTE; 6889 saved_pt = PT, saved_pt_byte = PT_BYTE;
6881 TEMP_SET_PT_BOTH (from, from_byte); 6890 TEMP_SET_PT_BOTH (from, from_byte);
6882 del_range_both (from, from_byte, to, to_byte, 1); 6891 del_range_both (from, from_byte, to, to_byte, 1);
@@ -6982,6 +6991,29 @@ decode_coding_object (coding, src_object, from, from_byte, to, to_byte,
6982 else 6991 else
6983 TEMP_SET_PT_BOTH (saved_pt + (coding->produced - bytes), 6992 TEMP_SET_PT_BOTH (saved_pt + (coding->produced - bytes),
6984 saved_pt_byte + (coding->produced - bytes)); 6993 saved_pt_byte + (coding->produced - bytes));
6994
6995 if (need_marker_adjustment)
6996 {
6997 struct Lisp_Marker *tail;
6998
6999 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next)
7000 if (tail->need_adjustment)
7001 {
7002 tail->need_adjustment = 0;
7003 if (tail->insertion_type)
7004 {
7005 tail->bytepos = from_byte;
7006 tail->charpos = from;
7007 }
7008 else
7009 {
7010 tail->bytepos = from_byte + coding->produced;
7011 tail->charpos
7012 = (NILP (current_buffer->enable_multibyte_characters)
7013 ? tail->bytepos : from + coding->produced_char);
7014 }
7015 }
7016 }
6985 } 7017 }
6986 7018
6987 unbind_to (count, coding->dst_object); 7019 unbind_to (count, coding->dst_object);
@@ -7002,6 +7034,7 @@ encode_coding_object (coding, src_object, from, from_byte, to, to_byte,
7002 Lisp_Object attrs; 7034 Lisp_Object attrs;
7003 Lisp_Object buffer; 7035 Lisp_Object buffer;
7004 int saved_pt = -1, saved_pt_byte; 7036 int saved_pt = -1, saved_pt_byte;
7037 int need_marker_adjustment = 0;
7005 int kill_src_buffer = 0; 7038 int kill_src_buffer = 0;
7006 7039
7007 buffer = Fcurrent_buffer (); 7040 buffer = Fcurrent_buffer ();
@@ -7013,6 +7046,18 @@ encode_coding_object (coding, src_object, from, from_byte, to, to_byte,
7013 7046
7014 attrs = CODING_ID_ATTRS (coding->id); 7047 attrs = CODING_ID_ATTRS (coding->id);
7015 7048
7049 if (EQ (src_object, dst_object))
7050 {
7051 struct Lisp_Marker *tail;
7052
7053 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next)
7054 {
7055 tail->need_adjustment
7056 = tail->charpos == (tail->insertion_type ? from : to);
7057 need_marker_adjustment |= tail->need_adjustment;
7058 }
7059 }
7060
7016 if (! NILP (CODING_ATTR_PRE_WRITE (attrs))) 7061 if (! NILP (CODING_ATTR_PRE_WRITE (attrs)))
7017 { 7062 {
7018 coding->src_object = code_conversion_save (1, coding->src_multibyte); 7063 coding->src_object = code_conversion_save (1, coding->src_multibyte);
@@ -7142,6 +7187,29 @@ encode_coding_object (coding, src_object, from, from_byte, to, to_byte,
7142 else 7187 else
7143 TEMP_SET_PT_BOTH (saved_pt + (coding->produced - bytes), 7188 TEMP_SET_PT_BOTH (saved_pt + (coding->produced - bytes),
7144 saved_pt_byte + (coding->produced - bytes)); 7189 saved_pt_byte + (coding->produced - bytes));
7190
7191 if (need_marker_adjustment)
7192 {
7193 struct Lisp_Marker *tail;
7194
7195 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next)
7196 if (tail->need_adjustment)
7197 {
7198 tail->need_adjustment = 0;
7199 if (tail->insertion_type)
7200 {
7201 tail->bytepos = from_byte;
7202 tail->charpos = from;
7203 }
7204 else
7205 {
7206 tail->bytepos = from_byte + coding->produced;
7207 tail->charpos
7208 = (NILP (current_buffer->enable_multibyte_characters)
7209 ? tail->bytepos : from + coding->produced_char);
7210 }
7211 }
7212 }
7145 } 7213 }
7146 7214
7147 if (kill_src_buffer) 7215 if (kill_src_buffer)