From cad941cca575d0f38c9668e3f5c69fc33dd3b24d Mon Sep 17 00:00:00 2001 From: jao Date: Thu, 6 Oct 2022 06:23:42 +0100 Subject: gnus adjustments --- custom/jao-custom-gnus.el | 173 +++++++++++++++++++++------------------------- 1 file changed, 79 insertions(+), 94 deletions(-) (limited to 'custom/jao-custom-gnus.el') diff --git a/custom/jao-custom-gnus.el b/custom/jao-custom-gnus.el index 6b1fd4a..0a015bc 100644 --- a/custom/jao-custom-gnus.el +++ b/custom/jao-custom-gnus.el @@ -14,24 +14,6 @@ ;; close gnus when closing emacs, but ask when exiting (setq gnus-interactive-exit t) -(defun jao-gnus-started-hook () - (add-hook 'before-kill-emacs-hook 'gnus-group-exit)) - -(add-hook 'gnus-started-hook 'jao-gnus-started-hook) - -(defun jao-gnus-after-exiting-hook () - (remove-hook 'before-kill-emacs-hook 'gnus-group-exit)) - -(add-hook 'gnus-after-exiting-gnus-hook 'jao-gnus-after-exiting-hook) - -;; define a wrapper around the save-buffers-kill-emacs -;; to run the new hook before: -(defadvice save-buffers-kill-emacs - (before my-save-buffers-kill-emacs activate) - "Install hook when emacs exits before emacs asks to save this and that." - (run-hooks 'before-kill-emacs-hook)) -;; Startup and kill:1 ends here - ;;; Directories (defun jao-gnus-dir (dir) (expand-file-name dir gnus-home-directory)) @@ -167,6 +149,21 @@ (setq nnheader-read-timeout 0.02 gnus-save-newsrc-file nil) ; .newsrc only needed by other newsreaders +;; leafnode articles group parameters +(defvar jao-gnus-image-groups '("xkcd")) + +(defvar jao-gnus-leafnode-group-params + `((,(format "gwene\\..*%s.*" (regexp-opt jao-gnus-image-groups)) + (mm-html-inhibit-images nil) + (mm-html-blocked-images nil)) + ("\\(gmane\\|gwene\\)\\..*" + (jao-gnus--archiving-group "nnml:feeds.trove") + (posting-style (address "jao@gnu.org"))))) + +(when jao-gnus-use-leafnode + (dolist (p jao-gnus-leafnode-group-params) + (add-to-list 'gnus-parameters p t))) + ;;; Mail ;;;; nnmail (setq nnmail-treat-duplicates 'delete @@ -182,9 +179,11 @@ ;;;; nnml (setq mail-sources - (when (and jao-gnus-use-nnml (not jao-notmuch-enabled)) - (mapcar (lambda (d) `(maildir :path ,(concat d "/"))) - (directory-files "~/var/mail" t "^[^\\.]"))) + (when jao-gnus-use-nnml + (let ((fix (regexp-opt '("feeds" "local" "trash" "spam")))) + (mapcar (lambda (d) `(maildir :path ,(concat d "/"))) + (directory-files "~/var/mail/" t + (concat "[^\\.]+\\.[^\\.]+\\|" fix))))) gnus-message-archive-group nil nnml-get-new-mail t nnml-directory message-directory) @@ -206,16 +205,17 @@ ("Gcc" "nnml:jao.trove")) (jao-gnus--trash-group "nnml:trash") (jao-gnus--spam-group "nnml:spam") - (jao-gnus--archiving-group "nnml:jao.trove")) + (jao-gnus--archiving-group "nnml:jao.trove") + (gcc-self . t)) ("nnml:jao\\.hacking" - (posting-style ("Bcc" "proton@jao.io") + (posting-style ("Bcc" "hacking@jao.io") ("Gcc" "nnml:jao.hacking") - ("address" "jao@gnu.org")) - (gcc-self . t) - (auto-expire . nil) - (total-expire . nil) - (expiry-target . nil) - (expiry-wait . nil)) + ("address" "jao@gnu.org"))) + ("nnml:jao\\.drivel" + (auto-expire . t) + (total-expire . t) + (expiry-wait . 3) + (expiry-target . delete)) ("nnml:bigml\\..*" (gcc-self . nil) (auto-expire . t) @@ -226,12 +226,18 @@ (jao-gnus--trash-group "nnml:trash") (jao-gnus--spam-group "nnml:spam") (jao-gnus--archiving-group "nnml:bigml.trove")) - ("nnml:bigml\\.\\(inbox\\|support\\)" + ("nnml:bigml\\.inbox" (gcc-self . t) (auto-expire . t) (total-expire . t) (expiry-wait . 7) (expiry-target . "nnml:bigml.trove")) + ("nnml:bigml\\.support" + (gcc-self . t) + (auto-expire . t) + (total-expire . t) + (expiry-wait . 7) + (expiry-target . delete)) ("nnml:bigml\\.alba" (gcc-self . t) (auto-expire . nil) @@ -243,11 +249,6 @@ (total-expire . t) (expiry-target . delete) (expiry-wait . 365)) - ("nnml:jao\\.drivel" - (auto-expire . t) - (total-expire . t) - (expiry-wait . 3) - (expiry-target . delete)) ("nnml:feeds\\.\\(.*\\)" (auto-expire . t) (total-expire . t) @@ -255,8 +256,8 @@ (expiry-target . delete) (comment . "feeds.\\1") (jao-gnus--archiving-group "nnml:feeds.trove")) - ("^nnml:feeds\\.\\(news\\)$" (expiry-wait . 2)) - ("nnml:feeds\\.\\(trove\\|lobsters\\|philosophy\\)" + ("nnml:feeds\\.\\(news\\)$" (expiry-wait . 2)) + ("nnml:feeds\\.trove" (auto-expire . nil) (total-expire . nil)) ("nnml:feeds\\.fun" @@ -267,21 +268,6 @@ (dolist (p jao-gnus-nnml-group-params) (add-to-list 'gnus-parameters p t))) -;; leafnode articles archiving -(defvar jao-gnus-image-groups '("xkcd")) - -(defvar jao-gnus-leafnode-group-params - `((,(format "gwene\\..*%s.*" (regexp-opt jao-gnus-image-groups)) - (mm-html-inhibit-images nil) - (mm-html-blocked-images nil)) - ("\\(gmane\\|gwene\\)\\..*" - (jao-gnus--archiving-group "nnml:feeds.trove") - (posting-style (address "jao@gnu.org"))))) - -(when jao-gnus-use-leafnode - (dolist (p jao-gnus-leafnode-group-params) - (add-to-list 'gnus-parameters p t))) - ;;;; imap (setq nnimap-quirks nil) @@ -372,51 +358,18 @@ '(setq message-draft-headers (remove 'Date message-draft-headers))) ;;; Groups buffer -;;;; customization -;; (setq gnus-group-line-format " %m%S%p%P:%~(pad-right 35)c %3y %B\n") -;; (setq gnus-group-line-format " %m%S%p%3y%P%* %~(pad-right 30)C %B\n") -(setq gnus-group-line-format " %m%S%p%3y%P%* %~(pad-right 30)G %B\n") - -(setq gnus-topic-line-format "%i[ %(%{%n%}%) -- %A ]%v\n" +(setq gnus-group-line-format + " %m%S%p%3y%P%* %~(pad-right 30)G %B\n" + ;; " %m%S%p%P:%~(pad-right 35)c %3y %B\n" + ;; " %m%S%p%3y%P%* %~(pad-right 30)C %B\n" + gnus-topic-line-format "%i[ %(%{%n%}%) -- %A ]%v\n" gnus-group-uncollapsed-levels 2 - gnus-auto-select-subject 'unread) -(setq-default gnus-large-newsgroup 2000) + gnus-auto-select-subject 'unread + gnus-large-newsgroup 2000) (add-hook 'gnus-select-group-hook 'gnus-group-set-timestamp) (add-hook 'gnus-group-mode-hook 'gnus-topic-mode) -;;;; 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. - IN: /home/jao/.emacs.d/gnus/Mail/jao.trove/32, /home/jao/.emacs.d/gnus/Mail/ - OUT: nnml:jao.trove " - (let* ((maildir (or maildir message-directory)) - (newsdir (or newsdir jao-gnus-leafnode-spool)) - (m-server (or m-server "nnml")) - (n-server (or n-server "nntp+localhost")) - (nntp (and newsdir (string-match-p newsdir file))) - (g (directory-file-name (file-name-directory file))) - (g (replace-regexp-in-string (file-name-as-directory maildir) "" g)) - (g (replace-regexp-in-string (file-name-as-directory newsdir) "" g)) - (g (cond (nntp (concat n-server ":" g)) - ((file-name-directory g) - (replace-regexp-in-string "^\\([^/]+\\)/" - (concat m-server ":\\1/") - (file-name-directory g) t)) - (t (concat m-server ":" g)))) - (g (replace-regexp-in-string "/" "." g)) - (g (replace-regexp-in-string "[/.]$" "" g))) - (cond ((string-match ":$" g) (concat g "inbox")) - (nntp g) - (t (replace-regexp-in-string ":\\." ":" g))))) - -(defun jao-gnus-goto-file (filename &optional _page) - (let ((group (jao-gnus-file-to-group filename)) - (id (file-name-nondirectory filename))) - (if (and group id) - (org-gnus-follow-link group id) - (message "Couldn't get relevant info for switching to Gnus.")))) - ;;; Summary buffer ;;;; configuration (setq gnus-face-1 'jao-gnus-face-tree @@ -622,7 +575,8 @@ (setq gnus-button-url 'browse-url-generic gnus-inhibit-images t mm-discouraged-alternatives nil ;; '("text/html" "text/richtext") - mm-inline-large-images 'resize) + mm-inline-large-images 'resize + shr-width 130) (defvar-local jao-gnus--images nil) @@ -701,6 +655,38 @@ (jao-mpc-add-or-play-url url)))))) ;;; Add-ons +;;;; 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. + IN: /home/jao/.emacs.d/gnus/Mail/jao.trove/32, /home/jao/.emacs.d/gnus/Mail/ + OUT: nnml:jao.trove " + (let* ((maildir (or maildir message-directory)) + (newsdir (or newsdir jao-gnus-leafnode-spool)) + (m-server (or m-server "nnml")) + (n-server (or n-server "nntp+localhost")) + (nntp (and newsdir (string-match-p newsdir file))) + (g (directory-file-name (file-name-directory file))) + (g (replace-regexp-in-string (file-name-as-directory maildir) "" g)) + (g (replace-regexp-in-string (file-name-as-directory newsdir) "" g)) + (g (cond (nntp (concat n-server ":" g)) + ((file-name-directory g) + (replace-regexp-in-string "^\\([^/]+\\)/" + (concat m-server ":\\1/") + (file-name-directory g) t)) + (t (concat m-server ":" g)))) + (g (replace-regexp-in-string "/" "." g)) + (g (replace-regexp-in-string "[/.]$" "" g))) + (cond ((string-match ":$" g) (concat g "inbox")) + (nntp g) + (t (replace-regexp-in-string ":\\." ":" g))))) + +(defun jao-gnus-goto-file (filename &optional _page) + (let ((group (jao-gnus-file-to-group filename)) + (id (file-name-nondirectory filename))) + (if (and group id) + (org-gnus-follow-link group id) + (message "Couldn't get relevant info for switching to Gnus.")))) + ;;;; gnus-icalendar (require 'ol-gnus) (use-package gnus-icalendar @@ -739,4 +725,3 @@ (define-key gnus-summary-mode-map "e" 'jao-gnus-open-enclosure) (define-key gnus-summary-mode-map "\C-l" nil) (define-key gnus-group-mode-map (kbd "A") 'nil) -(define-key gnus-topic-mode-map (kbd "A") 'org-agenda-list) -- cgit v1.2.3