summaryrefslogtreecommitdiffstats
path: root/.emacs.d/lisp/bandali-message.el
blob: dd048bbc418a172577dc683a281e28526ac9b2ee (plain) (blame)
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
;;; bandali-message.el --- bandali's message.el setup -*- lexical-binding: t; -*-

;; Copyright (C) 2018-2025 Amin Bandali <bandali@gnu.org>

;; Author: Amin Bandali <bandali@gnu.org>
;; Keywords: mail, news

;; 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:

;; My setup for message.el.

;;; Code:

(with-eval-after-load 'message
  ;; Redefine for a simplified In-Reply-To header
  ;; (https://todo.sr.ht/~sircmpwn/lists.sr.ht/67)
  (defun message-make-in-reply-to ()
    "Return the In-Reply-To header for this message."
    (when message-reply-headers
      (let ((from (mail-header-from message-reply-headers))
            (msg-id (mail-header-id message-reply-headers)))
        (when from
          msg-id))))

  (setopt
   message-elide-ellipsis "[...]\n"
   message-citation-line-format "%N wrote:\n"
   message-citation-line-function
   #'message-insert-formatted-citation-line
   message-confirm-send t
   message-fill-column 70
   message-forward-as-mime t
   ;; message-kill-buffer-on-exit t
   message-send-mail-function #'smtpmail-send-it
   message-subscribed-address-functions
   '(gnus-find-subscribed-addresses)
   message-dont-reply-to-names
   (mapconcat
    #'identity
    '("bandali@kelar\\.org"
      "amin@shemshak\\.org"
      "\\(bandali\\|mab\\|aminb?\\)@gnu\\.org"
      "a?bandali@\\(csclub\\.\\)?uwaterloo\\.ca"
      "bandali@gnu\\.ca"
      "bandali@ubuntu\\.com"
      "bandali@debian\\.org")
    "\\|"))

  (defun b/newlines-or-asterism (arg)
    "Create newlines per my liking, or insert asterism if ARG is
non-nil."
    (interactive "P")
    (if arg
        (b/insert-asterism)
      (progn
        (beginning-of-line)
        (delete-region (point) (line-end-position))
        (newline)
        (open-line 1))))
  (b/keymap-set message-mode-map "M-RET" #'b/newlines-or-asterism)

  (add-hook 'message-mode-hook #'flyspell-mode)
  (add-hook
   'message-mode-hook (lambda () (b/keymap-local-unset "C-c C-s"))))

(provide 'bandali-message)
;;; bandali-message.el ends here