6

I looked around, but I couldn't find any answer in the documentation of recentf and with C-h v recent.

My default directory is set with the following:

(setq user-emacs-directory "~/home/ReneFroger/"
       default-directory "~/home/ReneFroger/")

I noticed Emacs saves the recent files that I have visited in the file recentf, which will be stored in the home/ReneFroger/ path. I would like to change the location of recentf but I can't find any variable that allows me to do this.

1
  • It's stored in /Users/sth/.emacs.d/.cache/recentf for me by default.
    – HappyFace
    Commented Apr 7, 2020 at 15:40

2 Answers 2

10

You can set it with

(setq recentf-save-file (expand-file-name "recentf" <other-directory>))

You can usually find settings like this by looking at the help for one of the functions, e.g. recentf-mode, then following the link to the source code, and then doing occur for defcustom to find one that looks like it might be a file storage location - e.g. in this case you'd get

 23 matches for "defcustom" in buffer: recentf.el
 65:(defcustom recentf-max-saved-items 20
 72:(defcustom recentf-save-file (locate-user-emacs-file "recentf" ".recentf")
 85:(defcustom recentf-save-file-modes 384 ;; 0600
 94:(defcustom recentf-exclude nil
111:(defcustom recentf-keep
etc.
2
  • 2
    Not only your answer, but the tip to follow the source code of recentf and then doing occur for defcustom was very valuable for me. Thanks for that!
    – ReneFroger
    Commented Jan 20, 2016 at 18:18
  • From this link (emacswiki.org/emacs/RecentFiles) its advices to use (setq recentf-save-file (recentf-expand-file-name <file_path>))
    – alper
    Commented Mar 27, 2021 at 17:12
2

From the link (https://www.emacswiki.org/emacs/RecentFiles):

;; use a different set of recent files
(setq recentf-save-file (recentf-expand-file-name "~/.emacs.d/.recentf"))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.