From: Mark Walters <markwalters1009@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH v6 0/4] emacs postpone/resume patches
Date: Sun, 13 Nov 2016 11:21:42 +0000 [thread overview]
Message-ID: <1479036106-32453-1-git-send-email-markwalters1009@gmail.com> (raw)
This version 6 of this series. The previous version is at
id:20161107125211.23405-1-david@tethera.net
This addresses the review comments on the previous version, adds a
couple of "requires" to fix some compile warnings, and1 updates on
function name which was missed previously.
I also rejigged Patch 3 (the secure tag checks). I think I like this
version but i am happy to revert to the previous one if preferred.
The diff from the previous version is below.
Best wishes
Mark
David Bremner (2):
emacs: check drafts for encryption tags before saving
emacs: resume messages
Mark Walters (2):
emacs: tree: remove binding for pressing button in message pane
emacs: postpone a message
emacs/Makefile.local | 3 +-
emacs/notmuch-draft.el | 268 +++++++++++++++++++++++++++++++++++++++++++++++
emacs/notmuch-mua.el | 4 +
emacs/notmuch-show.el | 10 ++
emacs/notmuch-tree.el | 2 +-
test/T630-emacs-draft.sh | 70 +++++++++++++
6 files changed, 355 insertions(+), 2 deletions(-)
create mode 100644 emacs/notmuch-draft.el
create mode 100755 test/T630-emacs-draft.sh
diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el
index 1528d79..496e11f 100644
--- a/emacs/notmuch-draft.el
+++ b/emacs/notmuch-draft.el
@@ -24,6 +24,8 @@
;;; Code:
(require 'notmuch-maildir-fcc)
+(require 'notmuch-tag)
+(require 'notmuch-mua)
(declare-function notmuch-show-get-message-id "notmuch-show" (&optional bare))
@@ -109,7 +111,7 @@ Used when a new version is saved, or the message is sent."
;; specified tags.
(when notmuch-draft-quoted-tags
(let ((re (concat "<#!*/?\\("
- (mapconcat 'identity notmuch-draft-quoted-tags "\\|")
+ (mapconcat 'regexp-quote notmuch-draft-quoted-tags "\\|")
"\\)")))
(message-goto-body)
(while (re-search-forward re nil t)
@@ -122,7 +124,7 @@ Used when a new version is saved, or the message is sent."
(save-excursion
(when notmuch-draft-quoted-tags
(let ((re (concat "<#!+/?\\("
- (mapconcat 'identity notmuch-draft-quoted-tags "\\|")
+ (mapconcat 'regexp-quote notmuch-draft-quoted-tags "\\|")
"\\)")))
(message-goto-body)
(while (re-search-forward re nil t)
@@ -138,21 +140,32 @@ Used when a new version is saved, or the message is sent."
(when secure-tag
(insert secure-tag "\n")))))
-(defun notmuch-draft--check-encryption-tag (&optional ask)
- "Query user if there an mml tag that looks like it might indicate encryption.
-
-Returns t if there is no such tag, or the user confirms they mean
-it."
+(defun notmuch-draft--has-encryption-tag ()
+ "Returns t if there is an mml secure tag."
(save-excursion
(message-goto-body)
- (or
- ;; We are fine if no relevant tag is found, or
- (not (re-search-forward notmuch-draft-encryption-tag-regex nil 't))
- ;; The user confirms they means it.
- (and ask
- (yes-or-no-p "(Customize `notmuch-draft-save-plaintext' to avoid this warning)
+ (re-search-forward notmuch-draft-encryption-tag-regex nil 't)))
+
+(defun notmuch-draft--query-encryption ()
+ "Checks if we should save a message that should be encrypted.
+
+`notmuch-draft-save-plaintext' controls the behaviour."
+ (case notmuch-draft-save-plaintext
+ ((ask)
+ (notmuch-draft--query-encryption)
+ (unless (yes-or-no-p "(Customize `notmuch-draft-save-plaintext' to avoid this warning)
This message contains mml tags that suggest it is intended to be encrypted.
-Really save and index an unencrypted copy? ")))))
+Really save and index an unencrypted copy? ")
+ (error "Save aborted")))
+ ((nil)
+ (error "Refusing to save draft with encryption tags (see `notmuch-draft-save-plaintext')"))
+ ((t)
+ (ignore))))
+
+(defun notmuch-draft--make-message-id ()
+ ;; message-make-message-id gives the id inside a "<" ">" pair,
+ ;; but notmuch doesn't want that form, so remove them.
+ (concat "draft-" (substring (message-make-message-id) 1 -1)))
(defun notmuch-draft-save ()
"Save the current draft message in the notmuch database.
@@ -161,19 +174,9 @@ This saves the current message in the database with tags
`notmuch-draft-tags` (in addition to any default tags
applied to newly inserted messages)."
(interactive)
- (case notmuch-draft-save-plaintext
- ((ask)
- (unless (notmuch-draft--check-encryption-tag t)
- (error "Save aborted")))
- ((t)
- (ignore))
- ((nil)
- (unless (notmuch-draft--check-encryption-tag nil)
- (error "Refusing to save draft with encryption tags (see `notmuch-draft-save-plaintext')"))))
- (let (;; We need the message id as we need it for tagging. Note
- ;; message-make-message-id gives the id inside a "<" ">" pair,
- ;; but notmuch doesn't want that form, so remove them.
- (id (concat "draft-" (substring (message-make-message-id) 1 -1))))
+ (when (notmuch-draft--has-encryption-tag)
+ (notmuch-draft--query-encryption))
+ (let ((id (notmuch-draft--make-message-id)))
(with-temporary-notmuch-message-buffer
;; We insert a Date header and a Message-ID header, the former
;; so that it is easier to search for the message, and the
@@ -183,17 +186,19 @@ applied to newly inserted messages)."
;; as otherwise they are doing something strange and we
;; shouldn't interfere. Note, since we are doing this in a new
;; buffer we don't change the version in the compose buffer.
- (if (member 'Message-ID message-deletable-headers)
- (progn
- (message-remove-header "Message-ID")
- (message-add-header (concat "Message-ID: <" id ">")))
+ (cond
+ ((member 'Message-ID message-deletable-headers)
+ (message-remove-header "Message-ID")
+ (message-add-header (concat "Message-ID: <" id ">")))
+ (t
(message "You have customized emacs so Message-ID is not a deletable header, so not changing it")
- (setq id nil))
- (if (member 'Date message-deletable-headers)
- (progn
- (message-remove-header "Date")
- (message-add-header (concat "Date: " (message-make-date))))
- (message "You have customized emacs so Date is not a deletable header, so not changing it"))
+ (setq id nil)))
+ (cond
+ ((member 'Date message-deletable-headers)
+ (message-remove-header "Date")
+ (message-add-header (concat "Date: " (message-make-date))))
+ (t
+ (message "You have customized emacs so Date is not a deletable header, so not changing it")))
(message-add-header "X-Notmuch-Emacs-Draft: True")
(notmuch-draft-quote-some-mml)
(notmuch-maildir-setup-message-for-saving)
@@ -212,7 +217,7 @@ applied to newly inserted messages)."
(defun notmuch-draft-postpone ()
"Save the draft message in the notmuch database and exit buffer."
(interactive)
- (notmuch-draft-save-draft)
+ (notmuch-draft-save)
(kill-buffer))
(defun notmuch-draft-resume (id)
next reply other threads:[~2016-11-13 11:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-13 11:21 Mark Walters [this message]
2016-11-13 11:21 ` [PATCH v6 1/4] emacs: tree: remove binding for pressing button in message pane Mark Walters
2016-11-13 11:21 ` [PATCH v6 2/4] emacs: postpone a message Mark Walters
2016-11-13 11:21 ` [PATCH v6 3/4] emacs: check drafts for encryption tags before saving Mark Walters
2016-11-13 11:21 ` [PATCH v6 4/4] emacs: resume messages Mark Walters
2016-11-13 13:19 ` [PATCH v6 0/4] emacs postpone/resume patches David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1479036106-32453-1-git-send-email-markwalters1009@gmail.com \
--to=markwalters1009@gmail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).