diff options
Diffstat (limited to 'custom/jao-custom-gnus.el')
| -rw-r--r-- | custom/jao-custom-gnus.el | 87 | 
1 files changed, 28 insertions, 59 deletions
| diff --git a/custom/jao-custom-gnus.el b/custom/jao-custom-gnus.el index 597ef85..7483e39 100644 --- a/custom/jao-custom-gnus.el +++ b/custom/jao-custom-gnus.el @@ -87,8 +87,7 @@                     ,side-bar)))))  (defun jao-gnus-use-two-panes () -  (let ((wide-len jao-gnus-wide-width) -        (groups-len jao-gnus-groups-width) +  (let ((groups-len jao-gnus-groups-width)          (summary-len (- jao-gnus-wide-width jao-gnus-groups-width))          (msg-edit '(horizontal 1.0                                 (message 1.0 point) @@ -123,9 +122,7 @@      (gnus-add-configuration `(reply-yank ,msg-edit))      (gnus-add-configuration -     `(reply (horizontal 1.0 -                         (message ,(- wide-len 100) point) -                         (article 1.0)))))) +     `(reply (horizontal 1.0 (message 0.5 point) (article 1.0))))))  (if jao-gnus-use-three-panes      (jao-gnus-use-three-panes) @@ -659,10 +656,12 @@  (defun jao-gnus-add-demon ()    (interactive) +  (message "Adding scan demon for Gnus...")    (gnus-demon-add-handler 'jao-gnus--scan 5 1))  (defun jao-gnus-remove-demon ()    (interactive) +  (message "Removing scan demon for Gnus...")    (gnus-demon-remove-handler 'jao-gnus--scan))  (jao-gnus-add-demon) @@ -675,64 +674,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" | 
