2

When I want to open a recent file, I use ido-find-find (C-x C-f) or ido-switch-buffer (C-x b) and type a few characters and Ido automatically finds the right file among the recent files I have visited.

I would like to have something similar for directories. For example, with ido-dired, Ido suggests the current directory and I have to navigate my filesystem to reach the one I have in mind. For example, to reach ~/some/sub/directory/containing/the/RightDirectory/, I have to type in the first letters of all the parent directories (and remember them) to reach RightDirectory/. I find that cumbersome.

Is there a way to get an interface similar to ido-find-file to reach a recent directory?

Note: I am open to any other suggestion of workflow to reach a recent (or any) directory quickly.

2 Answers 2

1

I am open to any other suggestion of workflow to reach a recent (or any) directory quickly.

Dired+ lets you open a Dired buffer that shows recently used directories (commands diredp-dired-recent-dirs and diredp-dired-recent-dirs-other-window, bound globally to C-x D r and C-x 4 D r).

This is similar to the commands showing recent files (C-x D R and C-x 4 D R).

C-h C-x D r says:

Open Dired in BUFFER, showing recently visited directories.

Like diredp-dired-recent-files, but limited to recent directories. A directory is recent if any of its files is recent.

The more extensive doc string for C-x D R (recent files) says this. It all applies also to the recent-directories commands.

diredp-dired-recent-files is an interactive compiled Lisp function in dired+.el.

It is bound to C-x D R.

(diredp-dired-recent-files BUFFER &optional ARG FILES)

Open Dired in BUFFER, showing recently visited files and directories.

You are prompted for BUFFER (default: Recently Visited Files).

With a numeric prefix arg you can enter names of recent files to include or exclude.

No prefix arg or a plain prefix arg (C-u, C-u C-u, etc.) means list all of the recently used files.

With a prefix arg:

  • If 0, -, or plain (C-u) then you are prompted for the ls switches to use.

  • If not plain (C-u) then:

    • If >= 0 then the files to include are read, one by one.
    • If < 0 then the files to exclude are read, one by one.

When entering files to include or exclude, use C-g to end.

The file listing is sorted by option diredp-default-sort-arbitrary-function, if non-nil. If nil (the default) then the listing is in reverse chronological order of opening or writing files you access.

Use g to revert the buffer, as usual. If you use it without a prefix arg then the same files are relisted. A prefix arg is handled as for C-x D R itself.

When called from Lisp:

  • ARG corresponds to the raw prefix arg.
  • FILES is passed to diredp--dired-recent-files-1. It is used only when the command is used as part of the revert-buffer-function.

You can even sort such Dired buffers, using C-M-L (aka C-M-S-l).

1

Something quick. Far from perfection, but it's a start. (You might want to add some cache mechanism since it's rather slow)

(defun find-recent-dirs (dir) (interactive (list (completing-read "Recent dirs: " (-filter (lambda (p) (and (not (file-remote-p p)) (f-directory? p))) (-uniq (-map #'f-dirname recentf-list))))))) (find-file dir)) 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.