Reorganize Gnus configuration to remove most byte-compiler warnings

This commit is contained in:
Daniel Borchmann 2023-10-28 18:13:47 +02:00
parent 7b3b0811a1
commit 2f2eac0b38
No known key found for this signature in database
GPG Key ID: 784AA8DF0CCDF625

298
init.el
View File

@ -342,6 +342,7 @@
(use-package dash (use-package dash
:defer nil :defer nil
:autoload (-difference)
:config (progn :config (progn
(global-dash-fontify-mode) (global-dash-fontify-mode)
(dash-register-info-lookup))) (dash-register-info-lookup)))
@ -1377,8 +1378,124 @@ point to the beginning of buffer first."
(format "Day of Death: [[bbdb:%s][%s (%s%s)]]" (format "Day of Death: [[bbdb:%s][%s (%s%s)]]"
name name years suffix))))))) name name years suffix)))))))
;; Gnus package configuration
(use-package gnus
:commands (gnus)
:config (progn
(require 'db-mail)
(with-demoted-errors "Setting up BBDB failed: %s"
(bbdb-initialize 'gnus 'message)
(bbdb-mua-auto-update-init 'message))
;; Ensure that whenever we compose new mail, it will use the correct
;; posting style. This is ensured by setting ARG of
;; `gnus-group-mail to 1 to let it query the user for a group.
(defadvice gnus-group-mail (before inhibit-no-argument activate)
(unless (ad-get-arg 0)
(ad-set-arg 0 1)))
(remove-hook 'gnus-mark-article-hook
'gnus-summary-mark-read-and-unread-as-read)
(add-hook 'gnus-mark-article-hook 'gnus-summary-mark-unread-as-read)
;; Quit Gnus gracefully when exiting Emacs
(add-hook 'kill-emacs-hook #'(lambda ()
(interactive)
(when (get-buffer "*Group*")
(gnus-group-exit))))
;; Dont quit summary buffer when pressing `q
(bind-key "q" #'gnus-summary-expand-window gnus-article-mode-map)
;; Show topics in group buffer
(add-hook 'gnus-group-mode-hook 'gnus-topic-mode)
;; We need to do some magic as otherwise the agent does not delete
;; articles from its .overview when we move them around. Thus we
;; mark articles as expireable when they have been moved to another
;; group.
(defadvice gnus-summary-move-article (around
no-cancel-mark
(&optional n to-newsgroup
select-method action)
activate)
(let ((articles (gnus-summary-work-articles n))
(return ad-do-it))
(when (or (null action)
(eq action 'move))
(dolist (article articles)
(gnus-summary-mark-article article gnus-expirable-mark)))
return))
;; Increase score of group after reading it
(add-hook 'gnus-summary-exit-hook
'gnus-summary-bubble-group)
;; Use Gnus registry; doing this too early conflicts with `gnus'
;; calling `gnus-shutdown', which in turn calls
;; `gnus-registry-clear', leaving us with an empty registry upon
;; startup. So let's call this initialization right before startup,
;; that should be fine.
(add-hook 'gnus-before-startup-hook
#'gnus-registry-initialize)
;; Automatic encryption if all necessary keys are present
(add-hook 'gnus-message-setup-hook
#'db/signencrypt-message-when-possible)
;; Do some pretty printing before saving the newsrc file
(add-hook 'gnus-save-quick-newsrc-hook
#'db/gnus-save-newsrc-with-whitespace-1)
;; Automatically scan for new news
(gnus-demon-add-handler 'db/gnus-demon-scan-news-on-level-2 5 5)
;; Automatically expire groups on idle
(gnus-demon-add-handler 'gnus-group-expire-all-groups 10 5)
;; Visit group under point and immediately close it; this updates
;; gnus registry as a side-effect
(bind-key "v u"
#'(lambda ()
(interactive)
(save-mark-and-excursion
(when (gnus-topic-select-group)
(gnus-summary-exit))))
gnus-group-mode-map)
;; Toggle visibility of News group
(bind-key "v c"
#'(lambda ()
(interactive)
(save-mark-and-excursion
(gnus-topic-jump-to-topic "News")
(gnus-topic-read-group)))
gnus-group-mode-map)
(bind-key "C-<return>" #'db/gnus-summary-open-Link gnus-summary-mode-map)
(bind-key "C-<return>" #'db/gnus-summary-open-Link gnus-article-mode-map)))
(use-package gnus-topic
:commands (gnus-topic-select-group
gnus-topic-jump-to-topic
gnus-topic-read-group))
(use-package gnus-demon
:autoload (gnus-demon-add-handler))
(use-package gnus-group
:commands (gnus-group-exit))
;; General Gnus configuration ;; General Gnus configuration
(use-package nntp)
(use-package nnml)
(use-package message)
(use-package gnus-msg)
(use-package gnus-async)
(setq gnus-init-file (expand-file-name "gnus.el" emacs-d) (setq gnus-init-file (expand-file-name "gnus.el" emacs-d)
gnus-home-directory (expand-file-name "~/.config/gnus-news") gnus-home-directory (expand-file-name "~/.config/gnus-news")
gnus-directory gnus-home-directory gnus-directory gnus-home-directory
@ -1402,46 +1519,17 @@ point to the beginning of buffer first."
gnus-check-new-newsgroups nil gnus-check-new-newsgroups nil
gnus-use-cache 'passive gnus-use-cache 'passive
gnus-read-active-file 'some gnus-read-active-file 'some
gnus-build-sparse-threads 'some
gnus-subscribe-newsgroup-method 'gnus-subscribe-killed gnus-subscribe-newsgroup-method 'gnus-subscribe-killed
gnus-group-list-inactive-groups t gnus-group-list-inactive-groups t
gnus-suppress-duplicates nil gnus-suppress-duplicates nil
gnus-large-newsgroup 500 gnus-large-newsgroup 500
nnmail-expiry-wait 7 nnmail-expiry-wait 7
nnmail-cache-accepted-message-ids t nnmail-cache-accepted-message-ids t
gnus-summary-next-group-on-exit nil
gnus-use-full-window nil gnus-use-full-window nil
gnus-always-force-window-configuration t gnus-always-force-window-configuration t
gnus-fetch-old-headers nil
gnus-select-method '(nnnil "") gnus-select-method '(nnnil "")
gnus-refer-article-method 'current gnus-refer-article-method 'current
gnus-visible-headers (regexp-opt '("From:"
"Newsgroups:"
"Subject:"
"Date:"
"Followup-To:"
"Reply-To:"
"Organization:"
"Summary:"
"Keywords:"
"Mail-Copies-To:"
"To:"
"Cc:"
"BCC:"
"X-Newsreader:"
"X-Mailer:"
"X-Sent:"
"Posted-To:"
"Mail-Copies-To:"
"Apparently-To:"
"Gnus-Warning:"
"Resent-From:"
"gpg-key-ID:"
"fingerprint:"
"X-Jabber-ID:"
"User-Agent:"))
message-citation-line-function message-citation-line-function
#'(lambda () #'(lambda ()
(when message-reply-headers (when message-reply-headers
@ -1452,7 +1540,13 @@ point to the beginning of buffer first."
;; Gnus Appearence ;; Gnus Appearence
(setq gnus-group-line-format "%S%p%P%5y(%2i):%B%(%s:%G%)\n" (use-package gnus-sum
:commands (gnus-summary-exit
gnus-summary-expand-window)
:init (setq gnus-group-line-format "%S%p%P%5y(%2i):%B%(%s:%G%)\n"
gnus-build-sparse-threads 'some
gnus-summary-next-group-on-exit nil
gnus-fetch-old-headers nil
gnus-auto-select-first nil gnus-auto-select-first nil
gnus-auto-select-next nil gnus-auto-select-next nil
gnus-summary-line-format "%U%O%R%6k %(%&user-date; %-13,13f %B%s%)\n" gnus-summary-line-format "%U%O%R%6k %(%&user-date; %-13,13f %B%s%)\n"
@ -1486,23 +1580,49 @@ point to the beginning of buffer first."
gnus-unread-mark ?✉ gnus-unread-mark ?✉
;; gnus-unseen-mark ?★ ;; gnus-unseen-mark ?★
;; gnus-ticked-mark ?⚑ ;; gnus-ticked-mark ?⚑
))
gnus-treat-hide-boring-headers 'head
gnus-treat-strip-multiple-blank-lines nil
gnus-treat-display-smileys t
gnus-treat-emphasize 'head
gnus-treat-unsplit-urls t)
(use-package gnus-art (use-package gnus-art
:init (setq gnus-ignored-mime-types '("text/x-vcard") :init (setq gnus-ignored-mime-types '("text/x-vcard")
gnus-inhibit-mime-unbuttonizing nil gnus-inhibit-mime-unbuttonizing nil
gnus-buttonized-mime-types '("multipart/signed" "multipart/encrypted") gnus-buttonized-mime-types '("multipart/signed" "multipart/encrypted")
gnus-inhibit-images t gnus-inhibit-images t
gnus-blocked-images ".*")) gnus-blocked-images ".*"
gnus-visible-headers (regexp-opt '("From:"
"Newsgroups:"
"Subject:"
"Date:"
"Followup-To:"
"Reply-To:"
"Organization:"
"Summary:"
"Keywords:"
"Mail-Copies-To:"
"To:"
"Cc:"
"BCC:"
"X-Newsreader:"
"X-Mailer:"
"X-Sent:"
"Posted-To:"
"Mail-Copies-To:"
"Apparently-To:"
"Gnus-Warning:"
"Resent-From:"
"gpg-key-ID:"
"fingerprint:"
"X-Jabber-ID:"
"User-Agent:"))
gnus-treat-hide-boring-headers 'head
gnus-treat-strip-multiple-blank-lines nil
gnus-treat-display-smileys t
gnus-treat-emphasize 'head
gnus-treat-unsplit-urls t))
;; Adaptive Scoring ;; Adaptive Scoring
(setq gnus-use-scoring t (use-package gnus-score
:init (setq gnus-use-scoring t
gnus-use-adaptive-scoring '(word line) gnus-use-adaptive-scoring '(word line)
gnus-summary-mark-below nil gnus-summary-mark-below nil
gnus-adaptive-word-length-limit 5 gnus-adaptive-word-length-limit 5
@ -1519,7 +1639,7 @@ point to the beginning of buffer first."
(gnus-ancient-mark) (gnus-ancient-mark)
(gnus-low-score-mark) (gnus-low-score-mark)
(gnus-catchup-mark (from -1) (subject -1))) (gnus-catchup-mark (from -1) (subject -1)))
gnus-summary-mark-below nil) gnus-summary-mark-below nil))
;; Gnus Registry ;; Gnus Registry
@ -1642,106 +1762,6 @@ point to the beginning of buffer first."
gnus-agent-synchronize-flags t gnus-agent-synchronize-flags t
gnus-agent-go-online t)) gnus-agent-go-online t))
;; Package configuration
(use-package gnus
:commands (gnus)
:config (progn
(require 'db-mail)
(with-demoted-errors "Setting up BBDB failed: %s"
(bbdb-initialize 'gnus 'message)
(bbdb-mua-auto-update-init 'message))
;; Ensure that whenever we compose new mail, it will use the correct
;; posting style. This is ensured by setting ARG of
;; `gnus-group-mail to 1 to let it query the user for a group.
(defadvice gnus-group-mail (before inhibit-no-argument activate)
(unless (ad-get-arg 0)
(ad-set-arg 0 1)))
(remove-hook 'gnus-mark-article-hook
'gnus-summary-mark-read-and-unread-as-read)
(add-hook 'gnus-mark-article-hook 'gnus-summary-mark-unread-as-read)
;; Quit Gnus gracefully when exiting Emacs
(add-hook 'kill-emacs-hook #'(lambda ()
(interactive)
(when (get-buffer "*Group*")
(gnus-group-exit))))
;; Dont quit summary buffer when pressing `q
(bind-key "q" #'gnus-summary-expand-window gnus-article-mode-map)
;; Show topics in group buffer
(add-hook 'gnus-group-mode-hook 'gnus-topic-mode)
;; We need to do some magic as otherwise the agent does not delete
;; articles from its .overview when we move them around. Thus we
;; mark articles as expireable when they have been moved to another
;; group.
(defadvice gnus-summary-move-article (around
no-cancel-mark
(&optional n to-newsgroup
select-method action)
activate)
(let ((articles (gnus-summary-work-articles n))
(return ad-do-it))
(when (or (null action)
(eq action 'move))
(dolist (article articles)
(gnus-summary-mark-article article gnus-expirable-mark)))
return))
;; Increase score of group after reading it
(add-hook 'gnus-summary-exit-hook
'gnus-summary-bubble-group)
;; Use Gnus registry; doing this too early conflicts with `gnus'
;; calling `gnus-shutdown', which in turn calls
;; `gnus-registry-clear', leaving us with an empty registry upon
;; startup. So let's call this initialization right before startup,
;; that should be fine.
(add-hook 'gnus-before-startup-hook
#'gnus-registry-initialize)
;; Automatic encryption if all necessary keys are present
(add-hook 'gnus-message-setup-hook
#'db/signencrypt-message-when-possible)
;; Do some pretty printing before saving the newsrc file
(add-hook 'gnus-save-quick-newsrc-hook
#'db/gnus-save-newsrc-with-whitespace-1)
;; Automatically scan for new news
(gnus-demon-add-handler 'db/gnus-demon-scan-news-on-level-2 5 5)
;; Automatically expire groups on idle
(gnus-demon-add-handler 'gnus-group-expire-all-groups 10 5)
;; Visit group under point and immediately close it; this updates
;; gnus registry as a side-effect
(bind-key "v u"
#'(lambda ()
(interactive)
(save-mark-and-excursion
(when (gnus-topic-select-group)
(gnus-summary-exit))))
gnus-group-mode-map)
;; Toggle visibility of News group
(bind-key "v c"
#'(lambda ()
(interactive)
(save-mark-and-excursion
(gnus-topic-jump-to-topic "News")
(gnus-topic-read-group)))
gnus-group-mode-map)
(bind-key "C-<return>" #'db/gnus-summary-open-Link gnus-summary-mode-map)
(bind-key "C-<return>" #'db/gnus-summary-open-Link gnus-article-mode-map)))
;; Sending mail ;; Sending mail
(setq message-send-mail-function #'db/smtpmail-send-it (setq message-send-mail-function #'db/smtpmail-send-it