2020-05-09 21:41:30 -05:00
#+TITLE : email/notmuch
2020-05-10 18:26:33 -04:00
#+DATE : May 5, 2019
#+SINCE : v2.0
2020-05-09 21:41:30 -05:00
#+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 ]]
- [[#gmailier ][Gmailier ]]
- [[#offlineimap ][offlineimap ]]
- [[#mbsync ][mbsync ]]
- [[#notmuch ][notmuch ]]
2020-09-12 12:53:21 -07:00
- [[#customize-notmuch-hello-buffer ][Customize =*notmuch-hello*= buffer ]]
- [[#changing-the-notmuch-landing-page ][Changing the =notmuch= landing page ]]
2020-05-09 21:41:30 -05:00
- [[#troubleshooting ][Troubleshooting ]]
* Description
This module makes Emacs an email client, using ~notmuch~ .
** Module Flags
+ This module install no module flags.
** Plugins
+ [[https://notmuchmail.org/ ][notmuch ]]
+ [[https://github.com/org-mime/org-mime ][org-mime ]]
* Prerequisites
This module requires:
2020-09-12 12:53:21 -07:00
+ Either ~[[https://github.com/gauteh/lieer][gmailieer]]~ (default), ~mbsync~ or ~offlineimap~ (to sync mail with)
+ ~[[https://notmuchmail.org/][notmuch]]~ , to index and tag your downloaded messages.
2020-05-09 21:41:30 -05:00
+ ~afew~ , optionally to initially tag your downloaded messages.
** TODO MacOS
2020-11-26 09:49:22 -08:00
** Arch Linux
Run one of the following commands.
2021-03-05 20:57:25 -05:00
#+BEGIN_SRC sh
pacman -S isync notmuch #mbsync
#+END_SRC
2020-11-26 09:49:22 -08:00
#+BEGIN_SRC sh
2021-03-05 20:57:25 -05:00
pacman -S offlineimap notmuch
#+END_SRC
2020-09-12 12:53:21 -07:00
See: [[https://wiki.archlinux.org/index.php/Notmuch ][Arch Wiki - Notmuch ]]
2020-05-09 21:41:30 -05:00
** NixOS
#+BEGIN_SRC nix
environment.systemPackages = with pkgs; [
notmuch
# And one of the following
gmailieer
isync
offlineimap
];
#+END_SRC
[[https://github.com/Emiller88/dotfiles/blob/319841bd3b89e59b01d169137cceee3183aba4fc/modules/shell/mail.nix ][An example of setting up mbsync and notmuch with home-manager ]]
** TODO openSUSE
** TODO Debian/Ubuntu
2020-09-12 12:53:21 -07:00
2020-05-09 21:41:30 -05:00
* TODO Features
* Configuration
** TODO Gmailier
** offlineimap
This module uses =Gmailier= by default. To use =offlineimap= , change ~+notmuch-sync-backend~ :
#+BEGIN_SRC emacs-lisp
(setq +notmuch-sync-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
This module uses =Gmailier= by default. To use =mbsync= , change ~+notmuch-sync-backend~ :
#+BEGIN_SRC emacs-lisp
(setq +notmuch-sync-backend 'mbsync)
#+END_SRC
2020-11-26 09:49:22 -08:00
The steps needed to set up =notmuch= with =mbsync= are very similar to the ones for
2020-05-09 21:41:30 -05:00
[[*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
page]] contains all needed information to set up your own.
Next you can download your email with ~mbsync --all~ . This may take a while, but
should be quicker than =offlineimap= ;).
** notmuch
You should have your email downloaded already. If you have not, you need to set
=Gmailier= , =offlineimap= or =mbsync= up before you proceed.
Before you can use =notmuch= , you need to index your email initially.
#+BEGIN_SRC sh
notmuch new
#+END_SRC
2020-09-12 12:53:21 -07:00
** Customize =*notmuch-hello*= buffer
It is possible to change the =*notmuch-hello*= buffer if you want to.
#+BEGIN_SRC emacs-lisp
2021-03-05 20:57:25 -05:00
(after! notmuch
2020-09-12 12:53:21 -07:00
(setq notmuch-show-log nil
notmuch-hello-sections `(notmuch-hello-insert-saved-searches
notmuch-hello-insert-alltags)
;; Maybe you don't like seeing email headers when you write email either.
notmuch-message-headers-visible nil))
#+END_SRC
** Changing the =notmuch= landing page
2021-03-05 20:57:25 -05:00
You may want to forego the =*notmuch-hello*= buffer by having ~M-x =notmuch~ or
~SPC o m~ take you straight to a search page.
2020-09-12 12:53:21 -07:00
2021-03-05 20:57:25 -05:00
When using ~SPC o m~ the =+notmuch-home-function= is called. By default it uses
the =notmuch= function and so has the same familiar behavior of running a
vanilla install of notmuch-emacs. But, by overwriting this function you can run
a custom search as your landing page.
2020-09-12 12:53:21 -07:00
#+BEGIN_SRC emacs-lisp
(setq +notmuch-home-function (lambda () (notmuch-search "tag:inbox")))
#+END_SRC
2020-05-09 21:41:30 -05:00
* Troubleshooting