]> git.eshelyaron.com Git - emacs.git/commitdiff
(decode_coding_object): Adjuste marker positions after
authorKenichi Handa <handa@m17n.org>
Fri, 18 Jan 2008 07:08:52 +0000 (07:08 +0000)
committerKenichi Handa <handa@m17n.org>
Fri, 18 Jan 2008 07:08:52 +0000 (07:08 +0000)
conversion.
(encode_coding_object): Likewise.

src/coding.c

index 3e2a8664831946b1049da179335f937c2b5f40f0..32a775f34684236313da69d3bc65c37073e046f9 100644 (file)
@@ -6851,6 +6851,7 @@ decode_coding_object (coding, src_object, from, from_byte, to, to_byte,
   Lisp_Object attrs;
   Lisp_Object buffer;
   int saved_pt = -1, saved_pt_byte;
+  int need_marker_adjustment = 0;
 
   buffer = Fcurrent_buffer ();
 
@@ -6877,6 +6878,14 @@ decode_coding_object (coding, src_object, from, from_byte, to, to_byte,
        move_gap_both (from, from_byte);
       if (EQ (src_object, dst_object))
        {
+         struct Lisp_Marker *tail;
+
+         for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next)
+           {
+             tail->need_adjustment
+               = tail->charpos == (tail->insertion_type ? from : to);
+             need_marker_adjustment |= tail->need_adjustment;
+           }
          saved_pt = PT, saved_pt_byte = PT_BYTE;
          TEMP_SET_PT_BOTH (from, from_byte);
          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,
       else
        TEMP_SET_PT_BOTH (saved_pt + (coding->produced - bytes),
                          saved_pt_byte + (coding->produced - bytes));
+
+      if (need_marker_adjustment)
+       {
+         struct Lisp_Marker *tail;
+
+         for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next)
+           if (tail->need_adjustment)
+             {
+               tail->need_adjustment = 0;
+               if (tail->insertion_type)
+                 {
+                   tail->bytepos = from_byte;
+                   tail->charpos = from;
+                 }
+               else
+                 {
+                   tail->bytepos = from_byte + coding->produced;
+                   tail->charpos
+                     = (NILP (current_buffer->enable_multibyte_characters)
+                        ? tail->bytepos : from + coding->produced_char);
+                 }
+             }
+       }
     }
 
   unbind_to (count, coding->dst_object);
@@ -7002,6 +7034,7 @@ encode_coding_object (coding, src_object, from, from_byte, to, to_byte,
   Lisp_Object attrs;
   Lisp_Object buffer;
   int saved_pt = -1, saved_pt_byte;
+  int need_marker_adjustment = 0;
   int kill_src_buffer = 0;
 
   buffer = Fcurrent_buffer ();
@@ -7013,6 +7046,18 @@ encode_coding_object (coding, src_object, from, from_byte, to, to_byte,
 
   attrs = CODING_ID_ATTRS (coding->id);
 
+  if (EQ (src_object, dst_object))
+    {
+      struct Lisp_Marker *tail;
+
+      for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next)
+       {
+         tail->need_adjustment
+           = tail->charpos == (tail->insertion_type ? from : to);
+         need_marker_adjustment |= tail->need_adjustment;
+       }
+    }
+
   if (! NILP (CODING_ATTR_PRE_WRITE (attrs)))
     {
       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,
       else
        TEMP_SET_PT_BOTH (saved_pt + (coding->produced - bytes),
                          saved_pt_byte + (coding->produced - bytes));
+
+      if (need_marker_adjustment)
+       {
+         struct Lisp_Marker *tail;
+
+         for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next)
+           if (tail->need_adjustment)
+             {
+               tail->need_adjustment = 0;
+               if (tail->insertion_type)
+                 {
+                   tail->bytepos = from_byte;
+                   tail->charpos = from;
+                 }
+               else
+                 {
+                   tail->bytepos = from_byte + coding->produced;
+                   tail->charpos
+                     = (NILP (current_buffer->enable_multibyte_characters)
+                        ? tail->bytepos : from + coding->produced_char);
+                 }
+             }
+       }
     }
 
   if (kill_src_buffer)