branch: externals/consult-recoll commit f32c281756d60732663815d01e083c1721a1bdeb Author: jao <j...@gnu.org> Commit: jao <j...@gnu.org>
readme: example of a result formatter --- readme.org | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/readme.org b/readme.org index 7aa8d1d1d7..3337356664 100644 --- a/readme.org +++ b/readme.org @@ -78,6 +78,26 @@ display its results, via [[https://github.com/minad/consult][consult]]. snippets of the file (when provided by recoll). The title, path and mime type of the document are also shown in previews. +*** Tip: formatting results list + As mentioned, one can use ~consult-recoll-format-candidate~ to customize how + search results are shown in the minibufer. For instance, i like to + shorten paths removing common prefixes and to show MIME types, so i use + a formatter similar to this one: + #+begin_src emacs-lisp + (defun jao-recoll-format (title url mime-type) + ;; remove from url the common prefixes /home/jao/{org/doc,doc,...} + (let* ((u (replace-regexp-in-string "/home/jao/" "" url)) + (u (replace-regexp-in-string + "\\(doc\\|org/doc\\|.emacs.d/gnus/Mail\\|var/mail\\)/" "" u))) + (format "%s (%s, %s)" + (propertize title 'face 'consult-recoll-title-face) + (propertize u 'face 'consult-recoll-url-face) + (propertize mime-type 'face 'consult-recoll-mime-face)))) + + + (setq consult-recoll-format-candidate #'jao-recoll-format) + #+end_src + ** Opening search results :PROPERTIES: :CUSTOM_ID: opening-results