Update primary Canonical mail and a few other small tweaks
[~bandali/configs] / .emacs.d / lisp / bandali-message.el
1 ;;; bandali-message.el --- bandali's message.el setup -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 2018-2022 Amin Bandali
4
5 ;; Author: Amin Bandali <bandali@gnu.org>
6 ;; Keywords: mail, news
7
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
12
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
20
21 ;;; Commentary:
22
23 ;; My setup for message.el.
24
25 ;;; Code:
26
27 (with-eval-after-load 'message
28 ;; :bind (:map message-mode-map ("<C-return>" . b/insert-asterism))
29 ;; redefine for a simplified In-Reply-To header
30 ;; (see https://todo.sr.ht/~sircmpwn/lists.sr.ht/67)
31 (defun message-make-in-reply-to ()
32 "Return the In-Reply-To header for this message."
33 (when message-reply-headers
34 (let ((from (mail-header-from message-reply-headers))
35 (msg-id (mail-header-id message-reply-headers)))
36 (when from
37 msg-id))))
38
39 (defconst b/message-cite-style-format "On %Y-%m-%d %l:%M %p, %N wrote:")
40 (defconst message-cite-style-bandali
41 '((message-cite-function 'message-cite-original)
42 (message-citation-line-function 'message-insert-formatted-citation-line)
43 (message-cite-reply-position 'traditional)
44 (message-yank-prefix "> ")
45 (message-yank-cited-prefix ">")
46 (message-yank-empty-prefix ">")
47 (message-citation-line-format b/message-cite-style-format))
48 "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.")
49 (setq
50 message-elide-ellipsis "[...]\n"
51 ;; message-cite-style 'message-cite-style-bandali
52 message-citation-line-format "%N writes:\n"
53 message-citation-line-function 'message-insert-formatted-citation-line
54 message-confirm-send t
55 message-fill-column 70
56 message-forward-as-mime t
57 message-kill-buffer-on-exit t
58 message-send-mail-function #'smtpmail-send-it
59 message-subscribed-address-functions
60 '(gnus-find-subscribed-addresses)
61 message-dont-reply-to-names
62 (mapconcat
63 #'identity
64 '("\\(bandali\\|mab\\|aminb?\\)@gnu\\.org"
65 "bandali@kelar\\.org"
66 "amin@shemshak\\.org"
67 "a?bandali@\\(csclub\\.\\)?uwaterloo\\.ca"
68 "amin\\.bandali@savoirfairelinux\\.com"
69 "\\(amin\\.\\)?bandali@canonical\\.com")
70 "\\|"))
71 ;; (custom-set-faces
72 ;; '(message-header-subject
73 ;; ((t (:foreground "#111" :weight semi-bold))))
74 ;; '(message-header-to
75 ;; ((t (:foreground "#111" :weight normal))))
76 ;; '(message-header-cc
77 ;; ((t (:foreground "#333" :weight normal))))
78
79 ;; custom newline & reformat function
80 (defun b/message-newline-or-asterism (arg)
81 "Create newlines per my liking or insert asterism if ARG is
82 non-nil."
83 (interactive "P")
84 (if arg
85 (b/insert-asterism)
86 (progn
87 (beginning-of-line)
88 (delete-region (point) (line-end-position))
89 (newline)
90 (open-line 1))))
91 (define-key message-mode-map
92 (kbd "M-RET") #'b/message-newline-or-asterism)
93
94 ;; local key bindings
95 ;; (define-key message-mode-map
96 ;; [remap next-line] #'mail-abbrev-next-line)
97 ;; (define-key message-mode-map
98 ;; [remap end-of-buffer] #'mail-abbrev-end-of-buffer)
99 )
100 ;; hooks
101 ;; (add-hook 'message-setup-hook #'mml-secure-message-sign-pgpmime)
102 (add-hook 'message-mode-hook #'flyspell-mode)
103 (add-hook 'message-mode-hook
104 (lambda ()
105 (local-unset-key (kbd "C-c C-s"))))
106
107 (provide 'bandali-message)
108 ;;; bandali-message.el ends here