mu4e - better defaults, async and utility functions
This PR does a few things: - supports async mode for sending mails - registers imagemagick as handler for images if it exists - sets default downloads directory if it exists - sets a few (more) sane defaults - supports format=flowed in messages
This commit is contained in:
parent
0b484bc6cd
commit
0605476083
|
@ -11,6 +11,8 @@
|
|||
- [[#configuration][Configuration]]
|
||||
- [[#maildirs-extension][Maildirs extension]]
|
||||
- [[#multiple-accounts][Multiple Accounts]]
|
||||
- [[#async-mode][Async mode]]
|
||||
- [[#attachment-directory][Attachment directory]]
|
||||
- [[#example-configuration][Example configuration]]
|
||||
- [[#notifications][Notifications]]
|
||||
- [[#os-notifications][OS notifications]]
|
||||
|
@ -60,6 +62,7 @@ existing =dotspacemacs-configuration-layers= list in this file.
|
|||
| ~SPC a M~ | Start mu4e |
|
||||
| ~SPC m S~ or ~SPC m /~ | Search emails (requires helm) |
|
||||
| ~SPC m C~ | Search contacts (requires helm) |
|
||||
| C-x m | Compose new message |
|
||||
|
||||
** Headers mode
|
||||
|
||||
|
@ -144,6 +147,26 @@ Note: We used to have a hack to support multiple accounts with older version of
|
|||
`mu` but we removed it to encourage people to update their version and use the
|
||||
new contexts feature.
|
||||
|
||||
** Async mode
|
||||
mu4e can send mails in async mode, which speeds up sending as you do not have
|
||||
to wait for the email to be sent. This is off by default but you can enable
|
||||
it by setting the ~mu4e-enable-async-operations~ variable when including the
|
||||
layer.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(setq-default dotspacemacs-configuration-layers
|
||||
'((mu4e :variables
|
||||
mu4e-enable-async-operations t)))
|
||||
#+END_SRC
|
||||
|
||||
** Attachment directory
|
||||
By default mu4e will save attachment files to $HOME, but this layer changes
|
||||
that to $HOME/Downloads if it exists. You can override this in your user-config:
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(setq mu4e-attachment-dir "~/files")
|
||||
#+END_SRC
|
||||
|
||||
** Example configuration
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
;;; Set up some common mu4e variables
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
(defvar mu4e-spacemacs-layout-binding "m"
|
||||
"Binding used in the setup for `spacemacs-layouts' micro-state")
|
||||
|
||||
(defvar mu4e-enable-async-operations nil
|
||||
"Prefer async operations when sending emails.")
|
||||
|
||||
(defvar mu4e-enable-notifications nil
|
||||
"If non-nil, enable desktop notifications for unread emails.")
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
;;; funcs.el --- mu4e Layer functions File for Spacemacs
|
||||
;;
|
||||
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
|
||||
;;
|
||||
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
||||
;; URL: https://github.com/syl20bnr/spacemacs
|
||||
;;
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;;; License: GPLv3
|
||||
|
||||
(defun mu4e/load-signature-from-file (file)
|
||||
"Load signature from FILE and strip separator if needed."
|
||||
(setq mu4e-compose-signature
|
||||
(with-temp-buffer
|
||||
(insert-file-contents file)
|
||||
(flush-lines message-signature-separator)
|
||||
(buffer-string))))
|
||||
|
||||
(defun mu4e/message-is-for-p (msg rx)
|
||||
"Check if to, cc or bcc field in MSG has any address in RX."
|
||||
(when (and msg rx)
|
||||
(or (mu4e-message-contact-field-matches msg :to rx)
|
||||
(mu4e-message-contact-field-matches msg :cc rx)
|
||||
(mu4e-message-contact-field-matches msg :bcc rx))))
|
|
@ -42,7 +42,15 @@
|
|||
:init
|
||||
(progn
|
||||
(spacemacs/set-leader-keys "a M" 'mu4e)
|
||||
(global-set-key (kbd "C-x m") 'mu4e-compose-new))
|
||||
(global-set-key (kbd "C-x m") 'mu4e-compose-new)
|
||||
(setq mu4e-completing-read-function 'completing-read
|
||||
mu4e-use-fancy-chars 't
|
||||
mu4e-view-show-images 't
|
||||
message-kill-buffer-on-exit 't)
|
||||
(let ((dir "~/Downloads"))
|
||||
(when (file-directory-p dir)
|
||||
(setq mu4e-attachment-dir dir))))
|
||||
|
||||
:config
|
||||
(progn
|
||||
(evilified-state-evilify-map mu4e-main-mode-map
|
||||
|
@ -78,10 +86,19 @@
|
|||
"s" 'message-dont-send ; saves as draft
|
||||
"f" 'mml-attach-file)
|
||||
|
||||
(setq mu4e-completing-read-function 'completing-read)
|
||||
(when mu4e-enable-async-operations
|
||||
(require 'smtpmail-async)
|
||||
(setq send-mail-function 'async-smtpmail-send-it
|
||||
message-send-mail-function 'async-smtpmail-send-it))
|
||||
|
||||
(when (fboundp 'imagemagick-register-types)
|
||||
(imagemagick-register-types))
|
||||
|
||||
(add-to-list 'mu4e-view-actions
|
||||
'("View in browser" . mu4e-action-view-in-browser) t))))
|
||||
'("View in browser" . mu4e-action-view-in-browser) t)
|
||||
|
||||
(add-hook 'mu4e-compose-mode-hook
|
||||
(lambda () (use-hard-newlines t 'guess))))))
|
||||
|
||||
(defun mu4e/init-mu4e-alert ()
|
||||
(use-package mu4e-alert
|
||||
|
@ -111,6 +128,4 @@
|
|||
|
||||
(defun mu4e/pre-init-org ()
|
||||
;; load org-mu4e when org is actually loaded
|
||||
(with-eval-after-load 'org
|
||||
(require 'org-mu4e nil 'noerror)
|
||||
(require 'org-notmuch nil 'noerror)))
|
||||
(with-eval-after-load 'org (require 'org-mu4e nil 'noerror)))
|
||||
|
|
Loading…
Reference in New Issue