summaryrefslogtreecommitdiffhomepage
path: root/gnus.org
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-05-10 00:34:46 +0100
committerjao <jao@gnu.org>2021-05-10 00:35:05 +0100
commit45d0402daf089e825aa08b85bdab77e1a95f22c5 (patch)
treef7fd08b69d69def9677e418649c7857854c4156b /gnus.org
parentc0c462c65b49ca1bde69cfd6e41d5bd66eb10ed8 (diff)
downloadelibs-45d0402daf089e825aa08b85bdab77e1a95f22c5.tar.gz
elibs-45d0402daf089e825aa08b85bdab77e1a95f22c5.tar.bz2
gnus minibuffer notifications
Diffstat (limited to 'gnus.org')
-rw-r--r--gnus.org86
1 files changed, 63 insertions, 23 deletions
diff --git a/gnus.org b/gnus.org
index 5631aec..6ff23d3 100644
--- a/gnus.org
+++ b/gnus.org
@@ -36,18 +36,13 @@
#+end_src
* Directories
#+begin_src emacs-lisp
- (setq gnus-home-directory "~/.emacs.d/gnus"
- gnus-directory gnus-home-directory)
-
(defun jao-gnus-dir (dir)
(expand-file-name dir gnus-home-directory))
(setq smtpmail-queue-dir (jao-gnus-dir "Mail/queued-mail/"))
- (with-eval-after-load "gnus"
- (setq mail-source-directory (jao-gnus-dir "Mail/")
- message-auto-save-directory (jao-gnus-dir "Mail/drafts/")
- message-directory (jao-gnus-dir "Mail/")))
+ (setq mail-source-directory (jao-gnus-dir "Mail/")
+ message-directory (jao-gnus-dir "Mail/"))
(setq gnus-default-directory (expand-file-name "~")
gnus-startup-file (jao-gnus-dir "newsrc")
@@ -111,10 +106,7 @@
(article 100)
,side-bar)))))
- (defun jao-gnus--summary-done ()
- (save-window-excursion (org-agenda-list)))
- (add-hook 'gnus-summary-prepared-hook #'jao-gnus--summary-done)
#+END_SRC
*** No blue icon
#+begin_src emacs-lisp
@@ -210,15 +202,12 @@
slash:comments
slash:description))
#+end_src
-* Agents, demons, synchronicity
- #+BEGIN_SRC emacs-lisp
- ;; gnus agent(s) and demons
- ;; (setq gnus-agent nil)
+* Demons and notifications
+ #+begin_src emacs-lisp
(setq mail-user-agent 'gnus-user-agent)
+
(require 'gnus-demon)
- (when (featurep 'gnus-desktop-notify)
- (gnus-desktop-notify-mode 1)
- (gnus-demon-add-scanmail))
+ (gnus-demon-add-rescan)
;; synchronicity
(setq gnus-asynchronous t)
@@ -228,8 +217,58 @@
(setq gnus-save-killed-list nil)
(setq gnus-check-new-newsgroups nil)
- (setq gnus-gcc-mark-as-read t)
- #+END_SRC
+ (defvar jao-gnus-tracked-groups
+ '(("^nnimap:\\(bigml\\|jao\\)" "" default)
+ ("nnimap:bigml/bugs" "b" jao-themes-error)
+ ("nnimap:bigml/support" "S" default)
+ ("nnimap:jao/inbox" "I" default)
+ ("nnimap:bigml" "W" jao-themes-dimm)
+ ("nnimap:jao" "J" jao-themes-dimm)
+ ("nnimap:feeds" "F" jao-themes-dimm)
+ ("^gmane" "N" default)))
+
+ (defun jao-gnus--unread-counts ()
+ (seq-reduce (lambda (r g)
+ (let ((n (gnus-group-unread (car g))))
+ (if (and n (> n 0)) (cons (cons (car g) n) r) 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))
+ (save-window-excursion (jao-minibuffer-refresh)))
+
+ (add-hook 'gnus-after-getting-new-news-hook #'jao-gnus--notify)
+ (add-hook 'gnus-started-hook #'jao-gnus--notify)
+
+ (defun jao-gnus--summary-done ()
+ (let ((inhibit-message t)
+ (message-log-max nil))
+ (jao-gnus--notify)
+ (save-window-excursion (org-agenda-list))))
+
+ (add-hook 'gnus-summary-exit-hook #'jao-gnus--summary-done)
+
+ (with-eval-after-load "jao-minibuffer"
+ (jao-minibuffer-add-variable 'jao-gnus--notify-strs -20))
+
+ #+end_src
* Delayed messages
#+BEGIN_SRC emacs-lisp
;;; delayed messages (C-cC-j in message buffer)
@@ -335,7 +374,7 @@
(define-key gnus-group-mode-map "Z" #'jao-gnus-restart-servers)
- (define-key gnus-group-mode-map "Gg"#'consult-notmuch)
+ (define-key gnus-group-mode-map "Gg" #'consult-notmuch)
#+END_SRC
* Group parameters
#+begin_src emacs-lisp
@@ -432,7 +471,7 @@
(w (- (window-width) d)))
(setq gnus-summary-line-format (format jao-gnus--summary-line-fmt w))))
- (add-hook 'gnus-group-prepare-hook 'jao-gnus--set-summary-line)
+ (add-hook 'gnus-select-group-hook 'jao-gnus--set-summary-line)
(add-to-list 'nnmail-extra-headers 'Cc)
(add-to-list 'nnmail-extra-headers 'BCc)
@@ -559,8 +598,9 @@
#+end_src
* Article buffer
*** Config, headers
- #+BEGIN_SRC emacs-lisp
+ #+begin_src emacs-lisp
(setq mail-source-delete-incoming t)
+ (setq gnus-gcc-mark-as-read t)
(setq gnus-treat-display-smileys nil)
(setq gnus-treat-fill-long-lines nil)
(setq gnus-treat-fill-article nil)
@@ -576,7 +616,7 @@
(concat
gnus-visible-headers
"\\|^X-Newsreader:\\|^X-Mailer:\\|User-Agent:\\|X-User-Agent:")))
- #+END_SRC
+ #+end_src
*** HTML email
#+BEGIN_SRC emacs-lisp
(setq gnus-button-url 'browse-url-generic