2017-06-08 11:47:56 +02:00
|
|
|
;;; app/email/config.el -*- lexical-binding: t; -*-
|
2017-04-08 01:31:20 -04:00
|
|
|
|
|
|
|
;; I want to live in Emacs. Living is incomplete without email, so Emacs needs
|
|
|
|
;; to give me the ability to read, search, write and send my email. It does so
|
|
|
|
;; with `mu4e', and requires `offlineimap' and `mu' to be installed.
|
|
|
|
|
2018-01-24 15:08:43 -05:00
|
|
|
(defvar +email-backend 'mbsync
|
|
|
|
"Which backend to use. Can either be offlineimap, mbsync or nil (manual).")
|
2017-04-08 01:31:20 -04:00
|
|
|
|
|
|
|
|
|
|
|
;;
|
2018-09-07 19:36:16 -04:00
|
|
|
;; Packages
|
2017-04-08 01:31:20 -04:00
|
|
|
|
2019-01-03 02:08:16 -05:00
|
|
|
(add-to-list 'auto-mode-alist '("\\.\\(?:offlineimap\\|mbsync\\)rc\\'" . conf-mode))
|
|
|
|
|
|
|
|
|
2017-04-08 01:31:20 -04:00
|
|
|
(def-package! mu4e
|
|
|
|
:commands (mu4e mu4e-compose-new)
|
2018-01-24 15:08:43 -05:00
|
|
|
:init
|
2018-04-04 18:22:13 -04:00
|
|
|
(provide 'html2text) ; disable obsolete package
|
2018-01-24 15:08:43 -05:00
|
|
|
(setq mu4e-maildir "~/.mail"
|
|
|
|
mu4e-attachment-dir "~/.mail/.attachments"
|
|
|
|
mu4e-user-mail-address-list nil)
|
2017-04-08 01:31:20 -04:00
|
|
|
:config
|
2018-01-24 15:08:43 -05:00
|
|
|
(pcase +email-backend
|
|
|
|
(`mbsync
|
|
|
|
(setq mu4e-get-mail-command "mbsync -a"
|
|
|
|
mu4e-change-filenames-when-moving t))
|
|
|
|
(`offlineimap
|
|
|
|
(setq mu4e-get-mail-command "offlineimap -o -q")))
|
|
|
|
|
|
|
|
(setq mu4e-update-interval nil
|
2017-04-08 01:31:20 -04:00
|
|
|
mu4e-compose-format-flowed t ; visual-line-mode + auto-fill upon sending
|
|
|
|
mu4e-view-show-addresses t
|
2018-01-24 15:08:43 -05:00
|
|
|
mu4e-sent-messages-behavior 'sent
|
|
|
|
mu4e-hide-index-messages t
|
2017-04-08 01:31:20 -04:00
|
|
|
;; try to show images
|
|
|
|
mu4e-view-show-images t
|
|
|
|
mu4e-view-image-max-width 800
|
|
|
|
;; configuration for sending mail
|
2017-04-17 02:17:10 -04:00
|
|
|
message-send-mail-function #'smtpmail-send-it
|
2017-04-08 01:31:20 -04:00
|
|
|
smtpmail-stream-type 'starttls
|
2018-01-24 15:08:43 -05:00
|
|
|
message-kill-buffer-on-exit t ; close after sending
|
2017-04-08 01:31:20 -04:00
|
|
|
;; start with the first (default) context;
|
|
|
|
mu4e-context-policy 'pick-first
|
|
|
|
;; compose with the current context, or ask
|
|
|
|
mu4e-compose-context-policy 'ask-if-none
|
|
|
|
;; use helm/ivy
|
2018-01-24 15:08:43 -05:00
|
|
|
mu4e-completing-read-function
|
|
|
|
(cond ((featurep! :completion ivy) #'ivy-completing-read)
|
|
|
|
((featurep! :completion helm) #'completing-read)
|
|
|
|
(t #'ido-completing-read))
|
2017-04-08 01:31:20 -04:00
|
|
|
;; no need to ask
|
2018-10-03 09:05:36 +13:00
|
|
|
mu4e-confirm-quit nil
|
2017-04-09 17:42:17 -04:00
|
|
|
;; remove 'lists' column
|
2017-04-14 02:36:36 -04:00
|
|
|
mu4e-headers-fields
|
|
|
|
'((:account . 12)
|
|
|
|
(:human-date . 12)
|
|
|
|
(:flags . 4)
|
|
|
|
(:from . 25)
|
2018-01-24 15:08:43 -05:00
|
|
|
(:subject)))
|
|
|
|
|
2019-01-21 16:10:27 -08:00
|
|
|
;; set mail user agent
|
|
|
|
(setq mail-user-agent 'mu4e-user-agent)
|
|
|
|
|
2018-01-24 15:08:43 -05:00
|
|
|
;; Use fancy icons
|
|
|
|
(setq mu4e-headers-has-child-prefix '("+" . "")
|
|
|
|
mu4e-headers-empty-parent-prefix '("-" . "")
|
2018-08-17 12:40:47 +02:00
|
|
|
mu4e-headers-first-child-prefix '("\\" . "")
|
|
|
|
mu4e-headers-duplicate-prefix '("=" . "")
|
|
|
|
mu4e-headers-default-prefix '("|" . "")
|
|
|
|
mu4e-headers-draft-mark '("D" . "")
|
|
|
|
mu4e-headers-flagged-mark '("F" . "")
|
|
|
|
mu4e-headers-new-mark '("N" . "")
|
|
|
|
mu4e-headers-passed-mark '("P" . "")
|
|
|
|
mu4e-headers-replied-mark '("R" . "")
|
|
|
|
mu4e-headers-seen-mark '("S" . "")
|
|
|
|
mu4e-headers-trashed-mark '("T" . "")
|
|
|
|
mu4e-headers-attach-mark '("a" . "")
|
|
|
|
mu4e-headers-encrypted-mark '("x" . "")
|
|
|
|
mu4e-headers-signed-mark '("s" . "")
|
|
|
|
mu4e-headers-unread-mark '("u" . ""))
|
2017-04-18 21:04:25 -04:00
|
|
|
|
|
|
|
;; Add a column to display what email account the email belongs to.
|
2017-06-11 00:59:02 +02:00
|
|
|
(add-to-list 'mu4e-header-info-custom
|
|
|
|
'(:account
|
|
|
|
:name "Account"
|
|
|
|
:shortname "Account"
|
|
|
|
:help "Which account this email belongs to"
|
|
|
|
:function
|
|
|
|
(lambda (msg)
|
|
|
|
(let ((maildir (mu4e-message-field msg :maildir)))
|
|
|
|
(format "%s" (substring maildir 1 (string-match-p "/" maildir 1)))))))
|
2017-04-09 17:42:17 -04:00
|
|
|
|
2017-04-18 21:04:25 -04:00
|
|
|
;; Refresh the current view after marks are executed
|
|
|
|
(defun +email*refresh (&rest _) (mu4e-headers-rerun-search))
|
|
|
|
(advice-add #'mu4e-mark-execute-all :after #'+email*refresh)
|
|
|
|
|
2019-02-22 00:20:29 -05:00
|
|
|
(when (featurep! :tools flyspell)
|
2017-04-17 02:17:10 -04:00
|
|
|
(add-hook 'mu4e-compose-mode-hook #'flyspell-mode))
|
2017-04-14 02:36:36 -04:00
|
|
|
|
2017-04-09 22:10:41 -04:00
|
|
|
;; Wrap text in messages
|
2018-10-24 01:09:17 -04:00
|
|
|
(setq-hook! 'mu4e-view-mode-hook truncate-lines nil)
|
2017-04-08 01:31:20 -04:00
|
|
|
|
|
|
|
(when (fboundp 'imagemagick-register-types)
|
2017-04-19 13:18:03 -04:00
|
|
|
(imagemagick-register-types))
|
2017-04-08 01:31:20 -04:00
|
|
|
|
2018-10-24 01:09:17 -04:00
|
|
|
(set-evil-initial-state!
|
|
|
|
'(mu4e-main-mode
|
|
|
|
mu4e-view-mode
|
|
|
|
mu4e-headers-mode
|
|
|
|
mu4e-compose-mode
|
|
|
|
mu4e~update-mail-mode)
|
|
|
|
'normal))
|
2017-04-08 01:31:20 -04:00
|
|
|
|
|
|
|
|
|
|
|
(def-package! mu4e-maildirs-extension
|
|
|
|
:after mu4e
|
2018-01-24 15:08:43 -05:00
|
|
|
:config
|
2018-04-04 18:01:34 -04:00
|
|
|
(mu4e-maildirs-extension)
|
2019-02-16 13:12:28 -05:00
|
|
|
(setq mu4e-maildirs-extension-title nil))
|
2017-04-08 01:31:20 -04:00
|
|
|
|
|
|
|
|
|
|
|
(def-package! org-mu4e
|
2017-12-08 22:33:12 -05:00
|
|
|
:hook (mu4e-compose-mode . org-mu4e-compose-org-mode)
|
2017-04-08 01:31:20 -04:00
|
|
|
:config
|
|
|
|
(setq org-mu4e-link-query-in-headers-mode nil
|
|
|
|
org-mu4e-convert-to-html t)
|
2017-04-16 21:24:18 -04:00
|
|
|
|
2017-05-04 10:42:30 +02:00
|
|
|
;; Only render to html once. If the first send fails for whatever reason,
|
|
|
|
;; org-mu4e would do so each time you try again.
|
2017-04-08 01:31:20 -04:00
|
|
|
(add-hook! 'message-send-hook
|
|
|
|
(setq-local org-mu4e-convert-to-html nil)))
|
|
|
|
|
2018-01-24 15:08:43 -05:00
|
|
|
|
|
|
|
;;
|
|
|
|
;; Sub-modules
|
|
|
|
|
2018-05-27 12:44:22 +02:00
|
|
|
(if (featurep! +gmail) (load! "+gmail"))
|