diff src/fileio.c @ 83676:27d11c1d4e46

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 857-862) - Update from CVS - Merge from emacs--rel--22 - Update from CVS: lisp/emacs-lisp/avl-tree.el: New file. * emacs--rel--22 (patch 97-100) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 246-247) - Update from CVS Revision: emacs@sv.gnu.org/emacs--multi-tty--0--patch-38
author Miles Bader <miles@gnu.org>
date Mon, 27 Aug 2007 09:21:49 +0000
parents 5b644ae74c91 496cd44c3983
children 480b9674f921
line wrap: on
line diff
--- a/src/fileio.c	Mon Aug 27 08:16:42 2007 +0000
+++ b/src/fileio.c	Mon Aug 27 09:21:49 2007 +0000
@@ -4735,14 +4735,21 @@
 	  int opoint = PT;
 	  int opoint_byte = PT_BYTE;
 	  int oinserted = ZV - BEGV;
+	  int ochars_modiff = CHARS_MODIFF;
 	  
 	  TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE); 
 	  insval = call3 (Qformat_decode,
 			  Qnil, make_number (oinserted), visit);
 	  CHECK_NUMBER (insval);
-	  if (XINT (insval) == oinserted)
+	  if (ochars_modiff == CHARS_MODIFF)
+	    /* format_decode didn't modify buffer's characters => move
+	       point back to position before inserted text and leave
+	       value of inserted alone. */
 	    SET_PT_BOTH (opoint, opoint_byte);
-	  inserted = XFASTINT (insval);
+	  else
+	    /* format_decode modified buffer's characters => consider
+	       entire buffer changed and leave point at point-min. */
+	    inserted = XFASTINT (insval);
 	}
 
       /* For consistency with format-decode call these now iff inserted > 0
@@ -4765,15 +4772,24 @@
 	      int opoint = PT;
 	      int opoint_byte = PT_BYTE;
 	      int oinserted = ZV - BEGV;
-
+	      int ochars_modiff = CHARS_MODIFF;
+	      
 	      TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE);
 	      insval = call1 (XCAR (p), make_number (oinserted));
 	      if (!NILP (insval))
 		{
 		  CHECK_NUMBER (insval);
-		  if (XINT (insval) == oinserted)
+		  if (ochars_modiff == CHARS_MODIFF)
+		    /* after_insert_file_functions didn't modify
+		       buffer's characters => move point back to
+		       position before inserted text and leave value of
+		       inserted alone. */
 		    SET_PT_BOTH (opoint, opoint_byte);
-		  inserted = XFASTINT (insval);
+		  else
+		    /* after_insert_file_functions did modify buffer's
+	               characters => consider entire buffer changed and
+	               leave point at point-min. */
+		    inserted = XFASTINT (insval);
 		}
 	    }