Notmuch: Init

master
Pierre Neidhardt 2019-03-17 09:27:18 +01:00
parent 173308bd17
commit fefc905b55
6 changed files with 168 additions and 28 deletions

View File

@ -19,3 +19,8 @@
(string-append "units_cur " currency-file))
(job '(next-hour (range 0 24 3)) "updatedb-local")
(job '(next-minute (range 0 60 15))
'(begin (system* "mbsync" "-a")
(system* "notmuch" "new"))
"mail")

View File

@ -314,28 +314,31 @@
;;; Mail
;;; mu4e is usually site-local and not part of ELPA.
(when (or (fboundp 'mu4e)
(delq nil (mapcar (lambda (path) (string-match "/mu4e/\\|/mu4e$" path)) load-path)))
;; (nconc package-selected-packages '(mu4e-maildirs-extension))
(nconc package-selected-packages '(helm-mu)))
(with-eval-after-load 'mu4e
;; mu4e-conversation must be enabled here.
;; REVIEW: https://github.com/djcb/mu/issues/1258
(when (require 'mu4e-conversation nil t)
(global-mu4e-conversation-mode)
;; (setq mu4e-debug t)
(setq mu4e-headers-show-threads nil
mu4e-headers-include-related nil)
;; Tree is better to detect thread-jacks.
(setq mu4e-conversation-print-function 'mu4e-conversation-print-tree)
(add-hook 'mu4e-conversation-hook 'flyspell-mode)
(defun ambrevar/mu4e-conversation-sync ()
(let ((mu4e-get-mail-command "mbsync mail-sent atlas-sent"))
(mu4e-update-mail-and-index 'run-in-background)))
(add-hook 'mu4e-conversation-after-send-hook #'ambrevar/mu4e-conversation-sync)
(add-hook 'mu4e-view-mode-hook 'auto-fill-mode))
(require 'init-mu4e))
(autoload 'helm-mu4e-switch "mu4e")
;; (when (or (fboundp 'mu4e)
;; (delq nil (mapcar (lambda (path) (string-match "/mu4e/\\|/mu4e$" path)) load-path)))
;; ;; (nconc package-selected-packages '(mu4e-maildirs-extension))
;; (nconc package-selected-packages '(helm-mu)))
;; (with-eval-after-load 'mu4e
;; ;; mu4e-conversation must be enabled here.
;; ;; REVIEW: https://github.com/djcb/mu/issues/1258
;; (when (require 'mu4e-conversation nil t)
;; (global-mu4e-conversation-mode)
;; ;; (setq mu4e-debug t)
;; (setq mu4e-headers-show-threads nil
;; mu4e-headers-include-related nil)
;; ;; Tree is better to detect thread-jacks.
;; (setq mu4e-conversation-print-function 'mu4e-conversation-print-tree)
;; (add-hook 'mu4e-conversation-hook 'flyspell-mode)
;; (defun ambrevar/mu4e-conversation-sync ()
;; (let ((mu4e-get-mail-command "mbsync mail-sent atlas-sent"))
;; (mu4e-update-mail-and-index 'run-in-background)))
;; (add-hook 'mu4e-conversation-after-send-hook #'ambrevar/mu4e-conversation-sync)
;; (add-hook 'mu4e-view-mode-hook 'auto-fill-mode))
;; (require 'init-mu4e))
;; (autoload 'helm-mu4e-switch "mu4e")
(nconc package-selected-packages '(helm-notmuch))
(with-eval-after-load 'helm-notmuch (require 'init-notmuch))
;;; Makefile
(with-eval-after-load 'make-mode (require 'init-makefile))

View File

@ -161,6 +161,18 @@
"x" 'ambrevar/mu4e-mark-execute-all-no-confirm)))
(add-hook 'evil-collection-setup-hook 'ambrevar/evil-mu4e)
(defun ambrevar/evil-notmuch (mode _mode-keymaps &rest _rest)
(when (eq mode 'notmuch)
(evil-define-key 'normal notmuch-hello-mode-map
"s" 'helm-notmuch)
(evil-define-key 'normal notmuch-search-mode-map
"s" 'helm-notmuch)
(evil-define-key 'visual notmuch-search-mode-map
"s" 'helm-notmuch)
(evil-define-key 'normal notmuch-show-mode-map
"s" 'helm-notmuch)))
(add-hook 'evil-collection-setup-hook 'ambrevar/evil-notmuch)
(with-eval-after-load 'magit
(when (require 'evil-magit nil t)
(evil-magit-define-key evil-magit-state 'magit-mode-map "<" 'magit-section-up)

View File

@ -99,12 +99,16 @@
(if (fboundp 'helm-emms)
(exwm-input-set-key (kbd "s-A") #'helm-emms)
(exwm-input-set-key (kbd "s-A") #'emms)))
(when (or (fboundp 'mu4e)
(delq nil (mapcar (lambda (path) (string-match "/mu4e/\\|/mu4e$" path)) load-path)))
(if (not (fboundp 'helm-mu4e-switch))
(exwm-input-set-key (kbd "s-m") #'ambrevar/mu4e-headers)
(exwm-input-set-key (kbd "s-m") #'helm-mu4e-switch)
(exwm-input-set-key (kbd "s-M") #'helm-mu4e-switch-other-window)))
;; (when (or (fboundp 'mu4e)
;; (delq nil (mapcar (lambda (path) (string-match "/mu4e/\\|/mu4e$" path)) load-path)))
;; (if (not (fboundp 'helm-mu4e-switch))
;; (exwm-input-set-key (kbd "s-m") #'ambrevar/mu4e-headers)
;; (exwm-input-set-key (kbd "s-m") #'helm-mu4e-switch)
;; (exwm-input-set-key (kbd "s-M") #'helm-mu4e-switch-other-window)))
(if (not (fboundp 'helm-notmuch-switch))
(exwm-input-set-key (kbd "s-m") #'notmuch-hello)
(exwm-input-set-key (kbd "s-m") #'helm-notmuch-switch)
(exwm-input-set-key (kbd "s-M") #'helm-notmuch-switch-other-window))
(if (not (fboundp 'helm-elfeed-switch))
(exwm-input-set-key (kbd "s-n") #'elfeed)
(exwm-input-set-key (kbd "s-n") #'helm-elfeed-switch)

View File

@ -0,0 +1,28 @@
;; Notmuch
(when (require 'patch-helm nil 'noerror)
(helm-defswitcher
"notmuch"
(lambda (b)
(with-current-buffer b
(or
(derived-mode-p 'notmuch-hello-mode)
(derived-mode-p 'notmuch-search-mode)
(derived-mode-p 'notmuch-show-mode)
(derived-mode-p 'notmuch-message-mode))))
notmuch-hello))
(when (require 'helm-notmuch nil t)
;; TODO: Send PR.
(defun helm-notmuch-maybe-match-incomplete (pattern)
(if helm-notmuch-match-incomplete-words
(concat (mapconcat #'identity (split-string pattern) "* ") "*")
;; (if (string-match-p "[[:alnum:]]$" pattern)
;; (concat pattern "*")
;; pattern)
pattern))
(dolist (map (list notmuch-search-mode-map notmuch-hello-mode-map notmuch-show-mode-map))
(define-key map "s" 'helm-notmuch)))
(provide 'init-notmuch)

88
.notmuch-config Normal file
View File

@ -0,0 +1,88 @@
# .notmuch-config - Configuration file for the notmuch mail system
#
# For more information about notmuch, see https://notmuchmail.org
# Database configuration
#
# The only value supported here is 'path' which should be the top-level
# directory where your mail currently exists and to where mail will be
# delivered in the future. Files should be individual email messages.
# Notmuch will store its database within a sub-directory of the path
# configured here named ".notmuch".
#
[database]
path=/home/ambrevar/.cache/mail/
# User configuration
#
# Here is where you can let notmuch know how you would like to be
# addressed. Valid settings are
#
# name Your full name.
# primary_email Your primary email address.
# other_email A list (separated by ';') of other email addresses
# at which you receive email.
#
# Notmuch will use the various email addresses configured here when
# formatting replies. It will avoid including your own addresses in the
# recipient list of replies, and will set the From address based on the
# address to which the original email was addressed.
#
[user]
name=Pierre Neidhardt
primary_email=mail@ambrevar.xyz
other_email=pierre@atlas.engineer;
# Configuration for "notmuch new"
#
# The following options are supported here:
#
# tags A list (separated by ';') of the tags that will be
# added to all messages incorporated by "notmuch new".
#
# ignore A list (separated by ';') of file and directory names
# that will not be searched for messages by "notmuch new".
#
# NOTE: *Every* file/directory that goes by one of those
# names will be ignored, independent of its depth/location
# in the mail store.
#
[new]
tags=unread;inbox;
ignore=
# Search configuration
#
# The following option is supported here:
#
# exclude_tags
# A ;-separated list of tags that will be excluded from
# search results by default. Using an excluded tag in a
# query will override that exclusion.
#
[search]
exclude_tags=deleted;spam;
# Maildir compatibility configuration
#
# The following option is supported here:
#
# synchronize_flags Valid values are true and false.
#
# If true, then the following maildir flags (in message filenames)
# will be synchronized with the corresponding notmuch tags:
#
# Flag Tag
# ---- -------
# D draft
# F flagged
# P passed
# R replied
# S unread (added when 'S' flag is not present)
#
# The "notmuch new" command will notice flag changes in filenames
# and update tags, while the "notmuch tag" and "notmuch restore"
# commands will notice tag changes and update flags in filenames
#
[maildir]
synchronize_flags=true