summaryrefslogtreecommitdiff
path: root/init.org
diff options
context:
space:
mode:
Diffstat (limited to 'init.org')
-rw-r--r--init.org253
1 files changed, 252 insertions, 1 deletions
diff --git a/init.org b/init.org
index 53fc653..c89d55e 100644
--- a/init.org
+++ b/init.org
@@ -890,6 +890,257 @@ TODO: the parentheses adjustments should happen only when I’m in programming m
(global-set-key (kbd "<mouse-3>") 'god-mode-all)
#+END_SRC
+* Email
+:PROPERTIES:
+:header-args: :noweb-ref email
+:END:
+
+TODO: this is a big blob of email configuration. Document this properly!
+
+#+BEGIN_SRC elisp
+(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")
+
+;; 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
+ (or (member 'encrypted (mu4e-message-field msg :flags))
+ (string-match "-----BEGIN PGP MESSAGE-----$"
+ (mu4e-message-field msg :body-txt))))
+ (mml-secure-message-sign-encrypt)))))
+
+;; Don't open a new window to show the results of signature validation
+(setq epa-popup-info-window nil)
+
+(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"))
+ (mu4e-message-contact-field-matches
+ msg :from (rot13 "erxnqb@ryrcuyl.arg"))
+ ;; Additional check if this is a mailing list email.
+ (and (mu4e-message-field msg :mailing-list)
+ (zerop (call-process "grep" nil nil nil
+ "-E" "^Delivered-To: .*elephly.net"
+ (mu4e-message-field msg :path)))))))
+ :vars `((user-mail-address . ,(rot13 "erxnqb@ryrcuyl.arg"))
+ (mu4e-user-mail-address-list . ,(list (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 :from (rot13 "erxnqb@sunva.pbqreqbwb.oreyva"))
+ (mu4e-message-contact-field-matches
+ msg :to (rot13 "uryyb@sunva.pbqreqbwb.oreyva"))
+ (mu4e-message-contact-field-matches
+ msg :from (rot13 "uryyb@sunva.pbqreqbwb.oreyva")))))
+ :vars `((user-mail-address . ,(rot13 "erxnqb@sunva.pbqreqbwb.oreyva"))
+ (mu4e-user-mail-address-list . ,(list (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"))
+ (mu4e-message-contact-field-matches
+ msg :from (rot13 "evpneqb.jhezhf@zqp-oreyva.qr"))
+ ;; Additional check if this is a mailing list email.
+ (and (mu4e-message-field msg :mailing-list)
+ (zerop (call-process "grep" nil nil nil
+ "-E" "^Received: from .*mdc-berlin.de"
+ (mu4e-message-field msg :path)))))))
+ :vars `((user-mail-address . ,(rot13 "evpneqb.jhezhf@zqp-oreyva.qr"))
+ (mu4e-user-mail-address-list . ,(list (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)))))))))
+#+END_SRC
+
+Load all of this email configuration code only when I start =mu4e=.
+
+#+BEGIN_SRC elisp :noweb-ref email-lazy
+(global-set-key (kbd "<f12>") 'mu4e)
+(with-eval-after-load "mu4e"
+ <<email>>
+)
+#+END_SRC
+
* TODO Initial stuff
:PROPERTIES:
:header-args: :noweb-ref initial
@@ -1051,7 +1302,6 @@ This is even more stuff to be done after initialising packages. I still need to
(set-default 'tab-width 4)
(setq tab-width 4)
-(load "email.el")
(setq gnus-select-method '(nntp "news.gmane.org"))
(load "init-eshell.el")
(load "init-modeline.el")
@@ -1122,6 +1372,7 @@ Having defined named code blocks in the sections above we can finally put them a
<<shell>>
<<scheme>>
<<god>>
+<<email-lazy>>
<<ido-lazy>>
<<completion-lazy>>
<<pretty-symbols>>