Display filtered and sorted files with denote-sort-dired or denote-dired
The ‘denote.el’ file contains functions which empower user or developers to sort files by the given file name component (The file-naming scheme).
The command denote-sort-dired (alias denote-dired) produces a Dired file listing with a flat, filtered, and sorted set of files from the denote-directory (Define a sorting function per component). It does so by a series of prompts, which can be configured with the user option denote-sort-dired-extra-prompts (Configure what extra prompts denote-sort-dired issues).
Think of denote-sort-dired as the counterpart to the Unix find command. While denote-grep corresponds to the Unix grep (Use denote-grep to search inside files).
The out-of-the-box behaviour of denote-sort-dired is as follows:
- It first asks for a regular expression with which to match Denote file names. Remember that due to Denote’s efficient file-naming scheme, you usually do not need to write some complex regular expression. For example, something like ‘
_journal’ will match only files with a ‘journal’ keyword. - Once the regular expression is provided, the command asks for a Denote file name component to sort files by. This is a symbol among ‘
title’, ‘keywords’, ‘signature’, and ‘identifier’ (Define a sorting function per component). - Finally, it asks a “yes or no” on whether to reverse the sort order.
The resulting listing is a regular Dired buffer, unlike that of dired-virtual-mode (Use dired-virtual-mode for arbitrary file listings).
The sorting mechanism can be used by other packages to achieve their ends. As an example, the dynamic Org blocks that the denote-org package (by Protesilaos) defines also use this feature internally by means of the non-interactive function denote-sort-files.