From 23e0ce59dd3b52e13bc3358db33f5bf4cc28a921 Mon Sep 17 00:00:00 2001 From: jao Date: Sat, 8 Oct 2022 02:13:49 +0100 Subject: mail tweaks --- custom/jao-custom-email.el | 12 ++++--- custom/jao-custom-gnus.el | 76 +++++++++++++++++++++++--------------------- custom/jao-custom-notmuch.el | 35 ++++++++++---------- 3 files changed, 66 insertions(+), 57 deletions(-) diff --git a/custom/jao-custom-email.el b/custom/jao-custom-email.el index e79e63d..a315c25 100644 --- a/custom/jao-custom-email.el +++ b/custom/jao-custom-email.el @@ -63,12 +63,14 @@ (,(regexp-quote "jao@gnu.org") . "hacking@jao.io"))) (defun jao-message-insert-bcc () - (let ((f (or (message-fetch-field "From") ""))) - (when-let (b (seq-some (lambda (x) (when (string-match-p (car x) f) (cdr x))) - jao-message--bcc-alist)) - (insert "Bcc: " b "\n")))) + (when jao-notmuch-enabled + (let ((f (or (message-fetch-field "From") ""))) + (when-let (b (seq-some (lambda (x) (when (string-match-p (car x) f) (cdr x))) + jao-message--bcc-alist)) + (insert "Bcc: " b "\n"))))) -(add-hook 'message-header-setup-hook #'jao-message-insert-bcc) +(when jao-notmuch-enabled + (add-hook 'message-header-setup-hook #'jao-message-insert-bcc)) ;;;; to->from (defvar jao-message-to-from nil) diff --git a/custom/jao-custom-gnus.el b/custom/jao-custom-gnus.el index f24d20a..d0ca3d4 100644 --- a/custom/jao-custom-gnus.el +++ b/custom/jao-custom-gnus.el @@ -47,6 +47,10 @@ gnus-tree-minimize-window nil) (when jao-gnus-use-three-panes + + ;; (dolist (m '(calendar-mode org-agenda-mode gnus-group-mode)) + ;; (add-to-list 'display-buffer-alist `((major-mode . ,m) (dedicated t)))) + (let ((side-bar '(vertical 1.0 ("inbox.org" 0.4) ("*Org Agenda*" 1.0) @@ -210,7 +214,7 @@ ("nnml:jao\\.hacking" (posting-style ("Bcc" "hacking@jao.io") ("Gcc" "nnml:jao.hacking") - ("address" "jao@gnu.org"))) + (address "jao@gnu.org"))) ("nnml:jao\\.drivel" (auto-expire . t) (total-expire . t) @@ -232,12 +236,6 @@ (total-expire . t) (expiry-wait . 7) (expiry-target . "nnml:bigml.trove")) - ("nnml:bigml\\.support" - (gcc-self . t) - (auto-expire . t) - (total-expire . t) - (expiry-wait . 7) - (expiry-target . delete)) ("nnml:bigml\\.alba" (gcc-self . t) (auto-expire . nil) @@ -250,6 +248,8 @@ (expiry-target . delete) (expiry-wait . 365)) ("nnml:feeds\\.\\(.*\\)" + (posting-style ("Gcc" "nnml:feeds.trove") + (address "jao@gnu.org")) (auto-expire . t) (total-expire . t) (expiry-wait . 7) @@ -287,26 +287,20 @@ '(nnimap "gandi" (nnimap-address "mail.gandi.net")))) ;;; Demons and notifications -(setq mail-user-agent 'gnus-user-agent) -(setq gnus-asynchronous t) -(setq gnus-use-article-prefetch nil) -(setq gnus-save-killed-list nil) -(setq gnus-check-new-newsgroups nil) - +;;;; minibuffer notifications (defvar jao-gnus-tracked-groups (let ((feeds (thread-first - (directory-files mail-source-directory nil "feeds") + (directory-files mail-source-directory nil "feeds\\.[^e]") (seq-difference '("feeds.trove"))))) - `(("nnml:bigml.inbox" "B" jao-themes-f00) - ("nnml:bigml.alba" "A" jao-themes-f00) - ("nnml:bigml.bugs" "b" jao-themes-error) - ("nnml:bigml.support" "S" default) - ("nnml:jao.inbox" "I" jao-themes-f01) - ("nnml:bigml.[^ibs]" "W" jao-themes-dimm) + `(("nnml:bigml\\.inbox" "B" jao-themes-f00) + ("nnml:bigml\\.alba" "A" jao-themes-f00) + ("nnml:bigml\\.bugs" "b" jao-themes-error) + ("nnml:bigml\\.support" "S" default) + ("nnml:jao\\.inbox" "I" jao-themes-f01) + ("nnml:bigml\\.[^ibs]" "W" jao-themes-dimm) ("nnml:jao.[^ist]" "J" jao-themes-dimm) (,(format "^nnml:%s" (regexp-opt feeds)) "F" jao-themes-dimm) - ("^gmane\\.[^e]" "G" jao-themes-dimm) - ("^gmane\\.e" "E" jao-themes-dimm) + ("feeds\\.e" "E" jao-themes-dimm) ("nnml:local" "l" jao-themes-dimm)))) (defun jao-gnus--unread-counts () @@ -339,25 +333,28 @@ (setq jao-gnus--notify-strs (jao-gnus--notify-strs)) (jao-minibuffer-refresh)) -(require 'gnus-demon) -(gnus-demon-add-handler 'gnus-demon-scan-news 5 1) -;; (gnus-demon-remove-handler 'gnus-demon-scan-news) +(with-eval-after-load "jao-minibuffer" + (jao-minibuffer-add-variable 'jao-gnus--notify-strs -20)) (add-hook 'gnus-started-hook #'jao-gnus--notify) (add-hook 'gnus-summary-exit-hook #'jao-gnus--notify) (add-hook 'gnus-after-getting-new-news-hook #'jao-gnus--notify) -(with-eval-after-load "jao-minibuffer" - (jao-minibuffer-add-variable 'jao-gnus--notify-strs -20)) +;;;; gnus daemon +(setq mail-user-agent 'gnus-user-agent) +(setq gnus-asynchronous t) +(setq gnus-use-article-prefetch nil) +(setq gnus-save-killed-list nil) +(setq gnus-check-new-newsgroups nil) -;; delayed messages -(require 'gnus-util) -(gnus-delay-initialize) -(setq gnus-delay-default-delay "3h") -(eval-after-load "message" - '(setq message-draft-headers (remove 'Date message-draft-headers))) +(require 'gnus-demon) +(gnus-demon-add-handler 'gnus-demon-scan-news 5 1) +;; (gnus-demon-remove-handler 'gnus-demon-scan-news) -;;; Groups buffer +;;;; agenda updates +(add-hook 'gnus-summary-exit-hook #'org-agenda-list) + +;;; Groups (setq gnus-group-line-format " %m%S%p%3y%P%* %~(pad-right 30)G %B\n" ;; " %m%S%p%P:%~(pad-right 35)c %3y %B\n" @@ -370,7 +367,7 @@ (add-hook 'gnus-select-group-hook 'gnus-group-set-timestamp) (add-hook 'gnus-group-mode-hook 'gnus-topic-mode) -;;; Summary buffer +;;; Summary ;;;; configuration (setq gnus-face-1 'jao-gnus-face-tree gnus-show-threads t @@ -548,7 +545,7 @@ (goto-char (point-max)) (org-capture nil "X")) -;;; Article buffer +;;; Article ;;;; config, headers (setq mail-source-delete-incoming t) (setq gnus-gcc-mark-as-read t) @@ -654,6 +651,13 @@ (when-let ((url (thing-at-point-url-at-point))) (jao-mpc-add-or-play-url url)))))) +;;;; delayed messages +(require 'gnus-util) +(gnus-delay-initialize) +(setq gnus-delay-default-delay "3h") +(eval-after-load "message" + '(setq message-draft-headers (remove 'Date message-draft-headers))) + ;;; Add-ons ;;;; open mail file in gnus (defun jao-gnus-file-to-group (file &optional maildir newsdir m-server n-server) diff --git a/custom/jao-custom-notmuch.el b/custom/jao-custom-notmuch.el index 27b8465..492da2d 100644 --- a/custom/jao-custom-notmuch.el +++ b/custom/jao-custom-notmuch.el @@ -193,7 +193,7 @@ (setq notmuch-archive-tags '("+trove" "-new" "-inbox") notmuch-show-mark-read-tags '("-new" "-unread") notmuch-tag-formats - (let ((d `(:foreground ,(face-attribute 'jao-themes-dimm :foreground))) + (let (;; (d `(:foreground ,(face-attribute 'jao-themes-dimm :foreground))) (e `(:foreground ,(face-attribute 'jao-themes-error :foreground)))) `(("unread") ("signed") @@ -273,7 +273,7 @@ (defun jao-notmuch-hello-first () (interactive) (let ((inhibit-message t)) - (beginning-of-buffer) + (goto-char (point-min)) (widget-forward 1))) (defun jao-notmuch-refresh-hello (&optional agenda) @@ -318,8 +318,11 @@ notmuch-show-logo nil notmuch-show-empty-saved-searches nil) - :hook ((notmuch-hello-refresh . jao-notmuch-notify) - (jao-afio-switch . jao-notmuch-refresh-hello)) + :hook ((notmuch-hello-refresh . jao-notmuch-notify)) + + :config + (when jao-notmuch-enabled + (add-hook 'jao-afio-switch-hook #'jao-notmuch-refresh-hello)) :bind (:map notmuch-hello-mode-map (("a" . jao-notmuch-refresh-agenda) @@ -474,14 +477,14 @@ (jao-notmuch-adjust-tree-fonts (when (string-prefix-p "Hack" jao-themes-default-face) "Source Code Pro"))) - (defun jao-notmuch-before-tree (&rest args) + (defun jao-notmuch-before-tree (&rest _args) (when (string= (buffer-name) "*notmuch-hello*") (split-window-right 40) (other-window 1))) (defvar jao-notmuch--visits 0) - (defun jao-notmuch-after-tree-quit (&optional both) + (defun jao-notmuch-after-tree-quit (&optional _both) (when (and (not (derived-mode-p 'notmuch-tree-mode 'notmuch-hello-mode)) (save-window-excursion (other-window -1) (derived-mode-p 'notmuch-hello-mode))) @@ -562,7 +565,7 @@ (jao-notmuch--add-tags '("+trove"))) (when (y-or-n-p "Flag message as todo? ") (jao-notmuch--add-tags '("+flagged"))) - (org-store-link-props :type "notmuch" + (org-link-store-props :type "notmuch" :link link :description description))) (notmuch-search-mode @@ -572,7 +575,7 @@ (subj (notmuch-search-find-subject)) (description (format "Mail: %s" subj))) (setq jao-org-notmuch-last-subject subj) - (org-store-link-props + (org-link-store-props :type "notmuch" :link link :description description))))) @@ -618,13 +621,13 @@ (defun jao-consult-notmuch-folder (&optional tree folder) (interactive "P") - (let ((folder (if folder - (file-name-as-directory folder) - (completing-read "Group: " - jao-mailbox-folders - nil nil nil - jao-consult-notmuch-history - "."))) + (let* ((folder (if folder + (file-name-as-directory folder) + (completing-read "Group: " + jao-mailbox-folders + nil nil nil + jao-consult-notmuch-history + "."))) (folder (replace-regexp-in-string "/\\(.\\)" ".\\1" folder)) (init (read-string "Initial query: ")) (init (format "folder:/%s/ %s" folder init))) @@ -633,7 +636,7 @@ (with-eval-after-load "notmuch-hello" (define-key notmuch-hello-mode-map "f" #'jao-consult-notmuch-folder)) ;;; recoll -(defun jao-notmuch-open-file (fname &optional page) +(defun jao-notmuch-open-file (fname &optional _page) (with-temp-buffer (insert-file-contents-literally fname) (goto-char (point-min)) -- cgit v1.2.3