I want to quickly access recently visited files with ivy/counsel. In my init.el I have:

(use-package counsel
  :bind (("M-x" . counsel-M-x)
         ("C-x b" . counsel-switch-buffer)
         ("C-x C-f" . counsel-find-file)
         :map minibuffer-local-map
         ("C-r" . counsel-minibuffer-history)))

When I start Emacs and hit C-x C-f C-r I see a list of files I visited ... but from weeks ago. When I visit a file not in this list and check afterwards, it shows up there. But if I kill Emacs and restart it, I always end up with the "original" list, meaning my actions during the last sessions are forgotten.

Comming from here I also made sure I have

(savehist-mode 1)

but to no effect.

What am I missing? I am pretty sure it was working a while ago. I suppose some changes to my init-file are responsible. I checked carefully but found nothing. Any ideas what to look out for?

  • Does this answer your question? How do I persist M-x calls so they can be displayed in MRU order?
    – Drew
    Commented Nov 8, 2022 at 21:09
  • The question is a dup (probably of more than one question). Customize option savehist-additional-variables.
    – Drew
    Commented Nov 8, 2022 at 21:10
  • @Drew The docs of savehist-additional-variables state, I don't have to add minibuffer history variables. Nevertheless I tried (with counsel-minibuffer-history and file-name-history). But the problem persists.
    – Durtal
    Commented Nov 8, 2022 at 21:48

2 Answers 2


I think you need to set up and activate recentf. Here is a sample config:

(use-package recentf
  (setq recentf-exclude '("synctex" "log$"))
  (setq recentf-max-saved-items nil ;save all the items!
  :custom (recentf-auto-cleanup "1 min")

Finally, put

(setq ivy-use-virtual-buffers t)

in your ivy config to ensure that ivy knows to include recentf results.

  • Nope, the problem persists.
    – Durtal
    Commented Nov 8, 2022 at 21:35

There was some confusion with the savehist-file variable. I don't know how this happened or why it didn't work with the customized setting. I changed it to its default value and now everything seems to work again.

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.