blob: 0cf8a0477205c87dc9e20aabaa63a5efa594b59f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
;;; -*- lexical-binding: t; -*-
(setq kj/fastmail-maildir (expand-file-name "~/Maildir/fastmail"))
(when (file-exists-p (expand-file-name "~/Maildir"))
(use-package notmuch
:config
(setq message-mail-user-agent 'notmuch-user-agent
message-kill-buffer-on-exit t
message-send-mail-function 'message-send-mail-with-sendmail)
(setq notmuch-show-all-tags-list t
notmuch-show-relative-dates t
notmuch-hello-tag-list-make-query "tag:unread"
notmuch-archive-tags '("-inbox" "-unread")
notmuch-fcc-dirs nil
notmuch-show-logo nil
notmuch-show-indent-messages-width 0)
(add-hook 'message-mode-hook 'turn-off-auto-fill)
(add-hook 'message-mode-hook 'visual-line-mode)
(add-hook 'notmuch-show-hook 'kj/disable-trailing-whitespace)
(defun kj/confirm-empty-subject ()
"Allow user to quit when current message subject is empty."
(or (message-field-value "Subject")
(yes-or-no-p "Really send without Subject? ")
(keyboard-quit)))
(add-hook 'message-send-hook #'kj/confirm-empty-subject)
(advice-add
'notmuch :before (defun kj/notmuch-switch-to-local ()
(when (file-remote-p default-directory)
(cd (expand-file-name "~")))))
(setq notmuch-saved-searches
'((:name "inbox" :query "tag:inbox -tag:_gz" :key "i" :search-type tree)
(:name "unread" :query "tag:unread" :key "u" :search-type tree)
(:name "flagged" :query "tag:flagged" :key "f" :search-type tree)
(:name "sent" :query "tag:sent" :key "t" :search-type tree)
(:name "drafts" :query "tag:draft" :key "d" :search-type tree)
(:name "all mail" :query "*" :key "a" :search-type tree)
)))
(setq kj/notmuch-wash-citation-regexp "\\(^[[:space:]]*\\)\\(>+\\)\\(.*\n+\\)")
;;; XXX consider upstreaming this.
(defun kj/notmuch-wash-citations-by-depth (_msg _depth)
(goto-char (point-min))
(beginning-of-line)
(while (and (< (point) (point-max))
(re-search-forward kj/notmuch-wash-citation-regexp nil t))
(let ((maxlevel 1))
(while (intern-soft (format "message-cited-text-%d" maxlevel))
(setq maxlevel (1+ maxlevel)))
(setq maxlevel (1- maxlevel))
(let* ((cite-start (match-beginning 0))
(cite-end (match-end 0))
(cite-level (min (length (match-string 2))
maxlevel))
(cited-text-face (intern (format "message-cited-text-%d" cite-level))))
(overlay-put (make-overlay cite-start cite-end)
'face cited-text-face)))))
(add-hook 'notmuch-show-insert-text/plain-hook #'kj/notmuch-wash-citations-by-depth 90)
(defun kj/notmuch-tree-by-tag (tag)
(interactive
(list (notmuch-select-tag-with-completion "Notmuch search tag: ")))
(notmuch-tree (concat "tag:" tag)))
(define-key notmuch-hello-mode-map "T"
'kj/notmuch-tree-by-tag)
(define-key notmuch-show-mode-map "!"
(lambda ()
"mark message as spam"
(interactive)
(notmuch-show-tag (list "+_gz" "-inbox"))))
(define-key notmuch-search-mode-map "!"
(lambda (&optional beg end)
"mark thread as spam"
(interactive (notmuch-interactive-region))
(notmuch-search-tag (list "+_gz" "-inbox") beg end)))
)
(when (file-exists-p kj/fastmail-maildir)
(setq sendmail-program "mujmap"
message-sendmail-extra-arguments (list "-C" kj/fastmail-maildir "send")))
(provide 'kj-email)
|