aboutsummaryrefslogtreecommitdiffstats
path: root/oni-gnus.el
blob: d21a7371306788ede892532ee4f6aa69c71c2b81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
;;; oni-gnus.el --- Gnus configuration               -*- lexical-binding: t; -*-

;; Copyright (C) 2019  Tom Willemse

;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2023.0621.223533
;; Package-Requires: (oni-data-dir oni-sendmail)

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; Gnus configuration

;;; Code:

(require 'gnus)
(require 'gnus-msg)
(require 'mail-source)
(require 'message)
(require 'nnfolder)
(require 'oni-data-dir)
(require 'oni-sendmail)

(defun oni-gnus-goto-bracket-then-colon ()
  "Find the first occurrence of [ on the current line and then :.
The default function ‘gnus-goto-colon' only goes to the first
colon and then stops there. When there is a date with a time
involved, it just goes to the time, not the colon after the size
of the email."
  (move-beginning-of-line 1)
  (let ((eol (point-at-eol)))
    (goto-char (or (text-property-any (point) eol 'gnus-position t)
		           (progn (search-forward "[" eol t)
                          (search-forward ":" eol t))
		           (point)))))

;;; Make sure that repositioning point in Gnus means that first the bracket is
;;; found and then the following colon, instead of the first colon which is
;;; possibly one from a time stamp.
(defalias 'gnus-summary-position-point 'oni-gnus-goto-bracket-then-colon)

(setq gnus-directory (oni-data-dir-locate "News")
      gnus-article-save-directory gnus-directory
      gnus-cache-directory gnus-directory
      gnus-kill-files-directory gnus-directory)

(setq mail-source-directory (oni-data-dir-locate "Mail")
      message-directory mail-source-directory
      nnfolder-directory mail-source-directory)

(setq gnus-novice-user nil)

(defun oni-gnus-delete-forward (&optional n)
  "Delete the article under point and move to the next one.
Do this N times."
  (interactive "p")
  (dotimes (_ (or n 1))
    (gnus-summary-delete-article)
    (gnus-summary-next-subject 1)))

(define-key gnus-summary-mode-map (kbd "M-d") #'oni-gnus-delete-forward)

(setq gnus-group-line-format "%P%(%20G%): %-10s %S%p%B %5y %5T\n")
(setq gnus-summary-line-format "%U%R%z %&user-date;%20= %I%(%[%5L: %-23,23f%]%) %s\n")

(setq gnus-treat-from-gravatar t)

(setq gnus-select-method
      '(nnmaildir "ryuslash" (directory "~/documents/mail/ryuslash/")))

(setq gnus-summary-thread-gathering-function 'gnus-gather-threads-by-references)
(setq gnus-thread-sort-functions '(gnus-thread-sort-by-date))
(setq gnus-buttonized-mime-types '("multipart/alternative"))

(add-to-list 'gnus-posting-styles
             '(".*"
               (address "tom@ryuslash.org")
               (eval (setq message-sendmail-extra-arguments
                           '("-a" "ryuslash")))))

(add-to-list 'gnus-secondary-select-methods
             '(nnmaildir "gmail"
                         (directory "~/documents/mail/gmail/")))

(add-to-list 'gnus-posting-styles
             '("gmail:"
               (name "Tom Willemse")
               (address "ryuslash@gmail.com")
               (eval (setq message-sendmail-extra-arguments
                           '("-a" "gmail")))))

(provide 'oni-gnus)
;;; oni-gnus.el ends here