Skip to content

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

Description

@wolfv6

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

Activity

  1. abo-abo commented on May 8, 2018

    @abo-abo
    Owner

    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.

  2. basil-conto commented on May 8, 2018

    @basil-conto
    Collaborator

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

  3. zzamboni commented on Sep 30, 2020

    @zzamboni

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

  4. basil-conto commented on Sep 30, 2020

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

  5. tau3000 commented on Nov 18, 2020

    @tau3000

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

  6. zzamboni commented on Dec 2, 2020

    @zzamboni

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions