1

When finding files with Ctrl-x Ctrl-f and then pressing Tab, to list the file completion names, is there a way to list these files in reverse order of their dates (when they were last edited)? Currently emacs lists them alphabetically. Is there a way of having the following two options: pressing Ctrl-x Ctrl-f Tab lists the files in alphabetical order, pressing Ctrl-x Ctrl-f space lists them in reverse order of dates?

  • The answer probably depends on the completion framework (i.e. default, ido, ivy, helm, ...) you are using. So you should share that info. – jue Feb 13 at 14:43
  • sounds like default clean emacs since he uses tab. – RichieHH Feb 13 at 15:22
0

Vanilla Emacs doesn't let you choose the sort order in this context.

You can of course define your own command to use instead of what C-x C-f is bound to by default. But if you want to use read-file-name in that command then, again, you won't have much control over the order of candidates shown. If you instead use completing-read in the command, and you match file-name candidates only as strings, then you can order the set of candidates any way you like (and you can use relative or absolute file names). But in that case you lose the features of read-file-name (e.g. navigating up and down the file-system hierarchy).


If you use Icicles then you have multiple sort orders that you can switch among on the fly. See Icicles - File-Name Input and Icicles - Sorting Candidates for more info.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.