7d8edf46922704cb44b7a96f01351f6eadcfa0a3
[~bandali/configs] / lisp / bandali-message.el
1 ;;; bandali-message.el --- bandali's message.el setup -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 2018-2020 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 (use-package message
28 :bind (:map message-mode-map ("<C-return>" . b/insert-asterism))
29 :config
30 ;; redefine for a simplified In-Reply-To header
31 ;; (see https://todo.sr.ht/~sircmpwn/lists.sr.ht/67)
32 (defun message-make-in-reply-to ()
33 "Return the In-Reply-To header for this message."
34 (when message-reply-headers
35 (let ((from (mail-header-from message-reply-headers))
36 (msg-id (mail-header-id message-reply-headers)))
37 (when from
38 msg-id))))
39
40 (defconst b/message-cite-style-format "On %Y-%m-%d %l:%M %p, %N wrote:")
41 (defconst message-cite-style-bandali
42 '((message-cite-function 'message-cite-original)
43 (message-citation-line-function 'message-insert-formatted-citation-line)
44 (message-cite-reply-position 'traditional)
45 (message-yank-prefix "> ")
46 (message-yank-cited-prefix ">")
47 (message-yank-empty-prefix ">")
48 (message-citation-line-format
49 (if b/message-cite-say-hi
50 (concat "Hi %F,\n\n" b/message-cite-style-format)
51 b/message-cite-style-format)))
52 "Citation style based on Mozilla Thunderbird's. Use with message-cite-style.")
53 (setq ;; message-cite-style 'message-cite-style-bandali
54 message-citation-line-format "%N writes:\n"
55 message-citation-line-function 'message-insert-formatted-citation-line
56 message-kill-buffer-on-exit t
57 message-send-mail-function 'message-send-mail-with-sendmail
58 message-sendmail-envelope-from 'header
59 message-subscribed-address-functions
60 '(gnus-find-subscribed-addresses)
61 message-dont-reply-to-names
62 "\\(\\(amin@shemshak\\.org\\)\\|\\(.*@aminb\\.org\\)\\|\\(\\(bandali\\|mab\\|aminb?\\)@gnu\\.org\\)\\|bandali@fsf\\.org\\|\\(a?bandali@\\(csclub\\.\\)?uwaterloo\\.ca\\)\\)")
63 ;; (require 'company-ebdb)
64 :hook (;; (message-setup . mml-secure-message-sign-pgpmime)
65 (message-mode . flyspell-mode)
66 (message-mode . (lambda ()
67 ;; (setq-local fill-column b/fill-column
68 ;; message-fill-column b/fill-column)
69 (eval-when-compile (defvar company-idle-delay))
70 (make-local-variable 'company-idle-delay)
71 (setq company-idle-delay 0.2))))
72 ;; :custom-face
73 ;; (message-header-subject ((t (:foreground "#111" :weight semi-bold))))
74 ;; (message-header-to ((t (:foreground "#111" :weight normal))))
75 ;; (message-header-cc ((t (:foreground "#333" :weight normal))))
76 :custom
77 (message-elide-ellipsis "[...]\n"))
78
79 (use-package footnote
80 :after message
81 :config
82 ;; (setq footnote-start-tag ""
83 ;; footnote-end-tag ""
84 ;; footnote-style 'unicode)
85 (when (featurep 'which-key)
86 (which-key-add-major-mode-key-based-replacements 'message-mode
87 "C-c f n" "footnote"))
88 :bind
89 (:map message-mode-map
90 :prefix-map b/footnote-prefix-map
91 :prefix "C-c f n"
92 ("a" . footnote-add-footnote)
93 ("b" . footnote-back-to-message)
94 ("c" . footnote-cycle-style)
95 ("d" . footnote-delete-footnote)
96 ("g" . footnote-goto-footnote)
97 ("r" . footnote-renumber-footnotes)
98 ("s" . footnote-set-style)))
99
100 (comment
101 (use-package message-x
102 :custom
103 (message-x-completion-alist
104 (quote
105 (("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" . gnus-harvest-find-address)
106 ((if
107 (boundp
108 (quote message-newgroups-header-regexp))
109 message-newgroups-header-regexp message-newsgroups-header-regexp)
110 . message-expand-group))))))
111
112 (comment
113 (use-package gnus-harvest
114 :commands gnus-harvest-install
115 :demand
116 :config
117 (if (featurep 'message-x)
118 (gnus-harvest-install 'message-x)
119 (gnus-harvest-install))))
120
121 (use-package orgalist
122 :after message
123 :hook (message-mode . (lambda ()
124 ;; work around incompatibility between
125 ;; orgalist and yasnippet
126 (yas-minor-mode -1)
127 (orgalist-mode 1)
128 (yas-minor-mode 1))))
129
130 (provide 'bandali-message)
131 ;;; bandali-message.el ends here