emacs/gnus.el

173 lines
6.3 KiB
EmacsLisp

;;; gnus.el -*- lexical-binding: t; coding: utf-8-unix -*-
;; Author: Case Duckworth <acdw@acdw.net>
;; Created: Sometime during Covid-19, 2020
;; Keywords: configuration
;; URL: https://tildegit.org/acdw/emacs
;; This file is NOT part of GNU Emacs.
;;; License:
;; Everyone is permitted to do whatever with this software, without
;; limitation. This software comes without any warranty whatsoever,
;; but with two pieces of advice:
;; - Don't hurt yourself.
;; - Make good choices.
;;; Code:
;;; Select Methods
(setq gnus-select-method '(nnnil ""))
(setq gnus-secondary-select-methods
'((nnimap "fastmail.com"
(nnimap-address "imap.fastmail.com")
(nnimap-server-port 993)
(nnimap-stream ssl)
(nnir-search-engine imap))
(nntp "news.tilde.club")
(nntp "news.gwene.org")))
;;; Gnus cloud
(setq gnus-cloud-method "nnimap:fastmail.com"
gnus-cloud-storage-method 'base64 ; Don't always have GPG or gzip
)
(add-hook 'gnus-started-hook #'gnus-cloud-download-all-data)
(add-hook 'gnus-exit-gnus-hook #'gnus-cloud-upload-all-data)
;;; Gnus subscriptions
(setq gnus-options-subscribe (rx (or ;; all alternatives go under this
(seq string-start
"nnimap+fastmail.com:"
(or ;; folders in Fastmail
"INBOX")))
(seq string-start
"nntp+news.tilde.club:"
(or ;; news groups in tilde.club
(seq "local."
(or "general"))
(seq "tilde."
(or "art"
"club"
"cosmic"
"food+drink"
"gopher"
"meta"
"poetry"
"services"))))))
(setq gnus-options-not-subscribe (rx (or ;; all alternatives go under this
(seq string-start
"nnimap+fastmail.com:"
(or ;; folders in Fastmail
"Archive"
"Bulk"
"DeltaChat"
"Gmail"
"Pam"
"Spam"
"Trash"
"blag"
"notes"))
(seq string-start
"nntp+news.tilde.club:"
(or ;; news groups in tilde.club
(seq "tilde."
(or "black"
"javascript"
"nsfw"
"php"
"pink"
"python"
"your")))))))
;;; Gnus behavior options
(setq gnus-gcc-mark-as-read t
message-signature (or (file-exists-p message-signature-file)
"~ acdw")
gnus-save-newsrc-file nil
gnus-read-newsrc-file nil
gnus-interactive-exit nil)
;; Keybindings
(define-key gnus-group-mode-map (kbd "q") #'bury-buffer)
(define-key gnus-group-mode-map (kbd "Q") #'gnus-group-exit)
(define-key gnus-group-mode-map (kbd "C-q") #'gnus-group-quit)
;;; Other parameters
(setq gnus-parameters
'(("nnimap\\.*"
(display . 200))))
;;; Gnus UI options
(setq gnus-thread-sort-functions '(gnus-thread-sort-by-most-recent-date
(not gnus-thread-sort-by-number))
gnus-use-cache t
gnus-summary-thread-gathering-function #'gnus-gather-threads-by-subject
gnus-thread-hide-subtree t
gnus-thread-ignore-subject t
gnus-html-frame-width fill-column)
(when window-system
(setq gnus-sum-thread-tree-indent " ")
(setq gnus-sum-thread-tree-root "")
(setq gnus-sum-thread-tree-false-root "")
(setq gnus-sum-thread-tree-single-indent "")
(setq gnus-sum-thread-tree-vertical "")
(setq gnus-sum-thread-tree-leaf-with-other "├─ ")
(setq gnus-sum-thread-tree-single-leaf "╰─ "))
(setq gnus-summary-line-format
(concat
"%0{%U%R%z%}"
"%3{│%}" "%1{%d%}" "%3{│%}" ; date
" "
"%4{%-20,20f%}" ; name
" "
"%3{│%}"
" "
"%1{%B%}"
"%s\n"))
(setq gnus-summary-display-arrow t)
(add-hook 'gnus-group-mode-hook #'hl-line-mode)
(add-hook 'gnus-article-mode-hook #'acdw/reading-mode)
;;; MIME types
(setq mm-discouraged-alternatives '("text/html"
"text/richtext"))
;;; Composing mail
(hook-defun setup-message-mode message-mode-hook
(flyspell-mode +1)
(local-set-key (kbd "TAB") #'bbdb-complete-mail))
;;; Sending mail
(setq send-mail-function #'smtpmail-send-it
message-send-mail-function #'smtpmail-send-it
smtpmail-smtp-server "smtp.fastmail.com"
smtpmail-default-smtp-server "smtp.fastmail.com"
smtpmail-smtp-service 465
smtpmail-stream-type 'ssl
smtpmail-smtp-user "acdw@fastmail.com"
message-kill-buffer-on-exit t)
;;; Packages
;; searching (?)
(require 'nnir)
;; contacts
(setup (:straight bbdb)
(require 'bbdb)
(bbdb-initialize 'message 'gnus 'mail)
(bbdb-insinuate-message)
(add-hook 'gnus-startup-hook 'bbdb-insinuate-gnus)
(:option bbdb/gnus-summary-prefer-real-names t
bbdb/mail-auto-create-p t
bbdb/news-auto-create-p t
bbdb-use-pop-up t
bbdb-offer-save 1
bbdb-update-records-p t))