mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 18:38:08 +01:00
9ca1f945d9
We need to load `cl-lib' at run-time because we use more from it than just macros. Never-the-less many, but not all libraries required it only at compile-time, which we got away with because at least some libraries already required it at run-time as well. We use `cl-lib' and (currently to a lesser extend) `pcase' throughout the code-base, which means that we should require these features in most libraries. In the past we tried to only require these features in just the libraries that actually need them, without fully succeeding. We did not succeed in doing so because that means we would have to check every time that we use a function from these features whether they are already being required in the current library. An alternative would be to add the `require' forms at the top of every library but that is a bit annoying too. In order to make sure that these features are loaded when needed but also to keep the noise down we only require them in "notmuch-lib.el", which most other libraries require, and in most of the few libraries that do not do so, namely "notmuch-draft.el", "notmuch-message.el" and "notmuch-parser.el". ("coolj.el", "make-deps.el", various generated libraries, and "notmuch-compat.el" are left touched.)
75 lines
2.7 KiB
EmacsLisp
75 lines
2.7 KiB
EmacsLisp
;;; notmuch-message.el --- message-mode functions specific to notmuch -*- lexical-binding: t -*-
|
|
;;
|
|
;; Copyright © Jesse Rosenthal
|
|
;;
|
|
;; This file is part of Notmuch.
|
|
;;
|
|
;; Notmuch is free software: you can redistribute it and/or modify it
|
|
;; under the terms of the GNU General Public License as published by
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
;; (at your option) any later version.
|
|
;;
|
|
;; Notmuch is distributed in the hope that it will be useful, but
|
|
;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
;; General Public License for more details.
|
|
;;
|
|
;; You should have received a copy of the GNU General Public License
|
|
;; along with Notmuch. If not, see <https://www.gnu.org/licenses/>.
|
|
;;
|
|
;; Authors: Jesse Rosenthal <jrosenthal@jhu.edu>
|
|
|
|
;;; Code:
|
|
|
|
(require 'cl-lib)
|
|
(require 'pcase)
|
|
|
|
(require 'message)
|
|
(require 'notmuch-tag)
|
|
|
|
(defcustom notmuch-message-replied-tags '("+replied")
|
|
"List of tag changes to apply to a message when it has been replied to.
|
|
|
|
Tags starting with \"+\" (or not starting with either \"+\" or
|
|
\"-\") in the list will be added, and tags starting with \"-\"
|
|
will be removed from the message being replied to.
|
|
|
|
For example, if you wanted to add a \"replied\" tag and remove
|
|
the \"inbox\" and \"todo\" tags, you would set:
|
|
(\"+replied\" \"-inbox\" \"-todo\")"
|
|
:type '(repeat string)
|
|
:group 'notmuch-send)
|
|
|
|
(defcustom notmuch-message-forwarded-tags '("+forwarded")
|
|
"List of tag changes to apply to a message when it has been forwarded.
|
|
|
|
Tags starting with \"+\" (or not starting with either \"+\" or
|
|
\"-\") in the list will be added, and tags starting with \"-\"
|
|
will be removed from the message being forwarded.
|
|
|
|
For example, if you wanted to add a \"forwarded\" tag and remove
|
|
the \"inbox\" tag, you would set:
|
|
(\"+forwarded\" \"-inbox\")"
|
|
:type '(repeat string)
|
|
:group 'notmuch-send)
|
|
|
|
(defvar-local notmuch-message-queued-tag-changes nil
|
|
"List of tag changes to be applied when sending a message.
|
|
|
|
A list of queries and tag changes that are to be applied to them
|
|
when the message that was composed in the current buffer is being
|
|
send. Each item in this list is a list of strings, where the
|
|
first is a notmuch query and the rest are the tag changes to be
|
|
applied to the matching messages.")
|
|
|
|
(defun notmuch-message-apply-queued-tag-changes ()
|
|
;; Apply the tag changes queued in the buffer-local variable
|
|
;; notmuch-message-queued-tag-changes.
|
|
(pcase-dolist (`(,query . ,tags) notmuch-message-queued-tag-changes)
|
|
(notmuch-tag query tags)))
|
|
|
|
(add-hook 'message-send-hook 'notmuch-message-apply-queued-tag-changes)
|
|
|
|
(provide 'notmuch-message)
|
|
|
|
;;; notmuch-message.el ends here
|