2018-06-06 09:18:44 +02:00
|
|
|
(require 'notmuch)
|
2018-06-29 13:06:29 +02:00
|
|
|
(require 'counsel-notmuch)
|
2018-06-06 09:18:44 +02:00
|
|
|
|
2019-12-15 18:09:39 +01:00
|
|
|
;; (global-set-key (kbd "C-c m") 'notmuch-hello)
|
|
|
|
;; (global-set-key (kbd "C-c C-m") 'counsel-notmuch)
|
|
|
|
;; (global-set-key (kbd "C-c C-e n") 'notmuch-mua-new-mail)
|
2018-06-06 09:18:44 +02:00
|
|
|
|
2018-06-12 09:11:52 +02:00
|
|
|
(setq notmuch-cache-dir (format "%s/.cache/notmuch" (getenv "HOME")))
|
2018-06-06 09:18:44 +02:00
|
|
|
(make-directory notmuch-cache-dir t)
|
|
|
|
|
|
|
|
;; Cache addresses for completion:
|
|
|
|
(setq notmuch-address-save-filename (concat notmuch-cache-dir "/addresses"))
|
|
|
|
|
|
|
|
;; Don't spam my home folder with drafts:
|
2018-06-12 09:11:52 +02:00
|
|
|
(setq notmuch-draft-folder "drafts") ;; relative to notmuch database
|
|
|
|
|
|
|
|
;; Mark things as read when archiving them:
|
|
|
|
(setq notmuch-archive-tags '("-inbox" "-unread" "+archive"))
|
2018-06-06 09:18:44 +02:00
|
|
|
|
|
|
|
;; Show me saved searches that I care about:
|
|
|
|
(setq notmuch-saved-searches
|
2018-06-06 10:29:30 +02:00
|
|
|
'((:name "inbox" :query "tag:inbox" :count-query "tag:inbox AND tag:unread" :key "i")
|
2018-06-06 09:18:44 +02:00
|
|
|
(:name "sent" :query "tag:sent" :key "t")
|
2018-06-07 23:23:57 +02:00
|
|
|
(:name "drafts" :query "tag:draft")))
|
2018-06-06 09:18:44 +02:00
|
|
|
(setq notmuch-show-empty-saved-searches t)
|
|
|
|
|
|
|
|
;; Mail sending configuration
|
2021-05-22 21:38:48 +02:00
|
|
|
(setq sendmail-program "gmi") ;; lieer binary supports sendmail emulation
|
|
|
|
(setq message-sendmail-extra-arguments
|
|
|
|
'("send" "--quiet" "-t" "-C" "~/mail/account.tazjin"))
|
|
|
|
(setq send-mail-function 'sendmail-send-it)
|
2018-06-06 09:18:44 +02:00
|
|
|
(setq notmuch-mua-user-agent-function
|
|
|
|
(lambda () (format "Emacs %s; notmuch.el %s" emacs-version notmuch-emacs-version)))
|
2018-06-12 09:12:26 +02:00
|
|
|
(setq mail-host-address (system-name))
|
|
|
|
(setq notmuch-mua-cite-function #'message-cite-original-without-signature)
|
2019-12-30 22:19:56 +01:00
|
|
|
(setq notmuch-fcc-dirs nil) ;; Gmail does this server-side
|
2020-01-01 16:28:47 +01:00
|
|
|
(setq message-signature nil) ;; Insert message signature manually with C-c C-w
|
2018-06-06 09:18:44 +02:00
|
|
|
|
2018-06-18 16:39:28 +02:00
|
|
|
;; Close mail buffers after sending mail
|
|
|
|
(setq message-kill-buffer-on-exit t)
|
|
|
|
|
2018-06-06 09:18:44 +02:00
|
|
|
;; Ensure sender is correctly passed to msmtp
|
|
|
|
(setq mail-specify-envelope-from t
|
|
|
|
message-sendmail-envelope-from 'header
|
|
|
|
mail-envelope-from 'header)
|
|
|
|
|
|
|
|
;; Store sent mail in the correct folder per account
|
|
|
|
(setq notmuch-maildir-use-notmuch-insert nil)
|
|
|
|
|
2018-06-12 09:10:25 +02:00
|
|
|
;; I don't use drafts but I instinctively hit C-x C-s constantly, lets
|
|
|
|
;; handle that gracefully.
|
|
|
|
(define-key notmuch-message-mode-map (kbd "C-x C-s") #'ignore)
|
|
|
|
|
2018-06-15 01:12:51 +02:00
|
|
|
;; Define a telephone-line segment for displaying the count of unread,
|
|
|
|
;; important mails in the last window's mode-line:
|
|
|
|
(defvar *last-notmuch-count-redraw* 0)
|
|
|
|
(defvar *current-notmuch-count* nil)
|
|
|
|
|
|
|
|
(defun update-display-notmuch-counts ()
|
|
|
|
"Update and render the current state of the notmuch unread
|
|
|
|
count for display in the mode-line.
|
|
|
|
|
|
|
|
The offlineimap-timer runs every 2 minutes, so it does not make
|
|
|
|
sense to refresh this much more often than that."
|
|
|
|
|
2018-11-13 15:33:10 +01:00
|
|
|
(when (> (- (float-time) *last-notmuch-count-redraw*) 30)
|
2018-06-15 01:12:51 +02:00
|
|
|
(setq *last-notmuch-count-redraw* (float-time))
|
|
|
|
(let* ((inbox-unread (notmuch-saved-search-count "tag:inbox and tag:unread"))
|
2019-12-14 15:56:13 +01:00
|
|
|
(notmuch-count (format "I: %s; D: %s" inbox-unread)))
|
2018-06-15 01:12:51 +02:00
|
|
|
(setq *current-notmuch-count* notmuch-count)))
|
|
|
|
|
|
|
|
(when (and (bottom-right-window-p)
|
|
|
|
;; Only render if the initial update is done and there
|
|
|
|
;; are unread mails:
|
|
|
|
*current-notmuch-count*
|
|
|
|
(not (equal *current-notmuch-count* "I: 0; D: 0")))
|
|
|
|
*current-notmuch-count*))
|
|
|
|
|
|
|
|
(telephone-line-defsegment telephone-line-notmuch-counts ()
|
|
|
|
"This segment displays the count of unread notmuch messages in
|
|
|
|
the last window's mode-line (if unread messages are present)."
|
|
|
|
|
|
|
|
(update-display-notmuch-counts))
|
|
|
|
|
2018-06-06 09:18:44 +02:00
|
|
|
(provide 'mail-setup)
|