ambevar-dotfiles/.emacs.d/lisp/init-mu4e.el

152 lines
5.4 KiB
EmacsLisp
Raw Normal View History

;;; mu4e
2017-10-10 17:09:19 +02:00
;;; REVIEW: Reply to all by default.
;;; https://github.com/djcb/mu/issues/1135
;;; TODO: Is it possible to mbsync without attachments?
;;; REVIEW: Do not cite when replying: https://github.com/djcb/mu/issues/1110.
;;; TODO: Face of `message-cited-text' does not work.
;;; REVIEW: Handle attachments in attached e-mails.
;;; See https://github.com/djcb/mu/issues/454#issuecomment-320616279.
;;; TODO: <tab> should go to next link in text e-mails too.
2018-02-15 15:55:30 +01:00
;; We need 'main' to setup pinentry-emacs for GPG.
(require 'main)
(when (require 'mu4e-maildirs-extension nil t)
(mu4e-maildirs-extension))
2018-02-15 13:28:49 +01:00
(defun ambrevar/mu4e-headers ()
2017-07-31 08:59:03 +02:00
"Like `mu4e' but show the header view.
2018-02-15 13:28:49 +01:00
Default to unread messages if the header buffer does not already exist."
(interactive)
2017-07-31 08:59:03 +02:00
(mu4e~start)
(if (get-buffer "*mu4e-headers*" )
(switch-to-buffer "*mu4e-headers*")
(mu4e-headers-search "flag:unread AND NOT flag:trashed")))
(setq
2017-07-31 08:57:46 +02:00
;; Attachments
mu4e-attachment-dir "~/temp"
2017-07-31 08:57:46 +02:00
mu4e-save-multiple-attachments-without-asking t
;; IMAP sync.
mu4e-maildir "~/.cache/mail"
mu4e-get-mail-command "mbsync -a"
mu4e-update-interval 90
mu4e-change-filenames-when-moving t ; Preferred for mbsync according to the man page.
;; SMTP
message-send-mail-function 'smtpmail-send-it
;; Don't bother me with context on startup.
mu4e-context-policy nil
;; Don't keep sent e-mail buffer.
message-kill-buffer-on-exit t
;; For reporting bugs, "C-x m", etc.
mail-user-agent 'mu4e-user-agent
mu4e-compose-dont-reply-to-self t
;; Display
mu4e-headers-date-format "%F %R"
mu4e-headers-fields '((:human-date . 16)
(:flags . 6)
2017-07-31 08:58:44 +02:00
(:size . 6)
(:mailing-list . 10)
(:from . 22)
(:subject))
mu4e-headers-time-format "%R"
mu4e-view-show-addresses t
mu4e-view-show-images t
mu4e-view-image-max-width 800
mu4e-hide-index-messages t
;; If you're using a dark theme, and the messages are hard to read, it
;; can help to change the luminosity, e.g.:
shr-color-visible-luminance-min 80
;; Gmail-style threading.
mu4e-headers-include-related t
;; Gmail likes format=flowed(?)
;; mu4e-compose-format-flowed
2018-03-01 18:41:32 +01:00
;; Also crypt to self so that we can read sent e-mails.
mml-secure-openpgp-encrypt-to-self t
;; Because default completion can be extended (e.g. Helm, Ivy).
mu4e-completing-read-function 'completing-read)
2017-10-08 20:36:28 +02:00
;;; Press "aV" to view in browser.
(add-to-list 'mu4e-view-actions '("ViewInBrowser" . mu4e-action-view-in-browser) t)
2017-10-08 20:36:28 +02:00
;;; Unicode chars for decoration might cause issues with some fonts or in terminals.
;;; https://github.com/djcb/mu/issues/733
;;; https://github.com/djcb/mu/issues/1062
;; (setq mu4e-use-fancy-chars t)
;;; REVIEW: Sorting in ascending order is impeded by `mu4e-search-results-limit': the 500 oldest e-mails will be displayed first.
;;; https://github.com/djcb/mu/issues/809
;; (setq mu4e-headers-sort-direction 'ascending)
;;; Since we sort in ascending direction, we default to the end of buffer.
;; (add-hook 'mu4e-headers-found-hook 'end-of-buffer)
2018-02-15 13:28:49 +01:00
(defvar ambrevar/mu4e-compose-fortune-p t "Whether or not to include a fortune in the signature.")
(defun ambrevar/mu4e-add-fortune-signature ()
(require 'functions) ; For `call-process-to-string'.
(setq mu4e-compose-signature
2018-02-15 13:28:49 +01:00
(if ambrevar/mu4e-compose-fortune-p
2017-10-15 21:09:30 +02:00
(format "%s\n\n%s"
user-full-name
(ambrevar/call-process-to-string "fortune" "-s"))
2017-10-15 21:09:30 +02:00
user-full-name)))
2018-02-15 13:28:49 +01:00
(add-hook 'mu4e-compose-pre-hook 'ambrevar/mu4e-add-fortune-signature)
2017-10-10 17:09:19 +02:00
;;; Make some e-mails stand out a bit.
(set-face-foreground 'mu4e-unread-face "yellow")
(set-face-attribute 'mu4e-flagged-face nil :inherit 'font-lock-warning-face)
2017-10-10 17:09:19 +02:00
;;; Confirmation on every mark execution is too slow to my taste.
2018-02-15 13:28:49 +01:00
(defun ambrevar/mu4e-mark-execute-all-no-confirm ()
2017-10-10 17:09:19 +02:00
(interactive)
(mu4e-mark-execute-all t))
2018-02-15 13:28:49 +01:00
(define-key mu4e-headers-mode-map "x" 'ambrevar/mu4e-mark-execute-all-no-confirm)
2017-10-10 17:09:19 +02:00
2017-07-31 08:58:15 +02:00
(when (require 'helm-mu nil t)
(dolist (map (list mu4e-headers-mode-map mu4e-main-mode-map mu4e-view-mode-map))
2017-10-28 12:29:24 +02:00
(define-key map "s" 'helm-mu)))
2017-07-31 08:58:15 +02:00
2018-02-15 13:28:49 +01:00
(defvar ambrevar/mu4e-compose-signed-p nil)
(defvar ambrevar/mu4e-compose-signed-and-crypted-p nil)
(defun ambrevar/mu4e-compose-maybe-signed-and-crypted ()
"Maybe sign or encrypt+sign message.
Message is signed or encrypted+signed when replying to a signed or encrypted
message, respectively.
Alternatively, message is signed or encrypted+signed if
2018-02-15 13:28:49 +01:00
`ambrevar/mu4e-compose-signed-p' or `ambrevar/mu4e-compose-signed-and-crypted-p' is
non-nil, respectively.
This function is suitable for `mu4e-compose-mode-hook'."
(let ((msg mu4e-compose-parent-message))
(cond
2018-02-15 13:28:49 +01:00
((or ambrevar/mu4e-compose-signed-and-crypted-p
(and msg (member 'encrypted (mu4e-message-field msg :flags))))
(mml-secure-message-sign-encrypt))
2018-02-15 13:28:49 +01:00
((or ambrevar/mu4e-compose-signed-p
(and msg (member 'signed (mu4e-message-field msg :flags))))
(mml-secure-message-sign-pgpmime)))))
2018-02-15 13:28:49 +01:00
(add-hook 'mu4e-compose-mode-hook 'ambrevar/mu4e-compose-maybe-signed-and-crypted)
2017-12-19 09:47:51 +01:00
;;; Org capture
(when (require 'org-mu4e nil t)
(dolist (map (list mu4e-view-mode-map mu4e-headers-mode-map))
;; Org mode has "C-c C-t" for 'org-todo.
(define-key map (kbd "C-c C-t") 'org-mu4e-store-and-capture))
2017-12-19 09:47:51 +01:00
(setq org-mu4e-link-query-in-headers-mode nil))
(load "~/personal/mail/mu4e.el" t)
(provide 'init-mu4e)