all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Pieter van Oostrum <pieter-l@vanoostrum.org>
To: ndame <emacsuser@freemail.hu>
Cc: 39189@debbugs.gnu.org
Subject: bug#39189: 26.2; recentf should save the list periodically
Date: Sun, 19 Jan 2020 22:49:04 +0100	[thread overview]
Message-ID: <lxd0bfce27.fsf@cochabamba.vanoostrum.org> (raw)
In-Reply-To: <AyNW2A.EKNcPedqkEA.8dkhgbLf0vcFfQu4Wbp0@freemail.hu> (ndame's message of "Sun, 19 Jan 2020 10:16:12 +0000 (GMT)")

ndame <emacsuser@freemail.hu> 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)
	(recentf-save-list)
	(setq recentf-saved-list recentf-list))
  (run-at-time 120 nil 'delayed-recentf-save-list))

(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	other threads:[~2020-01-19 21:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-19 10:16 bug#39189: 26.2; recentf should save the list periodically ndame
2020-01-19 21:49 ` Pieter van Oostrum [this message]
2020-01-23  1:05 ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=lxd0bfce27.fsf@cochabamba.vanoostrum.org \
    --to=pieter-l@vanoostrum.org \
    --cc=39189@debbugs.gnu.org \
    --cc=emacsuser@freemail.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.