* .config/dunst/dunstrc: Update according to v1.5.0.
[~bandali/configs] / .emacs.d / lisp / bandali-message.el
CommitLineData
4c05c418
AB
1;;; bandali-message.el --- bandali's message.el setup -*- lexical-binding: t; -*-
2
78d731e1 3;; Copyright (C) 2018-2022 Amin Bandali
4c05c418
AB
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
c84be134
AB
27(with-eval-after-load 'message
28 ;; :bind (:map message-mode-map ("<C-return>" . b/insert-asterism))
2087ae39
AB
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
48 (if b/message-cite-say-hi
49 (concat "Hi %F,\n\n" b/message-cite-style-format)
50 b/message-cite-style-format)))
51 "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.")
78d731e1 52 (setq
c84be134
AB
53 message-elide-ellipsis "[...]\n"
54 ;; message-cite-style 'message-cite-style-bandali
8486a0d6
AB
55 message-citation-line-format "%N writes:\n"
56 message-citation-line-function 'message-insert-formatted-citation-line
5efecfcd 57 message-confirm-send t
1bc92270
AB
58 message-fill-column 70
59 message-forward-as-mime t
8486a0d6 60 message-kill-buffer-on-exit t
a220fb5b 61 message-send-mail-function #'smtpmail-send-it
8486a0d6
AB
62 message-subscribed-address-functions
63 '(gnus-find-subscribed-addresses)
64 message-dont-reply-to-names
18fed9bb 65 "\\(\\(bandali@kelar\\.org\\)\\|\\(amin@shemshak\\.org\\)\\|\\(\\(bandali\\|mab\\|aminb?\\)@gnu\\.org\\)\\|\\(a?bandali@\\(csclub\\.\\)?uwaterloo\\.ca\\)\\|amin\\.bandali@savoirfairelinux\\.com\\)")
c84be134
AB
66 ;; (custom-set-faces
67 ;; '(message-header-subject
68 ;; ((t (:foreground "#111" :weight semi-bold))))
69 ;; '(message-header-to
70 ;; ((t (:foreground "#111" :weight normal))))
71 ;; '(message-header-cc
72 ;; ((t (:foreground "#333" :weight normal))))
73
74 ;; footnote
a0e241c4 75 ;; (with-eval-after-load 'footnote
78d731e1
AB
76 ;; (setq footnote-start-tag ""
77 ;; footnote-end-tag ""
78 ;; footnote-style 'unicode))
c84be134 79
23eb0d7a
AB
80 ;; custom newline & reformat function
81 (defun b/message-newline-or-asterism (arg)
82 "Create newlines per my liking or insert asterism if ARG is
83non-nil."
84 (interactive "P")
85 (if arg
86 (b/insert-asterism)
87 (progn
88 (beginning-of-line)
89 (delete-region (point) (line-end-position))
90 (newline)
91 (open-line 1))))
92 (define-key message-mode-map
93 (kbd "M-RET") #'b/message-newline-or-asterism)
94
c84be134 95 ;; local key bindings
bc04a4d4
AB
96 (define-key message-mode-map
97 [remap next-line] #'mail-abbrev-next-line)
98 (define-key message-mode-map
99 [remap end-of-buffer] #'mail-abbrev-end-of-buffer)
c84be134
AB
100 (defvar b/footnote-prefix-map)
101 (define-prefix-command 'b/footnote-prefix-map)
102 (define-key message-mode-map (kbd "C-c f n")
103 'b/footnote-prefix-map)
104 (define-key b/footnote-prefix-map (kbd "a")
105 #'footnote-add-footnote)
106 (define-key b/footnote-prefix-map (kbd "b")
107 #'footnote-back-to-message)
108 (define-key b/footnote-prefix-map (kbd "c")
109 #'footnote-cycle-style)
110 (define-key b/footnote-prefix-map (kbd "d")
111 #'footnote-delete-footnote)
112 (define-key b/footnote-prefix-map (kbd "g")
113 #'footnote-goto-footnote)
114 (define-key b/footnote-prefix-map (kbd "r")
115 #'footnote-renumber-footnotes)
116 (define-key b/footnote-prefix-map (kbd "s")
117 #'footnote-set-style))
118;; hooks
119;; (add-hook 'message-setup-hook #'mml-secure-message-sign-pgpmime)
120(add-hook 'message-mode-hook #'flyspell-mode)
5df34463
AB
121(add-hook 'message-mode-hook
122 (lambda ()
123 (local-unset-key (kbd "C-c C-s"))))
2087ae39
AB
124
125(provide 'bandali-message)
4c05c418 126;;; bandali-message.el ends here