Add a query link
As noted in the introduction to this section of the manual, the ‘denote:’ hyperlink type supports query links (Linking notes). Unlike direct links, they do not point to any given file. Instead, they trigger a search, whose results are displayed in a separate buffer.
Query links are expressed as ‘denote:TOKEN:QUERY’, where ‘TOKEN’ is either ‘query-contents’ or ‘query-filenames’, while ‘QUERY’ is a string or Emacs regular expression to search for.
The exact syntax of a query link depends on the file type. In Org and plain text buffers, links are of the form ‘[[denote:TOKEN:QUERY][QUERY]]’. In Markdown, they are formatted as ‘[QUERY](denote:TOKEN:QUERY)’. In all cases, the description of the link is the query text itself.
The command denote-query-contents-link inserts a link at point that triggers a search in the file contents of all readable documents in the denote-directory (Interact with the links buffer). This is the equivalent of the Unix grep command and uses the built-in Emacs Xref interface (Speed up backlinks’ or query links’ buffer creation?). Matches are displayed in a separate buffer, highlighting the exact text while showing its context.
The command denote-query-filenames-link creates a link at point that initiates a search across file names in the denote-directory. This is the equivalent of the Unix find command. Results are placed in a Dired buffer (Display filtered and sorted files with denote-sort-dired).
The user option denote-query-links-display-buffer-action controls the placement of query link buffers. By default, they are designed to appear below the current window.
Query links are styled with the denote-faces-query-link face, which looks a bit different that denote-faces-link (though this depends on the active theme).