diff options
author | Case Duckworth | 2022-02-16 23:19:27 -0600 |
---|---|---|
committer | Case Duckworth | 2022-02-16 23:19:27 -0600 |
commit | c0313263675974dc952092dfb72f5464e07efb0a (patch) | |
tree | 74c42d77e98507e3bf6fed29b79e0e21b04c9e85 /lisp | |
parent | Uhhhhh (diff) | |
download | emacs-c0313263675974dc952092dfb72f5464e07efb0a.tar.gz emacs-c0313263675974dc952092dfb72f5464e07efb0a.zip |
Notmuch and stuff
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/+notmuch.el | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/lisp/+notmuch.el b/lisp/+notmuch.el new file mode 100644 index 0000000..890edbe --- /dev/null +++ b/lisp/+notmuch.el | |||
@@ -0,0 +1,62 @@ | |||
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 | (provide '+notmuch) | ||
62 | ;;; +notmuch.el ends here | ||