diff options
Diffstat (limited to 'lisp/+notmuch.el')
-rw-r--r-- | lisp/+notmuch.el | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/lisp/+notmuch.el b/lisp/+notmuch.el deleted file mode 100644 index 9e79c5a..0000000 --- a/lisp/+notmuch.el +++ /dev/null | |||
@@ -1,97 +0,0 @@ | |||
1 | ;;; +notmuch.el --- Notmuch extras -*- lexical-binding: t; -*- | ||
2 | |||
3 | ;;; Commentary: | ||
4 | |||
5 | ;; This is stuff that I suppose /could/ go in notmuch/init.el, but ... doesn't. | ||
6 | |||
7 | ;;; Code: | ||
8 | |||
9 | (require 'cl-lib) | ||
10 | (require 'notmuch) | ||
11 | |||
12 | (defvar +notmuch-send-dispatch-rules nil | ||
13 | "Alist of from addresses and variables to set when sending.") | ||
14 | |||
15 | (defun +notmuch-query-concat (&rest queries) | ||
16 | "Concatenate notmuch queries." | ||
17 | (mapconcat #'identity queries " AND ")) | ||
18 | |||
19 | (defun +send-mail-dispatch () | ||
20 | "Dispatch mail sender, depending on account." | ||
21 | (let ((from (message-fetch-field "from"))) | ||
22 | (dolist (vars (cl-loop for (addr . vars) in +notmuch-send-dispatch-rules | ||
23 | if (string-match-p addr from) return vars)) | ||
24 | (set (car vars) (cdr vars))))) | ||
25 | |||
26 | (defun +notmuch-correct-tags (args) | ||
27 | (list (car args) (mapcar #'string-trim (cadr args)))) | ||
28 | |||
29 | (defun +notmuch-goto (&optional prefix) | ||
30 | "Go straight to a `notmuch' search. | ||
31 | Without PREFIX argument, go to the first one in | ||
32 | `notmuch-saved-searches'; with a PREFIX argument, prompt the user | ||
33 | for which saved search to go to; with a double PREFIX | ||
34 | argument (\\[universal-argument] \\[universal-argument]), prompt | ||
35 | for search." | ||
36 | (interactive "P") | ||
37 | (pcase prefix | ||
38 | ('nil (notmuch-search (plist-get (car notmuch-saved-searches) :query))) | ||
39 | ('(4) (notmuch-search (plist-get (cl-find (completing-read "Saved Search: " | ||
40 | (mapcar (lambda (el) | ||
41 | (plist-get el :name)) | ||
42 | notmuch-saved-searches)) | ||
43 | notmuch-saved-searches | ||
44 | :key (lambda (el) (plist-get el :name)) | ||
45 | :test #'equal) | ||
46 | :query))) | ||
47 | (_ (notmuch-search)))) | ||
48 | |||
49 | ;; Don't add an initial input when completing addresses | ||
50 | (el-patch-feature notmuch) | ||
51 | (with-eval-after-load 'notmuch | ||
52 | (el-patch-defun notmuch-address-selection-function (prompt collection initial-input) | ||
53 | "Call (`completing-read' | ||
54 | PROMPT COLLECTION nil nil INITIAL-INPUT 'notmuch-address-history)" | ||
55 | (completing-read | ||
56 | prompt collection nil nil | ||
57 | (el-patch-swap initial-input | ||
58 | nil) | ||
59 | 'notmuch-address-history))) | ||
60 | |||
61 | (defcustom +notmuch-spam-tags '("+spam" "+Spam") | ||
62 | "A list of tag changes to apply when marking a thread as spam." | ||
63 | :type '(repeat string)) | ||
64 | |||
65 | (defun +notmuch-tree-mark-spam-then-next (&optional ham beg end) | ||
66 | "Mark the current message as spam and move to the next." | ||
67 | (interactive "P") | ||
68 | (+notmuch-tree-mark-spam ham) | ||
69 | (notmuch-tree-next-matching-message)) | ||
70 | |||
71 | (defun +notmuch-tree-mark-spam (&optional ham) | ||
72 | "Mark the current message as spam. | ||
73 | That is, apply the tag changes in `+notmuch-spam-tags' to it. If | ||
74 | an optional prefix HAM argument is given, the message will be | ||
75 | marked as not-spam (\"ham\"), i.e., the tag changes in | ||
76 | `+notmuch-spam-tags' will be reversed." | ||
77 | (interactive "P") | ||
78 | (when +notmuch-spam-tags | ||
79 | (notmuch-tree-tag | ||
80 | (notmuch-tag-change-list +notmuch-spam-tags ham)))) | ||
81 | |||
82 | (defun +notmuch-search-mark-spam (&optional ham beg end) | ||
83 | "Mark the current thread or region as spam. | ||
84 | This adds the tags in `+notmuch-spam-tags' to the message. With | ||
85 | an optional HAM prefix argument, mark the messages as | ||
86 | not-spam (\"ham\"). | ||
87 | |||
88 | This function advances the next thread when finished." | ||
89 | (interactive (cons current-prefix-arg (notmuch-interactive-region))) | ||
90 | (when +notmuch-spam-tags | ||
91 | (notmuch-search-tag | ||
92 | (notmuch-tag-change-list +notmuch-spam-tags ham) beg end)) | ||
93 | (when (eq beg end) | ||
94 | (notmuch-search-next-thread))) | ||
95 | |||
96 | (provide '+notmuch) | ||
97 | ;;; +notmuch.el ends here | ||