GNU bug report logs - #41060
[PATCH] Use write-region when saving recentf file

Previous Next

Package: emacs;

Reported by: philip <at> warpmail.net (Philip K.)

Date: Sun, 3 May 2020 19:15:01 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: philip <at> warpmail.net (Philip K.)
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Use write-region when saving recentf file
Date: Sun, 03 May 2020 18:43:01 +0200
[Message part 1 (text/plain, inline)]
I've been playing around with enabling "version-control" for backups,
and what I have been noticing is that the ~/.emacs.d/recentf file has
had a lot of backups, far more that regular files that I use. My
understanding is that this happens because recentf currently uses
write-file (that in turn uses the backup'ing save-buffer) instead of
directly writing the temporary buffer to the disk.

This patch does just that, replacing write-file with write-region,
because I argue that an automatically generated file doesn't need
backups.

-- 
	Philip K.

[0001-Use-write-region-when-saving-recentf-file.patch (text/x-diff, inline)]
>From 25700db3f6e8e282f86f1cd3ccc77250834fb7a0 Mon Sep 17 00:00:00 2001
From: Philip K <philip <at> warpmail.net>
Date: Sun, 3 May 2020 01:13:31 +0200
Subject: [PATCH] Use write-region when saving recentf file

---
 lisp/recentf.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/recentf.el b/lisp/recentf.el
index 27918a9739..877edd4be1 100644
--- a/lisp/recentf.el
+++ b/lisp/recentf.el
@@ -1289,7 +1289,8 @@ recentf-save-list
         (insert "\n\n;; Local Variables:\n"
                 (format ";; coding: %s\n" recentf-save-file-coding-system)
                 ";; End:\n")
-        (write-file (expand-file-name recentf-save-file))
+        (write-region (point-min) (point-max)
+                      (expand-file-name recentf-save-file))
         (when recentf-save-file-modes
           (set-file-modes recentf-save-file recentf-save-file-modes))
         nil)
-- 
2.20.1


This bug report was last modified 4 years and 290 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.