notmuch-message.el (2766B)
1 ;;; notmuch-message.el --- message-mode functions specific to notmuch -*- lexical-binding: t -*- 2 ;; 3 ;; Copyright © Jesse Rosenthal 4 ;; 5 ;; This file is part of Notmuch. 6 ;; 7 ;; Notmuch is free software: you can redistribute it and/or modify it 8 ;; under the terms of the GNU General Public License as published by 9 ;; the Free Software Foundation, either version 3 of the License, or 10 ;; (at your option) any later version. 11 ;; 12 ;; Notmuch is distributed in the hope that it will be useful, but 13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of 14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 ;; General Public License for more details. 16 ;; 17 ;; You should have received a copy of the GNU General Public License 18 ;; along with Notmuch. If not, see <https://www.gnu.org/licenses/>. 19 ;; 20 ;; Authors: Jesse Rosenthal <jrosenthal@jhu.edu> 21 22 ;;; Code: 23 24 (require 'cl-lib) 25 (require 'pcase) 26 (require 'subr-x) 27 28 (require 'message) 29 (require 'notmuch-tag) 30 31 (defcustom notmuch-message-replied-tags '("+replied") 32 "List of tag changes to apply to a message when it has been replied to. 33 34 Tags starting with \"+\" (or not starting with either \"+\" or 35 \"-\") in the list will be added, and tags starting with \"-\" 36 will be removed from the message being replied to. 37 38 For example, if you wanted to add a \"replied\" tag and remove 39 the \"inbox\" and \"todo\" tags, you would set: 40 (\"+replied\" \"-inbox\" \"-todo\")" 41 :type '(repeat string) 42 :group 'notmuch-send) 43 44 (defcustom notmuch-message-forwarded-tags '("+forwarded") 45 "List of tag changes to apply to a message when it has been forwarded. 46 47 Tags starting with \"+\" (or not starting with either \"+\" or 48 \"-\") in the list will be added, and tags starting with \"-\" 49 will be removed from the message being forwarded. 50 51 For example, if you wanted to add a \"forwarded\" tag and remove 52 the \"inbox\" tag, you would set: 53 (\"+forwarded\" \"-inbox\")" 54 :type '(repeat string) 55 :group 'notmuch-send) 56 57 (defvar-local notmuch-message-queued-tag-changes nil 58 "List of tag changes to be applied when sending a message. 59 60 A list of queries and tag changes that are to be applied to them 61 when the message that was composed in the current buffer is being 62 send. Each item in this list is a list of strings, where the 63 first is a notmuch query and the rest are the tag changes to be 64 applied to the matching messages.") 65 66 (defun notmuch-message-apply-queued-tag-changes () 67 ;; Apply the tag changes queued in the buffer-local variable 68 ;; notmuch-message-queued-tag-changes. 69 (pcase-dolist (`(,query . ,tags) notmuch-message-queued-tag-changes) 70 (notmuch-tag query tags))) 71 72 (add-hook 'message-send-hook 'notmuch-message-apply-queued-tag-changes) 73 74 (provide 'notmuch-message) 75 76 ;;; notmuch-message.el ends here