简体   繁体   中英

recentf does not save all opened files

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)?

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)
  )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM