summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2025-10-28 02:04:30 +0000
committerjao <jao@gnu.org>2025-10-28 02:04:30 +0000
commitbdfcb0c1119d4dee5d8fdff9f3c75ee5cb0ebe80 (patch)
treeeeff30f456e39aaa0ca6ff7a0fc16a74d13063f1
parent9196819facf2d6eff2d3142bed07139427d1427e (diff)
downloadelibs-bdfcb0c1119d4dee5d8fdff9f3c75ee5cb0ebe80.tar.gz
elibs-bdfcb0c1119d4dee5d8fdff9f3c75ee5cb0ebe80.tar.bz2
simpler, topic-based gnus notifications
-rw-r--r--attic/elisp/misc.el50
-rw-r--r--custom/jao-custom-gnus.el78
2 files changed, 74 insertions, 54 deletions
diff --git a/attic/elisp/misc.el b/attic/elisp/misc.el
index 5021465..6c295d7 100644
--- a/attic/elisp/misc.el
+++ b/attic/elisp/misc.el
@@ -1297,3 +1297,53 @@ It should be the title of the web page as returned by `rdrview'"
(add-to-list 'auto-mode-alist '("inbox\\.org\\'" . jao-org-inbox-mode))
(add-hook 'org-agenda-finalize-hook #'org-modern-agenda))
+
+;;; Gnus notify
+
+(defun jao-gnus--notify-strs ()
+ (let* ((all (jao-gnus--unread-counts))
+ (counts (cdr all))
+ (labels (seq-keep (lambda (args)
+ (apply 'jao-gnus--unread-label counts args))
+ jao-gnus-tracked-groups)))
+ (jao-when-darwin (jao-gnus--xbar-echo labels))
+ labels))
+
+(defvar jao-gnus-tracked-groups
+ (let ((feeds (thread-first
+ (directory-files mail-source-directory nil "feeds\\.[^e]")
+ (seq-difference
+ '("feeds.trove" "feeds.emacs" "feeds.emacs-devel")))))
+ `(("nnml:jao\\.bigml" "B" jao-themes-f00)
+ ("nnml:jao\\.\\(inbox\\|trove\\)" "I" jao-themes-f01)
+ ("nnml:jao.write" "W" jao-themes-warning)
+ ("nnml:jao.[^ithwb]" "J" jao-themes-dimm)
+ ("nnml:jao.hacking" "H" jao-themes-dimm)
+ ;; (,(format "^nnml:%s" (regexp-opt feeds)) "F" jao-themes-dimm)
+ ;; ("feeds\\.emacs" "E" jao-themes-dimm)
+ ("nnml:feeds\\." "F" jao-themes-dimm)
+ ("nnml:local" "l" jao-themes-dimm)
+ ("nnrss:.*" "R" jao-themes-dimm)
+ ("^\\(gwene\\|gmane\\)\\." "N" 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))
+ (cons (+ n (car r))
+ (cons (cons (car g) n) (cdr r)))
+ r)))
+ gnus-newsrc-alist
+ '(0)))
+
+(defun jao-gnus-unread-count ()
+ (seq-reduce (lambda (c g) (+ c (or (gnus-group-unread (car g)) 0)))
+ gnus-newsrc-alist
+ 0))
+
+(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))))
diff --git a/custom/jao-custom-gnus.el b/custom/jao-custom-gnus.el
index 597ef85..ff7390f 100644
--- a/custom/jao-custom-gnus.el
+++ b/custom/jao-custom-gnus.el
@@ -675,64 +675,34 @@
;;; 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" "feeds.emacs" "feeds.emacs-devel")))))
- `(("nnml:jao\\.bigml" "B" jao-themes-f00)
- ("nnml:jao\\.\\(inbox\\|trove\\)" "I" jao-themes-f01)
- ("nnml:jao.write" "W" jao-themes-warning)
- ("nnml:jao.[^ithwb]" "J" jao-themes-dimm)
- ("nnml:jao.hacking" "H" jao-themes-dimm)
- ;; (,(format "^nnml:%s" (regexp-opt feeds)) "F" jao-themes-dimm)
- ;; ("feeds\\.emacs" "E" jao-themes-dimm)
- ("nnml:feeds\\." "F" jao-themes-dimm)
- ("nnml:local" "l" jao-themes-dimm)
- ("nnrss:.*" "R" jao-themes-dimm)
- ("^\\(gwene\\|gmane\\)\\." "N" 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))
- (cons (+ n (car r))
- (cons (cons (car g) n) (cdr r)))
- r)))
- gnus-newsrc-alist
- '(0)))
-
-(defun jao-gnus-unread-count ()
- (seq-reduce (lambda (c g) (+ c (or (gnus-group-unread (car g)) 0)))
- gnus-newsrc-alist
- 0))
-
-(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--xbar-echo (labels)
- (jao-shell-exec
- (let* ((ls (mapconcat (lambda (x) (plist-get x :propertize)) labels " "))
- (m (when ls (format "%s | color=#8b3626 | size=11" ls))))
- (format "echo '%s' >/tmp/xbar" (or m " ")))))
-
-(defun jao-gnus--notify-strs ()
- (let* ((all (jao-gnus--unread-counts))
- (counts (cdr all))
- (labels (seq-keep (lambda (args)
- (apply 'jao-gnus--unread-label counts args))
- jao-gnus-tracked-groups)))
- (jao-when-darwin (jao-gnus--xbar-echo labels))
- labels))
+(defun jao-gnus--xbar-echo ()
+ (let* ((total (cdr (assoc "Gnus" gnus-topic-unreads)))
+ (jao (cdr (assoc "jao" gnus-topic-unreads)))
+ (str (concat (when (> total 0) (format "%d" total))
+ " "
+ (when (> jao 0) (format "J%d" jao)))))
+ (jao-shell-exec
+ (format "echo '%s | color=#8b3626 | size=11' >/tmp/xbar" str))))
+
+(defvar jao-gnus-group-notifications
+ '(("Gnus" "" jao-themes-dimm)
+ ("jao" "J" jao-themes-warning)
+ ("news" "N" jao-themes-dimm)
+ ("prog" "P" jao-themes-dimm)
+ ("sci" "S" jao-themes-dimm)))
+
+(defun jao-gnus--notify-group-str (p)
+ (let* ((n (cdr p))
+ (f (cdr (assoc (car p) jao-gnus-group-notifications))))
+ (when (and f (> n 0))
+ `(:propertize ,(format "%s%d " (car f) n) face ,(cadr f)))))
(defun jao-gnus--notify ()
- (setq jao-gnus--notify-strs (jao-gnus--notify-strs))
+ (setq jao-gnus--notify-strs
+ (seq-keep 'jao-gnus--notify-group-str gnus-topic-unreads))
+ (jao-when-darwin (jao-gnus--xbar-echo))
(jao-minibuffer-refresh))
(with-eval-after-load "jao-minibuffer"