[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/consult-recoll 34e883562c 02/50: initial implementation
From: |
ELPA Syncer |
Subject: |
[elpa] externals/consult-recoll 34e883562c 02/50: initial implementation |
Date: |
Sat, 6 Aug 2022 18:57:40 -0400 (EDT) |
branch: externals/consult-recoll
commit 34e883562cfc689d96c35e4da7dda8c46aaa1227
Author: jao <jao@gnu.org>
Commit: jao <jao@gnu.org>
initial implementation
---
README.md | 3 --
consult-recoll.el | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
LICENSE => license | 0
readme.org | 7 +++++
4 files changed, 93 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
deleted file mode 100644
index baeefd4ade..0000000000
--- a/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# consult-recoll
-
-recoll queries in emacs using consult
\ No newline at end of file
diff --git a/consult-recoll.el b/consult-recoll.el
new file mode 100644
index 0000000000..1a57abb130
--- /dev/null
+++ b/consult-recoll.el
@@ -0,0 +1,86 @@
+;;; consult-recoll.el --- Recoll searches using consult -*- lexical-binding:
t; -*-
+
+;; Author: Jose A Ortega Ruiz <jao@gnu.org>
+;; Maintainer: Jose A Ortega Ruiz
+;; Keywords: docs, convenience
+;; License: GPL-3.0-or-later
+;; Version: 0.1
+;; Package-Requires: ((emacs "26.1") (consult "0.5"))
+;; Homepage: https://codeberg.org/jao/consult-recoll
+
+;; Copyright (C) 2021 Jose A Ortega Ruiz
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; A simple consult-recoll function to perform simple queries over
+;; your Recoll (https://www.lesbonscomptes.com/recoll/) index.
+
+;;; Code:
+
+(require 'consult)
+
+(defvar consult-recoll--command
+ "recollq -a -F \"url title\" ARG"
+ "Command used to perform queries.")
+
+(defvar consult-recoll--open-fn #'find-file
+ "Function used to open candidate URL.")
+
+(defface consult-recoll-url-face '((t :inherit default))
+ "Face used to display URLs of candidates.")
+
+(defface consult-recoll-title-face '((t :inherit italic))
+ "Face used to display titles of candidates.")
+
+(defvar consult-recoll-history nil "History for `consult-recoll'.")
+
+(defun consult-recoll--transformer (str)
+ "Decode STR, as returned by recollq."
+ (unless (string-match-p "^\\(Recoll query:\\|[0-9]+ results\\| *$\\)" str)
+ (let* ((cmps (split-string str " " t))
+ (url+title (seq-map #'base64-decode-string cmps))
+ (url (car url+title))
+ (title (or (cadr url+title) (file-name-base url)))
+ (url (if (string-prefix-p "file://" url) (substring url 7) url)))
+ (format "%s (%s)"
+ (propertize title 'face 'consult-recoll-title-face)
+ (propertize url 'face 'consult-recoll-url-face)))))
+
+(defun consult-recoll--open (candidate)
+ "Open file of corresponding completion CANDIDATE."
+ (when (string-match ".+ (\\(.+\\))$" (or candidate ""))
+ (funcall consult-recoll--open-fn (match-string 1 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."
+ (consult--read (consult--async-command consult-recoll--command
+ (consult--async-filter (lambda (x) (not (null x))))
+ (consult--async-map #'consult-recoll--transformer))
+ :prompt "Recoll search: "
+ :require-match t
+ :initial (concat consult-async-default-split initial)
+ :history 'consult-recoll-history
+ :category 'recoll-result))
+
+;;;###autoload
+(defun consult-recoll ()
+ "Consult recoll's local index."
+ (interactive)
+ (consult-recoll--open (consult-recoll--search)))
+
+(provide 'consult-recoll)
+;;; consult-recoll.el ends here
diff --git a/LICENSE b/license
similarity index 100%
rename from LICENSE
rename to license
diff --git a/readme.org b/readme.org
new file mode 100644
index 0000000000..3b6a263f14
--- /dev/null
+++ b/readme.org
@@ -0,0 +1,7 @@
+#+title: consult-recoll
+
+[[(https://www.lesbonscomptes.com/recoll/][recoll]] queries in emacs using
consult.
+
+This package requires a working recoll index, and ~recollq~ in your
+path. =M-x consult-recoll= to perform a query on the index using
+consult.
- [elpa] externals/consult-recoll 39251b54eb 43/50: screenshot: no-groups and inline, (continued)
- [elpa] externals/consult-recoll 39251b54eb 43/50: screenshot: no-groups and inline, ELPA Syncer, 2022/08/06
- [elpa] externals/consult-recoll 204a936c5b 35/50: fix: a better regexp for decomposing recollq results, ELPA Syncer, 2022/08/06
- [elpa] externals/consult-recoll d96779ece2 01/50: Initial commit, ELPA Syncer, 2022/08/06
- [elpa] externals/consult-recoll c68b79f130 05/50: customizable prompt, ELPA Syncer, 2022/08/06
- [elpa] externals/consult-recoll 6ea952cd4c 36/50: back to the previous regexp, it's more precise in the common case, ELPA Syncer, 2022/08/06
- [elpa] externals/consult-recoll 3070550d0f 41/50: index metadata for search results, ELPA Syncer, 2022/08/06
- [elpa] externals/consult-recoll 1c48329d90 48/50: fix: show also results that have no snippets, ELPA Syncer, 2022/08/06
- [elpa] externals/consult-recoll 6ef792703b 19/50: Note on two-phased queries (fixes #2), ELPA Syncer, 2022/08/06
- [elpa] externals/consult-recoll 47f6c618a2 46/50: readme: thanks section, ELPA Syncer, 2022/08/06
- [elpa] externals/consult-recoll 72fc38d27a 49/50: readme: recommendation for a vertical completions UI, ELPA Syncer, 2022/08/06
- [elpa] externals/consult-recoll 34e883562c 02/50: initial implementation,
ELPA Syncer <=
- [elpa] externals/consult-recoll aa5bdff7f8 07/50: typo, ELPA Syncer, 2022/08/06
- [elpa] externals/consult-recoll 35b78fa3c1 08/50: readme: link to consult, ELPA Syncer, 2022/08/06
- [elpa] externals/consult-recoll c8e0849308 06/50: readme tweaks, ELPA Syncer, 2022/08/06
- [elpa] externals/consult-recoll b0fa4831e0 15/50: fix: using recoll's candidate ordering rather than alphabetical, ELPA Syncer, 2022/08/06
- [elpa] externals/consult-recoll 0ba5ae1b53 17/50: fix for consult-recoll's input history, ELPA Syncer, 2022/08/06
- [elpa] externals/consult-recoll ba3fcb8bae 28/50: readme: melpa badges, ELPA Syncer, 2022/08/06
- [elpa] externals/consult-recoll 9ce929510f 47/50: fix: reset index and current for every new search term, ELPA Syncer, 2022/08/06
- [elpa] externals/consult-recoll d550a76ffb 24/50: a bit more structure, ELPA Syncer, 2022/08/06
- [elpa] externals/consult-recoll 85a527af31 27/50: wee commentary tweaks, ELPA Syncer, 2022/08/06
- [elpa] externals/consult-recoll 57f2a5552f 31/50: Version bump, ELPA Syncer, 2022/08/06