Dired Flat File Listings

It turns out that if you call Dired from Elisp, you can pass it a list of files to display. Protesilaos Stavrou (Prot) leveraged that fact to write a bit of Elisp that provides him with a flat list of files matching a regular expression in a specified directory structure. His post has the code so you can see how he did it but it’s mostly what you’d expect: after some setup, he calls directory-file-recursively to gather the list of files that he then passes on to Dired.

It’s a pretty nice system but after using it for a while, Prot realized that when he was dealing with large directories a bit of initial filtering of the most recently modified files would be useful. He solved that by adapting his previous code to do the filtering. He does it by taking the list of files from his first function and running them through seq-filter to get the files he’s interested in. Again, all the code is in his post but Prot says he won’t be updating the post so you should check out his configuration for the latest version.

If you frequently generate Dired listings and would prefer to deal with a flat list of the files without worrying about what directory they’re in, take a look at Prot’s post for an excellent solution.

This entry was posted in General and tagged . Bookmark the permalink.