0

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?

Drew
  • 75,699
  • 9
  • 109
  • 225
Durtal
  • 101
  • Does this answer your question? [How do I persist M-x calls so they can be displayed in MRU order?](https://emacs.stackexchange.com/questions/45069/how-do-i-persist-m-x-calls-so-they-can-be-displayed-in-mru-order) – Drew Nov 08 '22 at 21:09
  • The question is a dup (probably of more than one question). Customize option `savehist-additional-variables`. – Drew Nov 08 '22 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 Nov 08 '22 at 21:48

2 Answers2

0

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

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

Finally, put

(setq ivy-use-virtual-buffers t)

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

Fran Burstall
  • 3,665
  • 10
  • 18
0

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.

Durtal
  • 101