Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: counsel-recentf with files ordered by last visible #1560

Open
wolfv6 opened this issue May 8, 2018 · 6 comments
Open

Feature request: counsel-recentf with files ordered by last visible #1560

wolfv6 opened this issue May 8, 2018 · 6 comments

Comments

@wolfv6
Copy link

wolfv6 commented May 8, 2018

Currently counsel-recentf lists file history in minibuffer in the order they where opened.

  • if an opened file is not one of the 12 most recent files opened, it is place at the top of history
  • if an opened file is one of the 12 most recent files opened, it's place in history remains unchanged

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:

  • reference a file often, while editing multiple files in another window
  • edit a file often, while referencing multiple files in another window

Example minibuffer counsel-recentflv with 2 windows currently open:

file currently open in window1 (currently open files are ordered as they appear in the frame)
file currently open in window2
file last visible at 3:10 (not-visible files are ordered by times they where last visible)
file last visible at 3:15
file last visible at 3:19
file last visible at 3:30

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

@abo-abo
Copy link
Owner

abo-abo commented May 8, 2018

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.

@basil-conto
Copy link
Collaborator

For posterity, this has been submitted as bug#31385.

@zzamboni
Copy link

zzamboni commented Sep 30, 2020

@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.

@basil-conto
Copy link
Collaborator

@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.

@tau3000
Copy link

tau3000 commented Nov 18, 2020

@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)

@zzamboni
Copy link

zzamboni commented Dec 2, 2020

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants