[Top][All Lists]

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

bug#39189: 26.2; recentf should save the list periodically

From: Pieter van Oostrum
Subject: bug#39189: 26.2; recentf should save the list periodically
Date: Sun, 19 Jan 2020 22:49:04 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.60 (darwin)

ndame <address@hidden> writes:

> Currently, recentf saves the recentf list only when emacs exits. Sometimes,
> when emacs crashes I lose recently opened files from the list, because
> the list is not saved periodically.
> Emacs should save the list every 10 minutes or so when the user is idle, so
> the recentf list is preserved even if there is a crash.

I have the following code in my ~/.emacs.d/init.el:

(defun delayed-recentf-save-list ()
  "Save recent files list when Emacs is idle."
  (run-with-idle-timer 10 nil 'repeat-recentf-save-list))

(defun repeat-recentf-save-list ()
  "Save recent files list when it was changed and Emacs is idle."
  (unless (equal recentf-saved-list recentf-list)
        (setq recentf-saved-list recentf-list))
  (run-at-time 120 nil 'delayed-recentf-save-list))


It saves periodically (every 2 minutes), but only when the list has changed, 
and it waits until Emacs is idle for 10 seconds.
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]

reply via email to

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