summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--custom/jao-custom-gnus.el150
1 files changed, 80 insertions, 70 deletions
diff --git a/custom/jao-custom-gnus.el b/custom/jao-custom-gnus.el
index 9b82c74..2d074b5 100644
--- a/custom/jao-custom-gnus.el
+++ b/custom/jao-custom-gnus.el
@@ -287,74 +287,6 @@
(add-to-list 'gnus-secondary-select-methods
'(nnimap "gandi" (nnimap-address "mail.gandi.net"))))
-;;; Demons and notifications
-;;;; minibuffer notifications
-(defvar jao-gnus-tracked-groups
- (let ((feeds (thread-first
- (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:jao.[^ist]" "J" jao-themes-dimm)
- (,(format "^nnml:%s" (regexp-opt feeds)) "F" jao-themes-dimm)
- ("feeds\\.e" "E" jao-themes-dimm)
- ("nnml:local" "l" jao-themes-dimm))))
-
-(defun jao-gnus--unread-counts ()
- (seq-reduce (lambda (r g)
- (let ((n (gnus-group-unread (car g))))
- (if (and (numberp n) (> n 0))
- (prog1 (cons (cons (car g) n) r)
- (gnus-message 7 "%s in %s" n g))
- r)))
- gnus-newsrc-alist
- ()))
-
-(defun jao-gnus--unread-label (counts rx label face)
- (let ((n (seq-reduce (lambda (n c)
- (if (string-match-p rx (car c)) (+ n (cdr c)) n))
- counts
- 0)))
- (when (> n 0) `(:propertize ,(format "%s%d " label n) face ,face))))
-
-(defvar jao-gnus--notify-strs ())
-
-(defun jao-gnus--notify-strs ()
- (let ((counts (jao-gnus--unread-counts)))
- (seq-filter #'identity
- (seq-map (lambda (args)
- (apply 'jao-gnus--unread-label counts args))
- jao-gnus-tracked-groups))))
-
-(defun jao-gnus--notify ()
- (setq jao-gnus--notify-strs (jao-gnus--notify-strs))
- (jao-minibuffer-refresh))
-
-(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)
-
-;;;; 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)
-
-(require 'gnus-demon)
-(gnus-demon-add-handler 'gnus-demon-scan-news 5 1)
-;; (gnus-demon-remove-handler 'gnus-demon-scan-news)
-
-;;;; 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"
@@ -412,8 +344,12 @@
(add-to-list 'nnmail-extra-headers 'Cc)
(add-to-list 'nnmail-extra-headers 'BCc)
-(add-to-list 'gnus-extra-headers 'Cc)
-(add-to-list 'gnus-extra-headers 'BCc)
+
+(use-package gnus-sum
+ :config
+ (add-to-list 'gnus-extra-headers 'Cc)
+ (add-to-list 'gnus-extra-headers 'BCc))
+
(defun gnus-user-format-function-j (headers)
(let ((to (gnus-extra-header 'To headers)))
@@ -660,6 +596,80 @@
'(setq message-draft-headers (remove 'Date message-draft-headers)))
;;; Add-ons
+;;;; notifications
+;;;;; minibuffer
+(defvar jao-gnus-tracked-groups
+ (let ((feeds (thread-first
+ (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:jao.[^ist]" "J" jao-themes-dimm)
+ (,(format "^nnml:%s" (regexp-opt feeds)) "F" jao-themes-dimm)
+ ("feeds\\.e" "E" jao-themes-dimm)
+ ("nnml:local" "l" jao-themes-dimm))))
+
+(defun jao-gnus--unread-counts ()
+ (seq-reduce (lambda (r g)
+ (let ((n (gnus-group-unread (car g))))
+ (if (and (numberp n) (> n 0))
+ (prog1 (cons (cons (car g) n) r)
+ (gnus-message 7 "%s in %s" n g))
+ r)))
+ gnus-newsrc-alist
+ ()))
+
+(defun jao-gnus--unread-label (counts rx label face)
+ (let ((n (seq-reduce (lambda (n c)
+ (if (string-match-p rx (car c)) (+ n (cdr c)) n))
+ counts
+ 0)))
+ (when (> n 0) `(:propertize ,(format "%s%d " label n) face ,face))))
+
+(defvar jao-gnus--notify-strs ())
+
+(defun jao-gnus--notify-strs ()
+ (let ((counts (jao-gnus--unread-counts)))
+ (seq-filter #'identity
+ (seq-map (lambda (args)
+ (apply 'jao-gnus--unread-label counts args))
+ jao-gnus-tracked-groups))))
+
+(defun jao-gnus--notify ()
+ (setq jao-gnus--notify-strs (jao-gnus--notify-strs))
+ (jao-minibuffer-refresh))
+
+(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)
+
+;;;;; daemon config
+(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)
+
+(require 'gnus-demon)
+
+(defun jao-gnus--scan ()
+ (let ((inhibit-message t))
+ (gnus-demon-scan-news)
+ (jao-gnus--notify)))
+
+(gnus-demon-add-handler 'jao-gnus--scan 5 1)
+
+;;;;; agenda updates
+(add-hook 'gnus-summary-exit-hook #'org-agenda-list)
+
+
;;;; open mail file in gnus
(defun jao-gnus-file-to-group (file &optional maildir newsdir m-server n-server)
"Compute the Gnus group name from the given file name.