diff options
Diffstat (limited to 'custom/jao-custom-gnus.el')
-rw-r--r-- | custom/jao-custom-gnus.el | 79 |
1 files changed, 67 insertions, 12 deletions
diff --git a/custom/jao-custom-gnus.el b/custom/jao-custom-gnus.el index 0d75b43..70823ef 100644 --- a/custom/jao-custom-gnus.el +++ b/custom/jao-custom-gnus.el @@ -114,7 +114,7 @@ (cl-defmethod gnus-search-indexed-search-command ((engine gnus-search-recoll) (qstring string) - _query + query &optional groups) (let* ((subdir (slot-value engine 'remove-prefix)) (sep (slot-value engine 'separator)) @@ -128,8 +128,18 @@ (mapconcat (lambda (d) (format "dir:%s" d)) gdirs " OR ") ")"))) - (q (concat "mime:message " dirsq " (" qstring ")"))) - ;; (message "query is: %s" q) + (qstring (if (string-prefix-p "id:" qstring) + (replace-regexp-in-string "<\\|>" "\"" qstring) + qstring)) + (qstring (if (cdr (assoc 'thread query)) + (concat qstring " OR " + (replace-regexp-in-string "id:\"" "ref:\"" + qstring)) + qstring)) + (qstring (replace-regexp-in-string " or " " OR " qstring)) + (qstring (replace-regexp-in-string " and " " AND " qstring)) + (q (format "mime:message %s (%s)" dirsq qstring))) + ;; (message "query is: %s -- %S" q query) `("-b" "-t" "-q" ,q)))) ;; (add-to-list 'gnus-parameters '("^nnselect:.*" (nnselect-rescan . t))) @@ -438,19 +448,37 @@ :config (add-to-list 'org-capture-templates '("X" "arXiv" entry (file "notes/physics/arxiv.org") - "* %:subject\n %i" :immediate-finish t) + "* %:subject\n\n(jao-gnus-org-paragraph \"%i\")" + :immediate-finish t) t) (org-capture-upgrade-templates org-capture-templates)) +(defvar jao-gnus-org-url nil) +(defun jao-gnus-org-paragraph (x) + (with-temp-buffer + (insert " " (string-trim (or x "")) "\n ") + (goto-char 0) + (fill-paragraph) + (goto-char (point-max)) + (open-rectangle 0 (point)) + (concat (buffer-string) "\n " (or jao-gnus-org-url "")))) + (defun jao-gnus-arXiv-capture () (interactive) + (unless (derived-mode-p '(gnus-summary-mode)) (gnus-article-show-summary)) + (setq jao-subject (gnus-summary-article-subject)) (gnus-summary-select-article-buffer) (gnus-article-goto-part 0) - (forward-paragraph) (setq-local transient-mark-mode 'lambda) (set-mark (point)) - (goto-char (point-max)) - (org-capture nil "X")) + (forward-paragraph) + (save-excursion + (when (re-search-forward "^Link" nil t) + (beginning-of-line) + (setq jao-gnus-org-url (org-eww-url-below-point)))) + (org-capture nil "X") + (set-mark (point)) + (gnus-article-show-summary)) ;;; article ;;;; config, headers @@ -533,9 +561,18 @@ (search-forward-regexp "^URL: h" nil t) (and (search-forward-regexp "^Link$" nil t) (not (beginning-of-line)))) - (if external - (jao-browse-with-external-browser) - (browse-url (jao-url-around-point)))))) + (cond (external (jao-browse-with-external-browser)) + ((featurep 'jao-custom-eww) (eww (jao-url-around-point))) + (t (browse-url (jao-url-around-point))))))) + +(defun jao-gnus-from-eww (keep-eww-buffer) + (interactive "P") + (unless keep-eww-buffer (jao-eww-close)) + (jao-afio-goto-mail) + (gnus-article-show-summary)) + +(with-eval-after-load 'eww + (define-key eww-mode-map (kbd "h") #'jao-gnus-from-eww)) (defun jao-gnus-open-enclosure () (interactive) @@ -576,7 +613,16 @@ (gnus-demon-scan-news) (jao-gnus--notify))) -(gnus-demon-add-handler 'jao-gnus--scan 5 1) +(defun jao-gnus-add-demon () + (interactive) + (gnus-demon-add-handler 'jao-gnus--scan 5 1)) + +(jao-gnus-add-demon) +(gnus-demon-init) + +;; this is, in theory, not needed; but at some point in the way to emacs +;; version 31 this idle timers have ceased to work after a sleep/awake cycle +(add-to-list 'jao-sleep-awake-functions #'jao-gnus-add-demon) ;;; add-ons ;;;; notifications @@ -592,7 +638,7 @@ ("nnml:jao\\.\\(inbox\\|trove\\)" "I" jao-themes-f01) ("nnml:bigml\\.[^aibs]" "W" jao-themes-dimm) ("nnml:jao.hacking" "H" jao-themes-dimm) - ("nnml:jao.write" "W" jao-themes-error) + ("nnml:jao.write" "W" jao-themes-warning) ("nnml:jao.[^isthw]" "J" jao-themes-dimm) (,(format "^nnml:%s" (regexp-opt feeds)) "F" jao-themes-dimm) ("feeds\\.e" "E" jao-themes-dimm) @@ -717,6 +763,15 @@ (with-eval-after-load "consult-recoll" (add-to-list 'consult-recoll-open-fns '("message/rfc822" . jao-gnus-goto-file)))) +;;;; notmuch +(use-package jao-notmuch-gnus + :demand t) + +(jao-load-path "consult-notmuch") + +(use-package consult-notmuch + :bind (:map gnus-group-mode-map ("S" . #'jao-gnus-consult-notmuch))) + ;;; keyboard shortcuts (define-key gnus-article-mode-map "i" 'jao-gnus-show-images) (define-key gnus-summary-mode-map "i" 'jao-gnus-show-images) |