summaryrefslogtreecommitdiffhomepage
path: root/init.el
diff options
context:
space:
mode:
Diffstat (limited to 'init.el')
-rw-r--r--init.el82
1 files changed, 79 insertions, 3 deletions
diff --git a/init.el b/init.el
index 4538c05..9b8fed3 100644
--- a/init.el
+++ b/init.el
@@ -387,9 +387,6 @@
;;;; man pages
(setq Man-notify-method 'pushy) ;; pushy - same window
-;;;; recoll
-(use-package jao-recoll)
-
;;; Window manager and window system helpers
;;;; transparency
(defvar jao-transparent-only-bg (> emacs-major-version 28))
@@ -925,9 +922,88 @@
(require 'jao-skel-haskell)
(require 'jao-skel-latex))
+;;; Completion and search
;;;; completion
(require 'jao-custom-completion)
+;;;; recoll
+(use-package jao-recoll :demand t)
+
+(defun jao-recoll-messages ()
+ (interactive)
+ (jao-recoll "mime:message "))
+
+(defun jao-recoll-docs ()
+ (interactive)
+ (jao-recoll (format "dir:%s/doc " jao-org-dir)))
+
+(defun jao-recoll-notes ()
+ (interactive)
+ (jao-recoll (format "dir:%s " jao-org-notes-dir)))
+
+(defun jao-recoll-open-with-notmuch (fname)
+ (let ((id (with-temp-buffer
+ (insert-file fname)
+ (goto-char (point-min))
+ (when (re-search-forward "[Mm]essage-[Ii][Dd]: <?\\([^><]+\\)>?"
+ nil t)
+ (match-string 1)))))
+ (when id (notmuch-show (concat "id:" id)))))
+
+(with-eval-after-load "org"
+ (org-link-set-parameters "message" :follow #'jao-recoll-open-with-notmuch))
+
+;;;; consult-recoll
+(jao-load-path "consult-recoll")
+
+(defun jao-recoll-format (title url mtype)
+ (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)"
+ title
+ (propertize u 'face 'jao-themes-f00)
+ (propertize mtype 'face 'jao-themes-f01))))
+
+(defun jao-recoll-open-html (file)
+ (jao-afio--goto-www)
+ (eww-open-file file))
+
+(defun jao-recoll-consult-messages ()
+ (interactive)
+ (consult-recoll "mime:message "))
+
+(defun jao-recoll-consult-docs ()
+ (interactive)
+ (consult-recoll (format "dir:%s/doc " jao-org-dir)))
+
+(defun jao-recoll-consult-notes ()
+ "Use consult-recoll to search notes."
+ (interactive)
+ (consult-recoll (format "dir:%s " jao-org-notes-dir)))
+
+(use-package consult-recoll
+ :init (setq consult-recoll-open-fns
+ '(("application/pdf" . jao-open-doc)
+ ("message/rfc822" . jao-recoll-open-with-notmuch)
+ ("text/html" . jao-recoll-open-html))
+ consult-recoll-search-flags nil
+ consult-recoll-format-candidate #'jao-recoll-format)
+ :config
+ (transient-define-prefix jao-recoll-transient ()
+ [["Consult recoll queries"
+ ("r" "consult recoll query" consult-recoll)
+ ("n" "consult recoll on notes" jao-recoll-consult-notes)
+ ("d" "consult recoll on docs" jao-recoll-consult-docs)
+ ("m" "consult recoll on messages" jao-recoll-consult-messages)]
+ ["Recoll queries"
+ ("R" "recoll query" jao-recoll)
+ ("N" "recoll on notes" jao-recoll-notes)
+ ("D" "consult recoll on docs" jao-recoll-docs)
+ ("M" "consult recoll on messages" jao-recoll-messages)]])
+
+ :bind (("s-r" . #'jao-recoll-transient)))
+
;;; Buffers
;;;; cursor and mark
(transient-mark-mode -1)