2015-12-02 14:23:39 +00:00
#+TITLE : Mu4e layer
2016-03-31 02:59:55 +00:00
2019-05-02 21:49:30 +00:00
#+TAGS : e-mail|layer
2019-05-07 20:05:06 +00:00
* Table of Contents :TOC_5_gh:noexport:
2017-11-03 12:48:57 +00:00
- [[#description ][Description ]]
2017-11-03 13:18:22 +00:00
- [[#features ][Features: ]]
2017-05-22 14:16:12 +00:00
- [[#install ][Install ]]
- [[#commands ][Commands ]]
- [[#global-bindings ][Global bindings ]]
- [[#headers-mode ][Headers mode ]]
- [[#view-mode ][View mode ]]
2021-01-02 04:41:38 +00:00
- [[#compose-mode ][Compose mode ]]
2017-05-22 14:16:12 +00:00
- [[#configuration ][Configuration ]]
- [[#maildirs-extension ][Maildirs extension ]]
- [[#multiple-accounts ][Multiple Accounts ]]
2016-02-02 15:50:27 +00:00
- [[#async-mode ][Async mode ]]
- [[#attachment-directory ][Attachment directory ]]
2017-05-22 14:16:12 +00:00
- [[#example-configuration ][Example configuration ]]
- [[#notifications ][Notifications ]]
- [[#os-notifications ][OS notifications ]]
- [[#mode-line-notifications ][Mode-line notifications ]]
- [[#spacemacs-layout-integration ][Spacemacs layout integration ]]
2021-01-02 04:41:38 +00:00
- [[#org-mu4e-integration ][Org-mu4e integration ]]
- [[#mu4e-link-support-in-org-mode ][Mu4e link support in Org mode ]]
- [[#composing-org-mode-messages-in-mu4e ][Composing Org mode messages in mu4e ]]
2017-05-22 14:16:12 +00:00
- [[#see-also ][See also ]]
2015-08-02 05:30:30 +00:00
2017-11-03 12:48:57 +00:00
* Description
2019-09-01 21:04:17 +00:00
This layer adds support for the =Mu4e= email client.
2017-11-03 12:48:57 +00:00
2017-11-03 13:18:22 +00:00
** Features:
2018-09-19 03:54:47 +00:00
- Search, read, reply, move, and delete email.
- Search-based: no folders, only queries.
- UI optimized for speed: quick keystrokes for common actions.
2019-06-01 17:13:30 +00:00
- Very extendable and customizable.
2018-09-19 03:54:47 +00:00
- Integration with Helm.
2019-09-01 21:04:17 +00:00
- Maildir summary using [[https://github.com/agpchil/mu4e-maildirs-extension ][mu4e-mailidirs-extension ]]
2018-09-19 03:54:47 +00:00
- Notifications using [[https://github.com/iqbalansari/mu4e-alert ][mu4e-alert ]]
2017-11-03 13:18:22 +00:00
2016-01-06 05:21:55 +00:00
* Install
2019-09-01 21:04:17 +00:00
In order to use this layer you must install =mu= and =mu4e= separately.
Typically =mu4e= will be bundled with =mu= (this is the case on many Linux
distributions).
2015-08-02 05:30:30 +00:00
2019-10-13 05:27:17 +00:00
If you're on macOS and install =mu= using Homebrew, you must specify the
2016-07-25 17:46:24 +00:00
location of your Emacs binary at install time using the EMACS environment
2016-11-21 15:57:14 +00:00
variable, as well as passing the =--with-emacs= option:
2016-07-25 17:46:24 +00:00
2018-09-19 03:54:47 +00:00
#+BEGIN_SRC shell
brew install mu --with-emacs
#+END_SRC
2016-07-25 17:46:24 +00:00
2019-09-01 21:04:17 +00:00
If the installation directory of =mu4e= is not in Emacs' load path, you can set
2015-11-11 20:45:30 +00:00
the layer variable =mu4e-installation-path= , for example:
2015-08-02 05:30:30 +00:00
2018-09-19 03:54:47 +00:00
#+BEGIN_SRC emacs-lisp
2015-11-11 20:45:30 +00:00
(setq-default dotspacemacs-configuration-layers
'((mu4e :variables
mu4e-installation-path "/usr/share/emacs/site-lisp")))
2018-09-19 03:54:47 +00:00
#+END_SRC
2015-11-11 20:45:30 +00:00
2016-01-08 20:13:02 +00:00
Then add this layer to your =~/.spacemacs= . You will need to add =mu4e= to the
existing =dotspacemacs-configuration-layers= list in this file.
2016-01-06 05:21:55 +00:00
2015-11-11 20:45:30 +00:00
* Commands
2015-11-23 06:55:56 +00:00
** Global bindings
2018-10-23 14:18:21 +00:00
| Key binding | Command |
2018-01-20 04:31:06 +00:00
|------------------------+---------------------------------|
2020-06-28 21:25:04 +00:00
| ~SPC a e m~ | Start mu4e |
2018-01-20 04:31:06 +00:00
| ~SPC m S~ or ~SPC m /~ | Search emails (requires helm) |
| ~SPC m C~ | Search contacts (requires helm) |
2019-09-01 21:04:17 +00:00
| ~C-x m~ | Compose new message |
2015-08-02 05:30:30 +00:00
2015-11-23 06:55:56 +00:00
** Headers mode
2018-10-23 14:18:21 +00:00
| Key binding | Command |
|-------------+-------------------------------------------------------------|
| ~J~ | Go to next unread thread marking other mail read on the way |
| ~C-j~ | Next header |
| ~C-k~ | Previous header |
2015-11-23 06:55:56 +00:00
** View mode
2018-10-23 14:18:21 +00:00
| Key binding | Command |
|-------------+-------------------------------------------------------------|
| ~J~ | Go to next unread thread marking other mail read on the way |
| ~C-j~ | Next header |
| ~C-k~ | Previous header |
2015-11-23 06:55:56 +00:00
2021-01-02 04:41:38 +00:00
** Compose mode
| Key binding | Command |
|------------------------+--------------------------------|
| ~SPC m c~ or ~SPC m ,~ | Send the message and exit |
| ~SPC m k~ or ~SPC m a~ | Kill the message buffer |
| ~SPC m s~ | Auto-save and bury the message |
| ~SPC m f~ | Add file as attachment |
2021-01-03 07:55:29 +00:00
| ~SPC m o~ | Compose in Org-mode syntax |
2021-01-02 04:41:38 +00:00
2015-11-11 20:45:30 +00:00
* Configuration
2018-10-23 14:18:21 +00:00
Configuration varies too much to give precise instructions. What follows is one
2019-09-01 21:04:17 +00:00
example configuration. Refer to =mu4e= 's manual for more detailed configuration
2015-08-02 05:30:30 +00:00
instructions.
2016-01-05 17:45:57 +00:00
** Maildirs extension
2019-09-01 21:04:17 +00:00
The [[https://github.com/agpchil/mu4e-maildirs-extension ][maildirs extension ]] adds a list of all your maildirs to the main =mu4e= view
2016-01-05 17:45:57 +00:00
that by default shows the unread and total mail counts for all your mail under
your base mail directory.
2017-09-14 20:25:43 +00:00
The maildirs extension is not enabled by default. To activate it, change the
variable =mu4e-use-maildirs-extension= to a non-nil value:
2018-09-19 03:54:47 +00:00
#+BEGIN_SRC emacs-lisp
2017-09-14 20:25:43 +00:00
(setq-default dotspacemacs-configuration-layers
'((mu4e :variables
mu4e-use-maildirs-extension t)))
2018-09-19 03:54:47 +00:00
#+END_SRC
2016-01-05 17:45:57 +00:00
2015-11-13 09:03:25 +00:00
** Multiple Accounts
2019-09-01 21:04:17 +00:00
With =mu 0.9.16= , =mu4e= comes with a native contexts feature for managing
2016-01-27 05:05:35 +00:00
multiple accounts.
2015-08-02 05:30:30 +00:00
2016-01-27 05:05:35 +00:00
The following example is taken from the manual:
2016-01-19 16:06:34 +00:00
#+BEGIN_SRC emacs-lisp
2016-01-27 05:05:35 +00:00
(setq mu4e-contexts
`( ,(make-mu4e-context
:name "Private"
:enter-func (lambda () (mu4e-message "Switch to the Private context"))
;; leave-func not defined
:match-func (lambda (msg)
(when msg
(mu4e-message-contact-field-matches msg
:to "aliced@home.example.com")))
:vars '( ( user-mail-address . "aliced@home.example.com" )
( user-full-name . "Alice Derleth" )
( mu4e-compose-signature .
(concat
"Alice Derleth\n"
"Lauttasaari, Finland\n"))))
,(make-mu4e-context
:name "Work"
:enter-func (lambda () (mu4e-message "Switch to the Work context"))
;; leave-fun not defined
:match-func (lambda (msg)
(when msg
(mu4e-message-contact-field-matches msg
:to "aderleth@miskatonic.example.com")))
:vars '( ( user-mail-address . "aderleth@miskatonic.example.com" )
( user-full-name . "Alice Derleth" )
( mu4e-compose-signature .
(concat
"Prof. Alice Derleth\n"
"Miskatonic University, Dept. of Occult Sciences\n"))))))
;; set `mu4e-context-policy` and `mu4e-compose-policy` to tweak when mu4e should
;; guess or ask the correct context, e.g.
;; start with the first (default) context;
;; default is to ask-if-none (ask when there's no context yet, and none match)
;; (setq mu4e-context-policy 'pick-first)
;; compose with the current context is no context matches;
;; default is to ask
2018-11-30 04:29:11 +00:00
;; (setq mu4e-compose-context-policy nil)
2016-01-19 16:06:34 +00:00
#+END_SRC
2016-01-27 05:05:35 +00:00
Note: We used to have a hack to support multiple accounts with older version of
2019-09-01 21:04:17 +00:00
=mu= but we removed it to encourage people to update their version and use the
2016-01-27 05:05:35 +00:00
new contexts feature.
2016-01-31 08:20:05 +00:00
2016-02-02 15:50:27 +00:00
** Async mode
2019-09-01 21:04:17 +00:00
=mu4e= can send mails in async mode, which speeds up sending as you do not have
2016-02-02 15:50:27 +00:00
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
2019-09-01 21:04:17 +00:00
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
=dotspacemacs/user-config= :
2016-02-02 15:50:27 +00:00
#+BEGIN_SRC emacs-lisp
(setq mu4e-attachment-dir "~/files")
#+END_SRC
2015-11-11 20:45:30 +00:00
** Example configuration
2015-08-02 05:30:30 +00:00
#+BEGIN_SRC emacs-lisp
;;; Set up some common mu4e variables
(setq mu4e-maildir "~/.mail"
mu4e-trash-folder "/Trash"
mu4e-refile-folder "/Archive"
mu4e-get-mail-command "mbsync -a"
mu4e-update-interval nil
mu4e-compose-signature-auto-include nil
mu4e-view-show-images t
mu4e-view-show-addresses t)
;;; Mail directory shortcuts
(setq mu4e-maildir-shortcuts
'(("/gmail/INBOX" . ?g)
("/college/INBOX" . ?c)))
;;; Bookmarks
(setq mu4e-bookmarks
`(("flag:unread AND NOT flag:trashed" "Unread messages" ?u)
("date:today..now" "Today's messages" ?t)
("date:7d..now" "Last 7 days" ?w)
("mime:image/*" "Messages with images" ?p)
(,(mapconcat 'identity
(mapcar
(lambda (maildir)
(concat "maildir:" (car maildir)))
mu4e-maildir-shortcuts) " OR ")
"All inboxes" ?i)))
#+END_SRC
2016-01-30 01:56:33 +00:00
** Notifications
2016-11-22 20:53:50 +00:00
=mu4e-alert= is an extension that provides desktop notifications and adds the
2016-01-30 01:56:33 +00:00
count of unread messages to the modeline.
[[https://raw.githubusercontent.com/iqbalansari/mu4e-alert/master/screenshots/mu4e-alert-in-action.png ]]
2016-02-14 16:20:14 +00:00
For an extended documentation of the available customizations please refer to
2019-05-26 20:58:52 +00:00
[[https://github.com/iqbalansari/mu4e-alert#user-content-customizations ][mu4e-alert's documentation ]]
2016-02-14 16:20:14 +00:00
*** OS notifications
2016-01-30 01:56:33 +00:00
To enable notifications about new messages, add the following line to your
2016-11-22 20:53:50 +00:00
=dotspacemacs/user-config= :
2016-01-30 01:56:33 +00:00
#+BEGIN_SRC emacs-lisp
(setq mu4e-enable-notifications t)
#+END_SRC
2016-02-14 16:20:14 +00:00
or use layer variables when you add the layer to
=dotspacemacs-configuration-layers= :
#+BEGIN_SRC emacs-lisp
(mu4e :variables mu4e-enable-notifications t)
#+END_SRC
2016-11-22 20:53:50 +00:00
By default, notifications will be shown in the =*Messages*= buffer. To enable
2016-01-30 01:56:33 +00:00
desktop notifications about new messages, add the following lines to
2016-11-22 20:53:50 +00:00
your =dotspacemacs/user-config= , according to your operating system and the
2016-01-30 01:56:33 +00:00
installed libraries:
#+BEGIN_SRC emacs-lisp
(with-eval-after-load 'mu4e-alert
;; Enable Desktop notifications
Various documentation copy-edits
Follow up the changes in the previous commit with some minor improvements
to formatting, grammar, spelling, and wording.
* layers/+distributions/spacemacs-docker/README.org: Replace "+" with
"and".
* layers/+email/mu4e/README.org: Use full sentences in the comments in the
mu4e-alert example.
* layers/+intl/japanese/README.org: Use verbatim markers for names of
files, functions, packages, and variables. Capitalize "Linux".
* layers/+os/osx/README.org: Capitalize "Emacs", "Vim", and "Evil".
* layers/+os/osx/config.el (osx-command-as, osx-use-dictionary-app):
* layers/+os/osx/keybindings.el (spacemacs/system-is-mac): Improve
docstrings.
* layers/+readers/dash/README.org: Capitalize "API", "Helm", and "Ivy".
* layers/+spacemacs/spacemacs-defaults/config.el
(delete-by-moving-to-trash): Use full sentences in comment.
* layers/+spacemacs/spacemacs-defaults/funcs.el
(spacemacs/toggle-frame-fullscreen-non-native): Improve docstrings.
2019-10-13 06:03:09 +00:00
(mu4e-alert-set-default-style 'notifications)) ; For Linux.
;; (mu4e-alert-set-default-style 'libnotify)) ; Alternative for Linux
2019-10-13 05:27:17 +00:00
;; (mu4e-alert-set-default-style 'notifier)) ; For macOS (through the
Various documentation copy-edits
Follow up the changes in the previous commit with some minor improvements
to formatting, grammar, spelling, and wording.
* layers/+distributions/spacemacs-docker/README.org: Replace "+" with
"and".
* layers/+email/mu4e/README.org: Use full sentences in the comments in the
mu4e-alert example.
* layers/+intl/japanese/README.org: Use verbatim markers for names of
files, functions, packages, and variables. Capitalize "Linux".
* layers/+os/osx/README.org: Capitalize "Emacs", "Vim", and "Evil".
* layers/+os/osx/config.el (osx-command-as, osx-use-dictionary-app):
* layers/+os/osx/keybindings.el (spacemacs/system-is-mac): Improve
docstrings.
* layers/+readers/dash/README.org: Capitalize "API", "Helm", and "Ivy".
* layers/+spacemacs/spacemacs-defaults/config.el
(delete-by-moving-to-trash): Use full sentences in comment.
* layers/+spacemacs/spacemacs-defaults/funcs.el
(spacemacs/toggle-frame-fullscreen-non-native): Improve docstrings.
2019-10-13 06:03:09 +00:00
; terminal notifier app).
;; (mu4e-alert-set-default-style 'growl)) ; Alternative for macOS.
2016-01-30 01:56:33 +00:00
#+END_SRC
2016-02-14 16:20:14 +00:00
*** Mode-line notifications
To enable mode-line display about new messages, add the following line to
2016-11-22 20:53:50 +00:00
your =dotspacemacs/user-config= :
2016-01-30 01:56:33 +00:00
#+BEGIN_SRC emacs-lisp
(setq mu4e-enable-mode-line t)
#+END_SRC
2016-02-14 16:20:14 +00:00
or use layer variables when you add the layer to
=dotspacemacs-configuration-layers= :
#+BEGIN_SRC emacs-lisp
(mu4e :variables mu4e-enable-mode-line t)
#+END_SRC
2016-01-30 01:56:33 +00:00
2017-05-11 16:03:52 +00:00
** Spacemacs layout integration
2017-08-18 19:07:43 +00:00
A [[https://github.com/syl20bnr/spacemacs/blob/develop/doc/DOCUMENTATION.org#layouts-and-workspaces ][Spacemacs custom layout ]] is defined by the layer. The name and the key binding
2017-05-11 16:03:52 +00:00
for it can be customized with the following layer variables:
- =mu4e-spacemacs-layout-name= for the layout name,
- =mu4e-spacemacs-layout-binding= for the key binding.
2019-09-01 21:04:17 +00:00
- =mu4e-spacemacs-kill-layout-on-exit= for automatically removing layout when
quitting =mu4e= .
2017-05-11 16:03:52 +00:00
By default the values are:
#+BEGIN_SRC emacs-lisp
2018-08-25 22:20:15 +00:00
(setq-default dotspacemacs-configuration-layers
'((mu4e :variables mu4e-spacemacs-layout-name "@Mu4e"
mu4e-spacemacs-layout-binding "m"
mu4e-spacemacs-kill-layout-on-exit t)))
2017-05-11 16:03:52 +00:00
#+END_SRC
2021-01-02 04:41:38 +00:00
** Org-mu4e integration
*** Mu4e link support in Org mode
Feature ~mu4e-org~ supports links to mu4e messages in Org mode in the form of
~[[mu4e:msgid::***][link text]]~ . Enabled by default. You can disable it by
setting the ~mu4e-org-link-support~ variable when including the layer.
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers
'((mu4e :variables
mu4e-org-link-support nil)))
#+END_SRC
*** Composing Org mode messages in mu4e
Feature ~org-mu4e~ supports composing emails in Org mode format. Disabled by
default. You can enable it by setting the ~mu4e-org-compose-support~ variable
when including the layer.
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers
'((mu4e :variables
mu4e-org-compose-support t)))
#+END_SRC
Then when composing, hit keys ~SPC m o~ to enable the
~org-mu4e-compose-org-mode~ mode. Note that you need to set the variable
~org-mu4e-convert-to-html~ if you want the message to be converted before
sending.
2015-11-11 20:45:30 +00:00
* See also
2019-09-01 21:04:17 +00:00
Refer to the official =mu= and =mu4e= documentation for additional info.
2015-08-02 05:30:30 +00:00
- [[http://www.djcbsoftware.nl/code/mu/mu4e/index.html ][mu4e Manual ]]