From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 6896A6DE1050 for ; Sun, 13 Nov 2016 03:21:52 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.055 X-Spam-Level: X-Spam-Status: No, score=0.055 tagged_above=-999 required=5 tests=[AWL=-0.075, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id H9OExZtvxoX5 for ; Sun, 13 Nov 2016 03:21:51 -0800 (PST) Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by arlo.cworth.org (Postfix) with ESMTPS id 559586DE1034 for ; Sun, 13 Nov 2016 03:21:51 -0800 (PST) Received: by mail-wm0-f68.google.com with SMTP id u144so7720257wmu.0 for ; Sun, 13 Nov 2016 03:21:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=SKAIEmdElthv49y8IYb23VImh07yVka9I8C3U50XG1Y=; b=rr3vzd1afr+PaXSI9pZz5r4ZKngznCyvRjQ6cywcMsKCS05DMnyLA4o3ToPHcbAsSl eC1S1ZRlmSlziYQczLmuP+NCKRMlL9HshckXlDQeA1aT6+23XPix0yfnE3h9i/373htP hQII/cIew7LHsfpK9OPsk9WX+U2L2O/szUxfV2ZVQ54Jfd/lSI/rGyvisxjeeSD0IHIP JRHPVHVp2eIjS6MI7aP1bWcBRfFRe9G1GmlQ+wX8GwZjUc1LKwJIYQMy9mdGmhCzmBAp QA4GEYdwZ4lmUQ0a3ESS30/77ZgIr2u9J3RS1K/d3DNs2wYKq3AHVldI3FVY8Q4L0zv/ 5dYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=SKAIEmdElthv49y8IYb23VImh07yVka9I8C3U50XG1Y=; b=ddnkXxPOUcW3lGHu6a4uakeDNj62i5N4p/tUnQmuKV3YDDdS3bAjuscZDoDkSGzuAD oq4XiXYVIsGH2bNTlx8tQDPRCcgzRv8OIVCTwKD3XZNeFHaL+SCcSq3RBmGB9+qylgMz 9AHqBILG3DydFdkj/mO3hMlV1DKuidYmLPAbmhrybZdtLEAQgym13RNR7QI3ul8MTX26 Cq1Fk0xsvFdLnm8rRgGodezlkMAA089Z+srXHxb8PUclUcPYQm55yY+59mvbrUKy7okm 1mrleR7gm7ccnrbkaQx9jRKRT/nvkTF5YbRvcP6nhReVVUmkTnk93jgYNGvBwWHnIyrM XNuA== X-Gm-Message-State: ABUngvexMc4geEGO+VgIyb156ovPM9CsBUhYkQzNLWCdBmhqVFEejCVEwo/YON5NUGt5uA== X-Received: by 10.28.55.213 with SMTP id e204mr5436246wma.92.1479036109689; Sun, 13 Nov 2016 03:21:49 -0800 (PST) Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) by smtp.gmail.com with ESMTPSA id g184sm29548817wme.23.2016.11.13.03.21.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Nov 2016 03:21:49 -0800 (PST) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH v6 0/4] emacs postpone/resume patches Date: Sun, 13 Nov 2016 11:21:42 +0000 Message-Id: <1479036106-32453-1-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 2.1.4 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Nov 2016 11:21:52 -0000 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)