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 ++++++++++++++++++------- 2 files changed, 64 insertions(+), 10 deletions(-) (limited to 'attic') 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 -- cgit v1.2.3