From 55bf8954d181a74349d06a48e33ef84529fb7049 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 1 Jan 2023 14:05:04 -0800 Subject: [PATCH] Improve interactive file-saving performance * src/fileio.c (init_fileio, syms_of_fileio): Default write-region-inhibit-fsync to t (Bug#60474). --- doc/emacs/files.texi | 3 +-- doc/lispref/files.texi | 3 +-- etc/NEWS | 4 ++++ src/fileio.c | 6 +++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index 6d66683161..5164339c66 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi @@ -815,8 +815,7 @@ Customize Save The @code{write-region-inhibit-fsync} variable controls whether Emacs invokes @code{fsync} after saving a file. The variable's -default value is @code{nil} when Emacs is interactive, and @code{t} -when Emacs runs in batch mode (@pxref{Initial Options, Batch Mode}). +default value is @code{t}. Emacs never uses @code{fsync} when writing auto-save files, as these files might lose data anyway. diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index 707af6ee64..57784fb57f 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi @@ -695,8 +695,7 @@ Writing to Files @code{fsync} system call after writing a file. Although this slows Emacs down, it lessens the risk of data loss after power failure. If the value is @code{t}, Emacs does not use @code{fsync}. The default -value is @code{nil} when Emacs is interactive, and @code{t} when Emacs -runs in batch mode. @xref{Files and Storage}. +value is @code{t}. @xref{Files and Storage}. @end defvar @defmac with-temp-file file body@dots{} diff --git a/etc/NEWS b/etc/NEWS index eb68ce434b..1ab6822da3 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -41,6 +41,10 @@ compositing manager, Emacs will now redisplay such a frame even though 'frame-visible-' returns nil or 'icon' for it. This can happen, for example, as part of preview for iconified frames. ++++ +** 'write-region-inhibit-fsync' now defaults to t in interactive mode, +as it has in batch mode since Emacs 24. + * Editing Changes in Emacs 30.1 diff --git a/src/fileio.c b/src/fileio.c index 7fb7f5ddc5..bd4c8ec0c9 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -6351,7 +6351,7 @@ init_fileio (void) Roche X. Necessary step(s) to synchronize filename operations on disk. Austin Group Defect 672, 2013-03-19 https://austingroupbugs.net/view.php?id=672 */ - write_region_inhibit_fsync = noninteractive; + write_region_inhibit_fsync = true; } void @@ -6610,8 +6610,8 @@ do (file-exists-p FILENAME) and FILENAME is handled by HANDLER, then 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. By default, it is non-nil in batch mode. */); - write_region_inhibit_fsync = 0; /* See also `init_fileio' above. */ +the operating system crashes. By default, it is non-nil. */); + write_region_inhibit_fsync = true; /* 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. -- 2.38.1