recentf does not save all opened files

628 views Asked by At

I have been having issues with recentf for quite a while: even I close emacs gracefully very oftern used files would not be in recent files next time.

My recentf config looks like

(use-package recentf
  :config
  (setq
    recentf-save-file "~/.cache/emacs/recentf"
    recentf-max-saved-items 10000
    recentf-max-menu-items 5000
    )
  (recentf-mode 1)
  (run-at-time nil (* 5 60) 'recentf-save-list)
  )

Recently I have noticed this

Saving file /home/yuki/.cache/emacs/recentf...
Wrote /home/yuki/.cache/emacs/recentf
Saving file /home/yuki/.cache/emacs/recentf...
Wrote /home/yuki/.cache/emacs/recentf
Error: (file-missing "Doing chmod" "No such file or directory" "/home/yuki/.cache/emacs/recentf")
Saving file /home/yuki/.cache/emacs/recentf...
Wrote /home/yuki/.cache/emacs/recentf
Saving file /home/yuki/.cache/emacs/recentf...

Seems like at some point file disappears or something. Did anyone have similar problems? Any ideas what can go wrong (may be multiple instances)?

1

There are 1 answers

0
sw1nn On

I suspect something is loading recentf earlier than you expect (for me it was triggered by a require in consult.el, which mean that it loads the recentf list from the wrong place because you haven't yet set it to your location. Later, when the (run-at-time ...) fires, you store only those files that have been loaded since startup and the cycle continues...

TL;DR - You need to move your setup from :config to :init.

(use-package recentf
  :init
  (setq
    recentf-save-file "~/.cache/emacs/recentf"
    recentf-max-saved-items 10000
    recentf-max-menu-items 5000
    )
  (recentf-mode 1)
  (run-at-time nil (* 5 60) 'recentf-save-list)
  )