| 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 | (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 |
| 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.") |
| 52 | (csetq |
| 53 | message-elide-ellipsis "[...]\n" |
| 54 | ;; message-cite-style 'message-cite-style-bandali |
| 55 | message-citation-line-format "%N writes:\n" |
| 56 | message-citation-line-function 'message-insert-formatted-citation-line |
| 57 | message-kill-buffer-on-exit t |
| 58 | message-send-mail-function 'message-send-mail-with-sendmail |
| 59 | message-sendmail-envelope-from 'header |
| 60 | message-subscribed-address-functions |
| 61 | '(gnus-find-subscribed-addresses) |
| 62 | message-dont-reply-to-names |
| 63 | "\\(\\(amin@shemshak\\.org\\)\\|\\(.*@aminb\\.org\\)\\|\\(\\(bandali\\|mab\\|aminb?\\)@gnu\\.org\\)\\|bandali@fsf\\.org\\|\\(a?bandali@\\(csclub\\.\\)?uwaterloo\\.ca\\)\\|amin\\.bandali@savoirfairelinux\\.com\\)") |
| 64 | ;; (require 'company-ebdb) |
| 65 | ;; (custom-set-faces |
| 66 | ;; '(message-header-subject |
| 67 | ;; ((t (:foreground "#111" :weight semi-bold)))) |
| 68 | ;; '(message-header-to |
| 69 | ;; ((t (:foreground "#111" :weight normal)))) |
| 70 | ;; '(message-header-cc |
| 71 | ;; ((t (:foreground "#333" :weight normal)))) |
| 72 | |
| 73 | ;; footnote |
| 74 | (with-eval-after-load 'footnote |
| 75 | ;; (csetq footnote-start-tag "" |
| 76 | ;; footnote-end-tag "" |
| 77 | ;; footnote-style 'unicode) |
| 78 | (when (featurep 'which-key) |
| 79 | (which-key-add-major-mode-key-based-replacements 'message-mode |
| 80 | "C-c f n" "footnote"))) |
| 81 | |
| 82 | ;; orgalist |
| 83 | (add-hook 'message-mode-hook |
| 84 | (lambda () |
| 85 | ;; work around incompatibility between |
| 86 | ;; orgalist and yasnippet |
| 87 | (yas-minor-mode -1) |
| 88 | (orgalist-mode 1) |
| 89 | (yas-minor-mode 1))) |
| 90 | |
| 91 | ;; local key bindings |
| 92 | (defvar b/footnote-prefix-map) |
| 93 | (define-prefix-command 'b/footnote-prefix-map) |
| 94 | (define-key message-mode-map (kbd "C-c f n") |
| 95 | 'b/footnote-prefix-map) |
| 96 | (define-key b/footnote-prefix-map (kbd "a") |
| 97 | #'footnote-add-footnote) |
| 98 | (define-key b/footnote-prefix-map (kbd "b") |
| 99 | #'footnote-back-to-message) |
| 100 | (define-key b/footnote-prefix-map (kbd "c") |
| 101 | #'footnote-cycle-style) |
| 102 | (define-key b/footnote-prefix-map (kbd "d") |
| 103 | #'footnote-delete-footnote) |
| 104 | (define-key b/footnote-prefix-map (kbd "g") |
| 105 | #'footnote-goto-footnote) |
| 106 | (define-key b/footnote-prefix-map (kbd "r") |
| 107 | #'footnote-renumber-footnotes) |
| 108 | (define-key b/footnote-prefix-map (kbd "s") |
| 109 | #'footnote-set-style)) |
| 110 | ;; hooks |
| 111 | ;; (add-hook 'message-setup-hook #'mml-secure-message-sign-pgpmime) |
| 112 | (add-hook 'message-mode-hook #'flyspell-mode) |
| 113 | (add-hook 'message-mode-hook |
| 114 | (lambda () |
| 115 | ;; (setq-local fill-column b/fill-column |
| 116 | ;; message-fill-column b/fill-column) |
| 117 | (eval-when-compile (defvar company-idle-delay)) |
| 118 | (make-local-variable 'company-idle-delay) |
| 119 | (setq company-idle-delay 0.2))) |
| 120 | |
| 121 | ;; (with-eval-after-load 'message-x |
| 122 | ;; (csetq |
| 123 | ;; message-x-completion-alist |
| 124 | ;; '(("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" |
| 125 | ;; . gnus-harvest-find-address) |
| 126 | ;; ((if |
| 127 | ;; (boundp |
| 128 | ;; (quote message-newgroups-header-regexp)) |
| 129 | ;; message-newgroups-header-regexp message-newsgroups-header-regexp) |
| 130 | ;; . message-expand-group)))) |
| 131 | |
| 132 | ;; (require 'gnus-harvest) |
| 133 | ;; (if (featurep 'message-x) |
| 134 | ;; (gnus-harvest-install 'message-x) |
| 135 | ;; (gnus-harvest-install)) |
| 136 | |
| 137 | (provide 'bandali-message) |
| 138 | ;;; bandali-message.el ends here |