Open wolfv6 opened 6 years ago
This sounds more like a feature request for recentf
. counsel-recentf
is simply a client of recentf
, it should not take over the responsibilities of that package.
So I suggest to open a feature request for recentf
with M-x report-emacs-bug
, since recentf
is in Emacs core. Once the functionality is implemented there, counsel-recentf
can use it.
If getting things done in the Emacs core seems too slow, you could also set up a new package on MELPA, e.g. better-recentf
or something.
For posterity, this has been submitted as bug#31385.
@basil-conto thanks for submitting this. Did you ever see any progress in that recentf bug, or find a workaround? I have been wondering about this behavior myself recently.
@zzamboni No, sorry. I have not followed up on it because I do not use recentf
, but as you can see in the linked feature request, neither has anyone else.
@wolfv6 @zzamboni The following works well for me.
(use-package switch-buffer-functions
:defer t
:after recentf
:preface
(defun my-recentf-track-visited-file (_prev _curr)
(and buffer-file-name
(recentf-add-file buffer-file-name)))
:init
(add-hook 'switch-buffer-functions #'my-recentf-track-visited-file))
cf. https://tsuu32.hatenablog.com/entry/2019/12/16/124052 (in Japanese)
@tau3000 thanks for the tip! Works well for me too. I've added this to my config: https://github.com/zzamboni/dot-doom/blob/master/doom.org#miscellaneous-keybindings
Currently counsel-recentf lists file history in minibuffer in the order they where opened.
There is a more human friendly way to list file history. Instead of listing files in the order they were opened, list files in the order they were last visible.
This is more human friendly because it is how human memory works. I remember when I was last looking at something (not when I opened it). So when I think, "I was just looking at such-and-such. What file was that in?", I find the file listed near the top of the minibuffer.
Here is a more detailed description: List currently-visible files at the top of minibuffer. Below currently-visible files, list file history in the order that they where last visible. Every time a file disappears from view, it is moved to just below currently-visible files.
Use cases:
Example minibuffer counsel-recentflv with 2 windows currently open:
This might be relevant. https://www.emacswiki.org/emacs/RecentFiles mentions recentf variables: file-was-visible-p keep-default-and-visible-recentf-p keep-default-and-visible-recentf-p