summaryrefslogtreecommitdiff
path: root/lisp/email.el
blob: 5ba82afc0cba9a27a9bc17fbf27830a3e063ef09 (about) (plain)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
(require 'mu4e)
(require 'org-mu4e)
(require 'mu4e-contrib)

(setq shr-color-visible-luminance-min 30)

(setq mu4e-get-mail-command "offlineimap"
      mu4e-compose-signature-auto-include nil
      mu4e-compose-dont-reply-to-self t
      mu4e-update-interval 60
      mu4e-headers-include-related t)

(setq mu4e-use-fancy-chars t)
(setq mu4e-headers-seen-mark    '("" . ""))
(setq mu4e-headers-unread-mark  '("u" . "✉"))

;; Don't update list of emails automatically.  I update the list
;; manually with "g".
(setq mu4e-headers-auto-update nil)

(setq mu4e-view-show-addresses t)
(setq mu4e-hide-index-messages t)
(setq mu4e-html2text-command 'mu4e-shr2text)
(setq mu4e-view-show-images t)

;; use imagemagick, if available
(when (fboundp 'imagemagick-register-types)
  (imagemagick-register-types))

(setq mu4e-maildir        "~/Mail"
      mu4e-attachment-dir "~/Downloads"
      mu4e-compose-signature-auto-include t)

;; pretty quotes!
(add-hook 'message-mode-hook
          (lambda ()
            (require 'typo)
            (typo-mode 1)))

(defun my/set-mu4e-bookmarks (maildir)
  (let ((guix     "(list:guix-devel@gnu.org OR list:bug-guix@gnu.org OR list:help-guix@gnu.org OR list:guix-sysadmin@gnu.org OR list:guix-security.gnu.org)")
        (guile    "(list:guile-user@gnu.org OR list:guile-devel@gnu.org OR list:bug-guile@gnu.org)")
        (emacs    "(list:emacs-devel@gnu.org)")
        (security "(list:oss-security@lists.openwall.com)")
        (lilypond "(list:lilypond-devel@gnu.org)")
        (eoma     "(list:arm-netbook@lists.phcomp.co.uk)")
        (fsfe     "(subject:\"Willkommen in der FSFE\" list:berlin-bounces@lists.fsfe.org OR list:berlin-owner@lists.fsfe.org OR list:coordinators@lists.fsfe.org OR list:berlin@lists.fsfe.org OR list:newsletter-en@fsfeurope.org OR list:newsletter-de@fsfeurope.org)")
        (dojo     "(list:coderdojo-berlin-discussion@googlegroups.com OR to:hello@fhain.coderdojo.berlin)")
        (unread   "(flag:unread AND NOT flag:trashed)")
        (me       "(body:rekado OR body:Ricardo)"))
    (setq mu4e-bookmarks
          (list
           ;; TODO: don't match my own signature
           (list (concat me " " unread)
                 "Mentioning me (unread)" ?R)
           (list (concat "maildir:\"/" maildir "/INBOX\"")
                 "Inbox"  ?i)
           (list "date:today..now"
                 "Today's messages" ?t)
           (list "date:today..now"
                 "Last 7 days" ?w)
           (list (concat "maildir:\"/" maildir "/INBOX\"" " " unread)
                 "Unread messages"  ?u)
           (list (concat guix " " unread)
                 "Guix"  ?1)
           (list (concat guile " " unread)
                 "Guile"  ?2)
           (list (concat lilypond " " unread)
                 "Lilypond"  ?3)
           (list (concat fsfe " " unread)
                 "FSFE"  ?4)
           (list (concat dojo " " unread)
                 "CoderDojo"  ?5)
           (list (concat eoma " " unread)
                 "EOMA68"  ?6)
           (list (concat emacs " " unread)
                 "Emacs"  ?7)
           (list (concat security " " unread)
                 "Security" ?8)
           (list (concat "maildir:\"/private/mailinglists\""
                         " " unread
                         " NOT " guix
                         " NOT " guile
                         " NOT " lilypond
                         " NOT " fsfe
                         " NOT " eoma
                         " NOT " emacs
                         " NOT " security
                         " NOT " dojo)
                 "Unread list messages"  ?m)
           (list (concat "maildir:\"/" maildir "/INBOX\" flag:flagged")
                 "Flagged"  ?f)))))

; set up email sending with msmtp
(setq mail-user-agent 'mu4e-user-agent)
(setq mail-specify-envelope-from t)
(setq mail-envelope-from 'header)

(setq message-kill-buffer-on-exit t)
(setq message-sendmail-envelope-from 'header)
(setq message-send-mail-function 'message-send-mail-with-sendmail)

;;use msmtp instead of sendmail
(setq sendmail-program "~/.guix-profile/bin/msmtp")

(global-set-key (kbd "<f12>") 'mu4e)

;; Crypto
(setq mml2015-encrypt-to-self t)
(setq mml2015-sign-with-sender t)

(add-hook 'mu4e-compose-mode-hook
  (defun my/maybe-reply-encrypted ()
    "Encrypt automatically if parent message was also encrypted."
    (let ((msg mu4e-compose-parent-message))
      (when (and msg (member 'encrypted (mu4e-message-field msg :flags)))
        (mml-secure-message-sign-encrypt)))))

(add-hook 'mu4e-view-mode-hook
  (defun my/maybe-decrypt-inline ()
    "Attempt to decrypt inline PGP messages automatically."
    (save-excursion
      (goto-char (point-min))
      (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t)
      (let ((armor-start (match-beginning 0)))
        (when armor-start
          (let ((armor-end (re-search-forward "^-----END PGP MESSAGE-----$" nil t)))
            (when armor-end
              ;; Don't ask if I want to replace the text.  Just do it.
              (flet ((yes-or-no-p (&rest args) t)
                     (y-or-n-p (&rest args) t))
                (epa-decrypt-armor-in-region armor-start armor-end)))))))))

(require 'mu4e-actions)
(add-to-list 'mu4e-view-actions
             '("git am" . mu4e-action-git-apply-mbox))
(add-to-list 'mu4e-headers-actions
             '("git am" . mu4e-action-git-apply-mbox))

(setq mu4e-contexts
      (list (make-mu4e-context
             :name "Private"
             :enter-func (lambda ()
                           (mu4e-message "Switch to the Private context")
                           (my/set-mu4e-bookmarks "private"))
             :match-func (lambda (msg)
                           (when msg
                             (or (mu4e-message-contact-field-matches
                                  msg :to (rot13 "erxnqb@ryrcuyl.arg")))))
             :vars `((user-mail-address  . ,(rot13 "erxnqb@ryrcuyl.arg"))
                     (user-full-name     . ,(rot13 "Evpneqb Jhezhf"))
                     (mu4e-sent-folder   . "/private/Sent")
                     (mu4e-trash-folder  . "/private/Trash")
                     (mu4e-refile-folder . "/private/Archives")
                     (mu4e-drafts-folder . "/private/Drafts")
                     (mu4e-compose-signature . "Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
http://elephly.net")))
            (make-mu4e-context
             :name "CoderDojo"
             :enter-func (lambda ()
                           (mu4e-message "Switch to the CoderDojo context")
                           (my/set-mu4e-bookmarks "fhaindojo"))
             :match-func (lambda (msg)
                           (when msg
                             (or (mu4e-message-contact-field-matches
                                  msg :to (rot13 "erxnqb@sunva.pbqreqbwb.oreyva"))
                                 (mu4e-message-contact-field-matches
                                  msg :to (rot13 "uryyb@sunva.pbqreqbwb.oreyva")))))
             :vars `((user-mail-address  . ,(rot13 "erxnqb@sunva.pbqreqbwb.oreyva"))
                     (user-full-name     . ,(rot13 "Evpneqb Jhezhf"))
                     (mu4e-sent-folder   . "/fhaindojo/Sent")
                     (mu4e-trash-folder  . "/fhaindojo/Trash")
                     (mu4e-refile-folder . "/fhaindojo/Archive")
                     (mu4e-drafts-folder . "/fhaindojo/Drafts")
                     (mu4e-compose-signature . "Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
http://elephly.net")))
            (make-mu4e-context
             :name "Work"
             :enter-func (lambda ()
                           (mu4e-message "Switch to the Work context")
                           (my/set-mu4e-bookmarks "mdc-personal"))
             :match-func (lambda (msg)
                           (when msg
                             (or (mu4e-message-contact-field-matches
                                  msg :to (rot13 "evpneqb.jhezhf@zqp-oreyva.qr")))))
             :vars `((user-mail-address      . ,(rot13 "evpneqb.jhezhf@zqp-oreyva.qr"))
                     (user-full-name         . ,(rot13 "Evpneqb Jhezhf"))
                     (mu4e-sent-folder       . "/mdc-personal/Sent Items")
                     (mu4e-trash-folder      . "/mdc-personal/Deleted Items")
                     (mu4e-refile-folder     . "/mdc-personal/Archive")
                     (mu4e-drafts-folder     . "/mdc-personal/Drafts")
                     (mu4e-compose-signature . ,(rot13 (concat "\
Evpneqb Jhezhf

Flfgrz nqzvavfgengbe
OVZFO - Fpvragvsvp Ovbvasbezngvpf Cyngsbez
Znk Qryoehrpx Pragre sbe Zbyrphyne Zrqvpvar

Eboreg-Eöffyr-Fge. 10, 13125, Oreyva, Treznal
Ohvyqvat 89, Ebbz 1.08

rznvy: evpneqb.jhezhf@zqp-oreyva.qr
gry:   +49 30 9406 " (number-to-string (+ (* 1 2 2 3 4 5 6) (expt 2 8) 100)))))))))