0

Currently the recentf-open dialog sorts by which entry was most recently opened through recentf-open. I would however prefer this to be access time in general, so whichever file I visited last, not necessarily through said dialog.

I've searched far and wide for a solution and found nothing, and I've tried to write a function that sorts the list and execute it before opening the prompt popup/minibuffer, but that did nothing. Especially since the "access time" in file metadata doesn't really reflect reality.

As far as I can tell the actual order of recentf-list does not affect the order on the prompt minibuffer, is there any way of achieving that short of practically recreating recentf on the basis of file-name-history? (or if it's not too much effort that would work too, it just seems like overkill and probably a solved issue that I just can't find...)

2
  • Look for amx package, may help, depend on your configuration. Commented Jan 30 at 13:46
  • I'm not sure how I understand how that would help? It seems to just replace M-x, nothing with other things in the minibuffer? Commented Jan 31 at 14:05

1 Answer 1

0

What you want would require a real-time interrogation of every path on the recentf list to determine access time as-of the moment you want to display the list. This could be expensive if the list is long, and time-consuming if network/remote files are on the list. It would require taking precautions against hanging if external resources could possibly be involved.

Nevertheless, you could write a function that loops thru files on recentf-list, sorts them appropriately, then implement it by adding '(recentf-menu-filter 'my-recentf-custom-sort) to your .emacs custom-set-variables section.

There are several sorting implementations in .../lisp/recentf.el.gz for use as raw examples such as:

(defun recentf-sort-basenames-descending (l) "Sort the list of menu elements L in descending order. Only filenames sans directory are compared." (sort (copy-sequence l) (lambda (e1 e2) (recentf-string-lessp (file-name-nondirectory (recentf-menu-element-value e2)) (file-name-nondirectory (recentf-menu-element-value e1)))))) (defun recentf-sort-directories-ascending (l) "Sort the list of menu elements L in ascending order. Compares directories then filenames to order the list." (sort (copy-sequence l) (lambda (e1 e2) (recentf-directory-compare (recentf-menu-element-value e1) (recentf-menu-element-value e2))))) 

Obviously you need to add some info-gathering steps before sorting and you probably want to filter out remote paths to avoid that headache but the satisfaction of accomplishment factor could be significant:)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.