;; Manage mails with notmuch
;; Use default mapping (emacs)
(defun +notmuch/search-delete ()
(interactive)
(notmuch-search-add-tag (list "+deleted" "-inbox" "-unread"))
(notmuch-tree-next-message))
(use-package notmuch
:config
(setq-default notmuch-search-oldest-first nil) ;; setq does NOT work
(setq sendmail-program "/usr/local/bin/msmtp" ;; Freebsd
notmuch-fcc-dirs nil
notmuch-archive-tags '("-inbox" "-unread" "-new" "+archived")
notmuch-saved-searches '(
(:name "inbox" :query "tag:inbox " :key "i" :search-type 'tree)
(:name "sent" :query "tag:sent" :key "s" :search-type 'tree)
(:name "archived":query "tag:archived" :key "a" :search-type 'tree)
(:name "drafts" :query "tag:draft" :key "d" :search-type 'tree))
send-mail-function 'sendmail-send-it ; Activate mail sending
message-cite-reply-position 'above) ; mailing list reply style
(add-to-list 'mm-inhibit-file-name-handlers 'openwith-file-handler)
;; Jump to inbox
(remap-global "C-c m" '(lambda () (interactive) (notmuch-search "tag:inbox")))
(define-key notmuch-search-mode-map (kbd "d") '+notmuch/search-delete))