]> code.delx.au - gnu-emacs/blobdiff - src/fileio.c
Merge from trunk.
[gnu-emacs] / src / fileio.c
index 7b4bd7f196da86ea81cd2bd35040d310e895b867..2ef3f1fe0f9399a890e545942b8485cecffcae04 100644 (file)
@@ -3878,6 +3878,9 @@ by calling `format-decode', which see.  */)
          beg_offset += same_at_start - BEGV_BYTE;
          end_offset -= ZV_BYTE - same_at_end;
 
+         invalidate_buffer_caches (current_buffer,
+                                   BYTE_TO_CHAR (same_at_start),
+                                   BYTE_TO_CHAR (same_at_end));
          del_range_byte (same_at_start, same_at_end, 0);
          /* Insert from the file at the proper position.  */
          temp = BYTE_TO_CHAR (same_at_start);
@@ -3988,7 +3991,12 @@ by calling `format-decode', which see.  */)
        {
          /* Truncate the buffer to the size of the file.  */
          if (same_at_start != same_at_end)
-           del_range_byte (same_at_start, same_at_end, 0);
+           {
+             invalidate_buffer_caches (current_buffer,
+                                       BYTE_TO_CHAR (same_at_start),
+                                       BYTE_TO_CHAR (same_at_end));
+             del_range_byte (same_at_start, same_at_end, 0);
+           }
          inserted = 0;
 
          unbind_to (this_count, Qnil);
@@ -4036,6 +4044,9 @@ by calling `format-decode', which see.  */)
 
       if (same_at_end != same_at_start)
        {
+         invalidate_buffer_caches (current_buffer,
+                                   BYTE_TO_CHAR (same_at_start),
+                                   BYTE_TO_CHAR (same_at_end));
          del_range_byte (same_at_start, same_at_end, 0);
          temp = GPT;
          eassert (same_at_start == GPT_BYTE);
@@ -5793,6 +5804,24 @@ void
 init_fileio (void)
 {
   valid_timestamp_file_system = 0;
+
+  /* fsync can be a significant performance hit.  Often it doesn't
+     suffice to make the file-save operation survive a crash.  For
+     batch scripts, which are typically part of larger shell commands
+     that don't fsync other files, its effect on performance can be
+     significant so its utility is particularly questionable.
+     Hence, for now by default fsync is used only when interactive.
+
+     For more on why fsync often fails to work on today's hardware, see:
+     Zheng M et al. Understanding the robustness of SSDs under power fault.
+     11th USENIX Conf. on File and Storage Technologies, 2013 (FAST '13), 271-84
+     http://www.usenix.org/system/files/conference/fast13/fast13-final80.pdf
+
+     For more on why fsync does not suffice even if it works properly, see:
+     Roche X. Necessary step(s) to synchronize filename operations on disk.
+     Austin Group Defect 672, 2013-03-19
+     http://austingroupbugs.net/view.php?id=672  */
+  write_region_inhibit_fsync = noninteractive;
 }
 
 void
@@ -6013,28 +6042,12 @@ in the buffer; this is the default behavior, because the auto-save
 file is usually more useful if it contains the deleted text.  */);
   Vauto_save_include_big_deletions = Qnil;
 
-  /* fsync can be a significant performance hit.  Often it doesn't
-     suffice to make the file-save operation survive a crash.  For
-     batch scripts, which are typically part of larger shell commands
-     that don't fsync other files, its effect on performance can be
-     significant so its utility is particularly questionable.
-     Hence, for now by default fsync is used only when interactive.
-
-     For more on why fsync often fails to work on today's hardware, see:
-     Zheng M et al. Understanding the robustness of SSDs under power fault.
-     11th USENIX Conf. on File and Storage Technologies, 2013 (FAST '13), 271-84
-     http://www.usenix.org/system/files/conference/fast13/fast13-final80.pdf
-
-     For more on why fsync does not suffice even if it works properly, see:
-     Roche X. Necessary step(s) to synchronize filename operations on disk.
-     Austin Group Defect 672, 2013-03-19
-     http://austingroupbugs.net/view.php?id=672  */
   DEFVAR_BOOL ("write-region-inhibit-fsync", write_region_inhibit_fsync,
               doc: /* Non-nil means don't call fsync in `write-region'.
 This variable affects calls to `write-region' as well as save commands.
 Setting this to nil may avoid data loss if the system loses power or
 the operating system crashes.  */);
-  write_region_inhibit_fsync = noninteractive;
+  write_region_inhibit_fsync = 0; /* See also `init_fileio' above.  */
 
   DEFVAR_BOOL ("delete-by-moving-to-trash", delete_by_moving_to_trash,
                doc: /* Specifies whether to use the system's trash can.