emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/src/fileio.c,v


From: Andreas Schwab
Subject: [Emacs-diffs] Changes to emacs/src/fileio.c,v
Date: Thu, 24 Jul 2008 13:00:22 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Andreas Schwab <schwab> 08/07/24 13:00:21

Index: fileio.c
===================================================================
RCS file: /sources/emacs/emacs/src/fileio.c,v
retrieving revision 1.625
retrieving revision 1.626
diff -u -b -r1.625 -r1.626
--- fileio.c    10 Jul 2008 15:26:13 -0000      1.625
+++ fileio.c    24 Jul 2008 13:00:20 -0000      1.626
@@ -4670,11 +4670,12 @@
        }
     }
 
-  /* Decode file format */
+  /* Decode file format.  */
   if (inserted > 0)
     {
       /* Don't run point motion or modification hooks when decoding. */
       int count = SPECPDL_INDEX ();
+      int old_inserted = inserted;
       specbind (Qinhibit_point_motion_hooks, Qt);
       specbind (Qinhibit_modification_hooks, Qt);
 
@@ -4693,13 +4694,13 @@
        {
          /* If REPLACE is non-nil and we succeeded in not replacing the
          beginning or end of the buffer text with the file's contents,
-         call format-decode with `point' positioned at the beginning of
-         the buffer and `inserted' equalling the number of characters
-         in the buffer.  Otherwise, format-decode might fail to
-         correctly analyze the beginning or end of the buffer.  Hence
-         we temporarily save `point' and `inserted' here and restore
-         `point' iff format-decode did not insert or delete any text.
-         Otherwise we leave `point' at point-min. */
+            call format-decode with `point' positioned at the beginning
+            of the buffer and `inserted' equalling the number of
+            characters in the buffer.  Otherwise, format-decode might
+            fail to correctly analyze the beginning or end of the buffer.
+            Hence we temporarily save `point' and `inserted' here and
+            restore `point' iff format-decode did not insert or delete
+            any text.  Otherwise we leave `point' at point-min.  */
          int opoint = PT;
          int opoint_byte = PT_BYTE;
          int oinserted = ZV - BEGV;
@@ -4721,7 +4722,7 @@
        }
 
       /* For consistency with format-decode call these now iff inserted > 0
-        (martin 2007-06-28) */
+        (martin 2007-06-28).  */
       p = Vafter_insert_file_functions;
       while (CONSP (p))
        {
@@ -4736,7 +4737,8 @@
            }
          else
            {
-             /* For the rationale of this see the comment on format-decode 
above. */
+             /* For the rationale of this see the comment on
+                format-decode above.  */
              int opoint = PT;
              int opoint_byte = PT_BYTE;
              int oinserted = ZV - BEGV;
@@ -4767,17 +4769,16 @@
 
       if (NILP (visit))
        {
-         Lisp_Object lbeg, lend;
-         XSETINT (lbeg, PT);
-         XSETINT (lend, PT + inserted);
-         if (CONSP (old_undo))
+         current_buffer->undo_list = old_undo;
+         if (CONSP (old_undo) && inserted != old_inserted)
            {
+             /* Adjust the last undo record for the size change during
+                the format conversion.  */
              Lisp_Object tem = XCAR (old_undo);
-             if (CONSP (tem) && INTEGERP (XCAR (tem)) &&
-                 INTEGERP (XCDR (tem)) && EQ (XCAR (tem), lbeg))
-               /* In the non-visiting case record only the final insertion. */
-               current_buffer->undo_list =
-                 Fcons (Fcons (lbeg, lend), Fcdr (old_undo));
+             if (CONSP (tem) && INTEGERP (XCAR (tem))
+                 && INTEGERP (XCDR (tem))
+                 && XFASTINT (XCDR (tem)) == PT + old_inserted)
+               XSETCDR (tem, make_number (PT + inserted));
            }
        }
       else




reply via email to

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