emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/consult-recoll 2e70eebee4 40/50: new feature: grouping


From: ELPA Syncer
Subject: [elpa] externals/consult-recoll 2e70eebee4 40/50: new feature: grouping search results by mime type
Date: Sat, 6 Aug 2022 18:57:43 -0400 (EDT)

branch: externals/consult-recoll
commit 2e70eebee41065866cb3f024f2b86ef2caa6d831
Author: jao <jao@gnu.org>
Commit: jao <jao@gnu.org>

    new feature: grouping search results by mime type
---
 consult-recoll.el | 12 +++++++++++-
 readme.org        |  5 +++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/consult-recoll.el b/consult-recoll.el
index 9f3c7a6107..e4cdcf9397 100644
--- a/consult-recoll.el
+++ b/consult-recoll.el
@@ -55,7 +55,7 @@
                  (list string)))
 
 (defcustom consult-recoll-open-fn #'find-file
-  "Default function used to open candidate URL.
+  "Default function used to open candidate URLs.
 It receives a single argument, the full path to the file to open.
 See also `consult-recoll-open-fns'"
   :type 'function)
@@ -64,6 +64,10 @@ See also `consult-recoll-open-fns'"
   "Alist mapping mime types to functions to open a selected candidate."
   :type '(alist :key-type string :value-type function))
 
+(defcustom consult-recoll-group-by-mime t
+  "When set, list search results grouped by mime type."
+  :type 'boolean)
+
 (defcustom consult-recoll-format-candidate nil
   "A function taking title, path and mime type, and formatting them for 
display.
 Set to nil to use the default 'title (path)' format."
@@ -161,6 +165,10 @@ Set to nil to use the default 'title (path)' format."
          (when (get-buffer consult-recoll--preview-buffer)
            (kill-buffer consult-recoll--preview-buffer)))))
 
+(defun consult-recoll--group (candidate transform)
+  "If TRANSFORM return candidate, othewise extract mime-type."
+  (if transform candidate (consult-recoll--candidate-mime candidate)))
+
 (defun consult-recoll--search (&optional initial)
   "Perform an asynchronous recoll search via `consult--read'.
 If given, use INITIAL as the starting point of the query."
@@ -174,6 +182,8 @@ If given, use INITIAL as the starting point of the query."
                  :lookup #'consult--lookup-member
                  :sort nil
                  :state #'consult-recoll--preview
+                 :group (and consult-recoll-group-by-mime
+                             #'consult-recoll--group)
                  :initial (consult--async-split-initial initial)
                  :history '(:input consult-recoll-history)
                  :category 'recoll-result))
diff --git a/readme.org b/readme.org
index 3337356664..d5d83adc44 100644
--- a/readme.org
+++ b/readme.org
@@ -98,6 +98,11 @@ display its results, via 
[[https://github.com/minad/consult][consult]].
       (setq consult-recoll-format-candidate #'jao-recoll-format)
     #+end_src
 
+*** Tip: disabling mime type groups
+    By default, results are listed grouped by their mime type.  You can
+    disable grouping by setting the customizable variable
+    ~consult-recoll-group-by-mime~ to ~nil~.
+
 ** Opening search results
     :PROPERTIES:
     :CUSTOM_ID: opening-results



reply via email to

[Prev in Thread] Current Thread [Next in Thread]