From 9af5239971df315d1403733eb1e38039375ffdc9 Mon Sep 17 00:00:00 2001 From: jao Date: Thu, 30 Jun 2022 15:30:17 +0100 Subject: notmuch nits --- attic/misc.el | 47 ++++++++++++++++++++++++++++++++++++++++--- attic/net/jao-notmuch-gnus.el | 27 ++++++++++++++++++------- custom/jao-custom-notmuch.el | 16 +++++++++++++++ init.el | 17 ++-------------- 4 files changed, 82 insertions(+), 25 deletions(-) diff --git a/attic/misc.el b/attic/misc.el index a872ce7..e394490 100644 --- a/attic/misc.el +++ b/attic/misc.el @@ -1,4 +1,4 @@ -;;;; ace window +;;; ace window (use-package ace-window :ensure t :demand t @@ -27,7 +27,7 @@ ("M-O" . ace-swap-window) ("C-x 4 t" . ace-swap-window))) -;;;; sway +;;; sway (defun jao-swaymsg (msg) (shell-command (format "swaymsg '%s' >/dev/null" msg))) @@ -76,7 +76,7 @@ (defalias 'x-change-window-property #'ignore) (add-hook 'after-init-hook #'jao-sway-enable)) -;;;; time display +;;; time display (setq display-time-world-list '(("Europe/Paris" "Barcelona") ("America/Los_Angeles" "Los Angeles") @@ -122,3 +122,44 @@ (message "%s = %s" v (format-time-string "%Y-%m-%d %H:%M:%S" (seconds-to-time (/ v 1000.0)))))) +;;; gnus bits + +(jao-transient-major-mode gnus-group + ["Search" + ("zc" "consult search" consult-notmuch) + ("zf" "consult folder search" jao-consult-notmuch-folder) + ("g" "gnus search" gnus-group-read-ephemeral-search-group)]) + +(defun jao-gnus-restart-servers () + (interactive) + (message "Restarting all servers...") + (gnus-group-enter-server-mode) + (gnus-server-close-all-servers) + (gnus-server-open-all-servers) + (gnus-server-exit) + (message "Restarting all servers... done")) + +;;;; delayed expiry +(defvar jao-gnus--expire-every 50) +(defvar jao-gnus--get-count (1+ jao-gnus--expire-every)) + +(defun jao-gnus-get-new-news (&optional arg) + (interactive "p") + (when (and jao-gnus--expire-every + (> jao-gnus--get-count jao-gnus--expire-every)) + (when jao-gnus-use-pm-imap (gnus-group-catchup "nnimap:pm/spam" t)) + (gnus-group-expire-all-groups) + (setq jao-gnus--get-count 0)) + (setq jao-gnus--get-count (1+ jao-gnus--get-count)) + (gnus-group-get-new-news (max (if (= 1 jao-gnus--get-count) 4 3) + (or arg 0)))) + +(define-key gnus-group-mode-map "g" 'jao-gnus-get-new-news) +(define-key gnus-group-mode-map "\C-x\C-s" #'gnus-group-save-newsrc) + +(defun jao-gnus--first-group () + (when (derived-mode-p 'gnus-group-mode) + (gnus-group-first-unread-group))) + +(with-eval-after-load "jao-afio" + (add-hook 'jao-afio-switch-hook #'jao-gnus--first-group)) diff --git a/attic/net/jao-notmuch-gnus.el b/attic/net/jao-notmuch-gnus.el index e18c5a1..1576964 100644 --- a/attic/net/jao-notmuch-gnus.el +++ b/attic/net/jao-notmuch-gnus.el @@ -28,7 +28,6 @@ (require 'ol-gnus) (require 'notmuch-show) - ;;; Tagging in notmuch from Gnus buffers (defun jao-notmuch-gnus--notmuch-id (id) @@ -100,8 +99,16 @@ (add-hook 'gnus-summary-article-move-hook #'jao-notmuch-gnus-tag-on-move) (add-hook 'gnus-summary-article-expire-hook #'jao-notmuch-gnus-tag-on-move)) - -;;;; Displaying search results in Gnus +;;; Gnus search using notmuch + +(add-to-list 'gnus-search-expandable-keys "list") + +(cl-defmethod gnus-search-transform-expression ((engine gnus-search-notmuch) + (expr (head list))) + (format "List:%s" (gnus-search-transform-expression engine (cdr expr)))) + + +;;; Displaying search results in Gnus (defvar jao-notmuch-gnus-server "nnml" "Name of the target Gnus server, e.g. nnml+mail.") @@ -164,8 +171,14 @@ Example: (org-gnus-follow-link group msg-id) (message "Couldn't get relevant infos for switching to Gnus.")))) - -;;;; Org links +(defun jao-notmuch-gnus-engine (prefix config) + (let ((prefix (file-name-as-directory (expand-file-name prefix "~"))) + (config (expand-file-name config gnus-home-directory))) + `(gnus-search-engine gnus-search-notmuch + (remove-prefix ,prefix) + (config-file ,config)))) + +;;; Org links (defun jao-notmuch-gnus--fname (id) (let ((cmd (format "notmuch search --output=files id:%s" id))) (car (split-string (shell-command-to-string cmd))))) @@ -193,8 +206,7 @@ Example: (org-link-set-parameters "gnus" :store #'ignore) (org-link-set-parameters "notmuch" :store #'ignore) - -;;;; consult-notmuch +;;; consult-notmuch (with-eval-after-load "consult-notmuch" (defun jao-notmuch-gnus--open-candidate (candidate) @@ -209,5 +221,6 @@ Example: (consult-customize jao-gnus-consult-notmuch :preview-key 'any)) +;;; . (provide 'jao-notmuch-gnus) ;;; jao-notmuch-gnus.el ends here diff --git a/custom/jao-custom-notmuch.el b/custom/jao-custom-notmuch.el index 5673242..8c4146a 100644 --- a/custom/jao-custom-notmuch.el +++ b/custom/jao-custom-notmuch.el @@ -644,6 +644,22 @@ (with-eval-after-load "notmuch-hello" (define-key notmuch-hello-mode-map "f" #'jao-consult-notmuch-folder)) +;;; recoll +(defun jao-notmuch-open-file (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-notmuch-open-file)) + +(with-eval-after-load "consult-recoll" + (add-to-list 'consult-recoll-open-fns + ("message/rfc822" . jao-notmuch-open-file))) ;;; link hint (with-eval-after-load "link-hint" diff --git a/init.el b/init.el index 9b8fed3..c558d7f 100644 --- a/init.el +++ b/init.el @@ -941,18 +941,6 @@ (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") @@ -985,7 +973,6 @@ (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) @@ -1847,9 +1834,9 @@ ;; (transient-get-suffix 'jao-transient-pdf-view '(0 -1)) ;;; Email -(setq jao-afio-mail-function 'notmuch) +(setq jao-afio-mail-function 'gnus) (require 'jao-custom-email) -(require 'jao-custom-notmuch) +;; (require 'jao-custom-notmuch) ;;; Shells and terms ;;;; shell modes -- cgit v1.2.3