<commit_before>#+TITLE:   email/mu4e
#+DATE:    April 8, 2017
#+SINCE:   v2.0
#+STARTUP: inlineimages

* Table of Contents :TOC:
- [[#description][Description]]
  - [[#module-flags][Module Flags]]
  - [[#plugins][Plugins]]
- [[#prerequisites][Prerequisites]]
  - [[#macos][MacOS]]
  - [[#arch-linux][Arch Linux]]
  - [[#nixos][NixOS]]
  - [[#opensuse][openSUSE]]
  - [[#debianubuntu][Debian/Ubuntu]]
- [[#features][Features]]
- [[#configuration][Configuration]]
  - [[#offlineimap][offlineimap]]
  - [[#mbsync][mbsync]]
  - [[#mu-and-mu4e][mu and mu4e]]
- [[#troubleshooting][Troubleshooting]]
  - [[#no-such-file-or-directory-mu4e][=No such file or directory, mu4e=]]
  - [[#void-function-org-time-add-error-on-gentoo][~(void-function org-time-add)~ error on Gentoo]]

* Description
This module makes Emacs an email client, using ~mu4e~.

#+begin_quote
I want to live in Emacs, but as we all know, living is incomplete without email.
So I prayed to the text editor gods and they (I) answered. Emacs+evil's editing
combined with org-mode for writing emails? /Yes please./

It uses ~mu4e~ to read my email, but depends on ~offlineimap~ (to sync my email
via IMAP) and ~mu~ (to index my mail into a format ~mu4e~ can understand).
#+end_quote

** Module Flags
+ ~+gmail~ Enables gmail-specific configuration.

** Plugins
This module install no plugins.

* Prerequisites
This module requires:

+ Either ~mbsync~ (default) or ~offlineimap~ (to sync mail with)
+ ~mu~, to index your downloaded messages and to provide the ~mu4e~ package.

** MacOS
#+BEGIN_SRC sh
brew install mu
# And one of the following
brew install isync  # mbsync
brew install offlineimap
#+END_SRC

** Arch Linux
Run one of the following commands.

#+BEGIN_SRC sh
sudo pacman -S isync  # mbsync
# OR
sudo pacman -S offlineimap
#+END_SRC

Install ~mu~, which is not available in the main repositories but in the AUR, by
using for example the AUR helper ~yay~.

#+BEGIN_SRC sh
yay -S mu
#+END_SRC

** NixOS
#+BEGIN_SRC nix
environment.systemPackages = with pkgs; [
    mu
    # And one of the following
    isync
    offlineimap
];
#+END_SRC

[[https://github.com/Emiller88/dotfiles/blob/5eaabedf1b141c80a8d32e1b496055231476f65e/modules/shell/mail.nix][An example of setting up mbsync and mu with home-manager]]

** openSUSE
Remove ~#~ in ~#sync_program=offlineimap~ to choose ~offlineimap~ instead of
~mbsync~.

#+BEGIN_SRC sh :dir /sudo::
sync_program=isync # mbsync
#sync_program=offlineimap

sudo zypper install maildir-utils $sync_program
#+END_SRC

** Debian/Ubuntu
Run the command corresponding to the desired backend and the last one.
#+BEGIN_SRC sh
sudo apt-get install isync  # mbsync
# or
sudo apt-get install offlineimap
# then
sudo apt-get install maildir-utils # mu
#+END_SRC
* TODO Features

* Configuration
** offlineimap
This module uses =mbsync= by default. To use =offlineimap=, change ~+mu4e-backend~:

#+BEGIN_SRC emacs-lisp
(setq +mu4e-backend 'offlineimap)
#+END_SRC

Next, you need to write a configuration file for =offlineimap=. Mine can be found
[[https://github.com/hlissner/dotfiles/tree/master/shell/mu][in my dotfiles repository]]. It is configured to download mail to ~\~/.mail~. I
use [[https://www.passwordstore.org/][unix pass]] to securely store my login credentials. You can find a *very*
detailed configuration [[https://github.com/OfflineIMAP/offlineimap/blob/master/offlineimap.conf][here]].

Next you can download your email with ~offlineimap -o~. This may take a while,
especially if you have thousands of mails.

You can now proceed with the [[#mu-and-mu4e][mu and mu4e]] section.

** mbsync
The steps needed to set up =mu4e= with =mbsync= are very similar to the ones for
[[#offlineimap][offlineimap]].

Start with writing a ~\~/.mbsyncrc~. An example for GMAIL can be found on
[[http://pragmaticemacs.com/emacs/migrating-from-offlineimap-to-mbsync-for-mu4e/][pragmaticemacs.com]]. A non-GMAIL example is available as a gist [[https://gist.github.com/agraul/60977cc497c3aec44e10591f94f49ef0][here]]. The [[http://isync.sourceforge.net/mbsync.html][manual<commit_msg>Dotfiles were refactored, pinned to arbitrary point with valid example<commit_after>#+TITLE:   email/mu4e
#+DATE:    April 8, 2017
#+SINCE:   v2.0
#+STARTUP: inlineimages

* Table of Contents :TOC:
- [[#description][Description]]
  - [[#module-flags][Module Flags]]
  - [[#plugins][Plugins]]
- [[#prerequisites][Prerequisites]]
  - [[#macos][MacOS]]
  - [[#arch-linux][Arch Linux]]
  - [[#nixos][NixOS]]
  - [[#opensuse][openSUSE]]
  - [[#debianubuntu][Debian/Ubuntu]]
- [[#features][Features]]
- [[#configuration][Configuration]]
  - [[#offlineimap][offlineimap]]
  - [[#mbsync][mbsync]]
  - [[#mu-and-mu4e][mu and mu4e]]
- [[#troubleshooting][Troubleshooting]]
  - [[#no-such-file-or-directory-mu4e][=No such file or directory, mu4e=]]
  - [[#void-function-org-time-add-error-on-gentoo][~(void-function org-time-add)~ error on Gentoo]]

* Description
This module makes Emacs an email client, using ~mu4e~.

#+begin_quote
I want to live in Emacs, but as we all know, living is incomplete without email.
So I prayed to the text editor gods and they (I) answered. Emacs+evil's editing
combined with org-mode for writing emails? /Yes please./

It uses ~mu4e~ to read my email, but depends on ~offlineimap~ (to sync my email
via IMAP) and ~mu~ (to index my mail into a format ~mu4e~ can understand).
#+end_quote

** Module Flags
+ ~+gmail~ Enables gmail-specific configuration.

** Plugins
This module install no plugins.

* Prerequisites
This module requires:

+ Either ~mbsync~ (default) or ~offlineimap~ (to sync mail with)
+ ~mu~, to index your downloaded messages and to provide the ~mu4e~ package.

** MacOS
#+BEGIN_SRC sh
brew install mu
# And one of the following
brew install isync  # mbsync
brew install offlineimap
#+END_SRC

** Arch Linux
Run one of the following commands.

#+BEGIN_SRC sh
sudo pacman -S isync  # mbsync
# OR
sudo pacman -S offlineimap
#+END_SRC

Install ~mu~, which is not available in the main repositories but in the AUR, by
using for example the AUR helper ~yay~.

#+BEGIN_SRC sh
yay -S mu
#+END_SRC

** NixOS
#+BEGIN_SRC nix
environment.systemPackages = with pkgs; [
    mu
    # And one of the following
    isync
    offlineimap
];
#+END_SRC

[[https://github.com/Emiller88/dotfiles/blob/5eaabedf1b141c80a8d32e1b496055231476f65e/modules/shell/mail.nix][An example of setting up mbsync and mu with home-manager]]

** openSUSE
Remove ~#~ in ~#sync_program=offlineimap~ to choose ~offlineimap~ instead of
~mbsync~.

#+BEGIN_SRC sh :dir /sudo::
sync_program=isync # mbsync
#sync_program=offlineimap

sudo zypper install maildir-utils $sync_program
#+END_SRC

** Debian/Ubuntu
Run the command corresponding to the desired backend and the last one.
#+BEGIN_SRC sh
sudo apt-get install isync  # mbsync
# or
sudo apt-get install offlineimap
# then
sudo apt-get install maildir-utils # mu
#+END_SRC
* TODO Features

* Configuration
** offlineimap
This module uses =mbsync= by default. To use =offlineimap=, change ~+mu4e-backend~:

#+BEGIN_SRC emacs-lisp
(setq +mu4e-backend 'offlineimap)
#+END_SRC

Next, you need to write a configuration file for =offlineimap=. Mine can be found
[[https://github.com/hlissner/dotfiles/blob/be0dce5dae8f3cbafaac0cc44269d84b4a742c46/shell/mu/][in my dotfiles repository]]. It is configured to download mail to ~\~/.mail~. I
use [[https://www.passwordstore.org/][unix pass]] to securely store my login credentials. You can find a *very*
detailed configuration [[https://github.com/OfflineIMAP/offlineimap/blob/master/offlineimap.conf][here]].

Next you can download your email with ~offlineimap -o~. This may take a while,
especially if you have thousands of mails.

You can now proceed with the [[#mu-and-mu4e][mu and mu4e]] section.

** mbsync
The steps needed to set up =mu4e= with =mbsync= are very similar to the ones for
[[#offlineimap][offlineimap]].

Start with writing a ~\~/.mbsyncrc~. An example for GMAIL can be found on
[[http://pragmaticemacs.com/emacs/migrating-from-offlineimap-to-mbsync-for-mu4e/][pragmaticemacs.com]]. A non-GMAIL example is available as a gist [[https://gist.github.com/agraul/60977cc497c3aec44e10591f94f49ef0][here]]. The [[http://isync.sourceforge.net/mbsync.html][manual
{'fraction_non_alphanumeric': 0.12766990291262137, 'fraction_numerical': 0.0191747572815534, 'mean_word_length': 4.663917525773196, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 10, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '97773', 'n_tokens_mistral': 3072, 'n_tokens_neox': 2901, 'n_words': 902}