diff options
Diffstat (limited to 'attic/elisp')
| -rw-r--r-- | attic/elisp/misc.el | 50 | 
1 files changed, 50 insertions, 0 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)))) | 
