diff options
author | jao <jao@gnu.org> | 2022-06-28 03:27:52 +0100 |
---|---|---|
committer | jao <jao@gnu.org> | 2022-06-28 03:27:52 +0100 |
commit | 1834b5c5c0b0040377328a9f01e25bf87a0d6b8b (patch) | |
tree | 87da8f1b45bbe310ceacae6364668e2200fe8402 | |
parent | 9823e901c3d903e8ffe0a24ce692ad6192186643 (diff) | |
download | elibs-1834b5c5c0b0040377328a9f01e25bf87a0d6b8b.tar.gz elibs-1834b5c5c0b0040377328a9f01e25bf87a0d6b8b.tar.bz2 |
recoll code shuffling
-rw-r--r-- | custom/jao-custom-completion.el | 75 | ||||
-rw-r--r-- | init.el | 82 |
2 files changed, 79 insertions, 78 deletions
diff --git a/custom/jao-custom-completion.el b/custom/jao-custom-completion.el index 8afd4ae..47ada77 100644 --- a/custom/jao-custom-completion.el +++ b/custom/jao-custom-completion.el @@ -440,80 +440,5 @@ ("C-S-l" . jao-link-hint-open-link-ext) ("C-x C-l" . recenter-top-bottom))) -;;; 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-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-consult-notes () - "Use consult-recoll to search notes." - (interactive) - (consult-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)) - -(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))) - ;;; . (provide 'jao-custom-completion) @@ -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) |