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.

ReneFroger
  • 3,855
  • 22
  • 63

2 Answers2

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.
Brian Burns
  • 1,577
  • 14
  • 15
  • 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 Jan 20 '16 at 18:18
  • From this link (https://www.emacswiki.org/emacs/RecentFiles) its advices to use `(setq recentf-save-file (recentf-expand-file-name ))` – alper Mar 27 '21 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"))
alper
  • 1,238
  • 11
  • 30