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 325256DE0173 for ; Thu, 3 Nov 2016 11:09:19 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.672 X-Spam-Level: X-Spam-Status: No, score=0.672 tagged_above=-999 required=5 tests=[AWL=-0.458, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, FREEMAIL_REPLY=1, 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 XvxmqjNGVUXL for ; Thu, 3 Nov 2016 11:09:18 -0700 (PDT) Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by arlo.cworth.org (Postfix) with ESMTPS id 3550C6DE00B8 for ; Thu, 3 Nov 2016 11:09:17 -0700 (PDT) Received: by mail-wm0-f68.google.com with SMTP id u144so238225wmu.0 for ; Thu, 03 Nov 2016 11:09:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=iGouRerIxU9QbqY/ad/QyFMES+sjFIkgchnjsj2VfEQ=; b=v8nQWaUawUogXjRqT4xj1rDE12GcUdZBwguvkcxffAA9us48AsEyTSvHd+R6LOjySm 5Od2WKeNuPriaH+1pflXUbl1Wqi+nIbAyXp5IicZEFTUi8RFll3BCpe0IRsgzy8vuzwB t9VrEok7Pz7dp6EBRHe9ixp79dYbqOzFyyqWALsIzyNCOPSszj9ssdfqNawESr5NGeoZ 3La3BbbvjoWGE2ifv5VJKNCPo98rmGWvTwgHx4+GMwHb+eaU4f97YSGfXnmHVXcNUXed VKzgQcaqsJh132i8RIJgIWLrjMB+hpzWdP2p/QP5Gjkcrz4FMjhztREu90IOs2pm7rAA ulVg== 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=iGouRerIxU9QbqY/ad/QyFMES+sjFIkgchnjsj2VfEQ=; b=j9zS4vxXGKmq5FjQuP8BNCA7KiDdkbXajY7VVslw7PosjYa6fHfpTfb39eUcaQWsoX +CJ4b7WP2Dt78A/OOkghS0xARjfzotaKcxbsAfXoR5Fma+yzF7tV7f7oI1+KecDmwJ5+ 0bCotqvcB51pBUFy0nuJYJ65IP26sLoOla9ylDM1Q6ELX9/Z7SA0laDaUCLYWPf2lBeZ wCDOXxyievSDJ66zyn9jybnYLjVwyZrbyYuGKXbUsBrgOgUqQl0pVnINXB9hht5A3SVV wlFztjq0e/b9/L83dgT975iVZrA5UoeJwUmdyxnIjv89lA8YCxvP3Xn0M5KQbGOZn5Xc c0rg== X-Gm-Message-State: ABUngveNnkAEbWRPxCdYLUcJSgZ9zlA3ozNe2IIg8Uhxjv5yX1vJNB2A6cozeY/0zexdaw== X-Received: by 10.28.29.68 with SMTP id d65mr3281535wmd.91.1478196556144; Thu, 03 Nov 2016 11:09:16 -0700 (PDT) Received: from localhost (188.28.91.110.threembb.co.uk. [188.28.91.110]) by smtp.gmail.com with ESMTPSA id w203sm217174wmw.16.2016.11.03.11.09.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Nov 2016 11:09:15 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH v2 0/2] add postpone support Date: Thu, 3 Nov 2016 18:09:06 +0000 Message-Id: <1478196548-19596-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: Thu, 03 Nov 2016 18:09:19 -0000 This is version 2 of this set. The previous version is at id:1473004582-19396-1-git-send-email-markwalters1009@gmail.com The diff between v1 and v2 is below. The main change is that we store the secure tag in a temporary header and restore it afterwards. This avoids a bug in the way emacs deals with secure tags not at the top of the message. Other comments: I haven't tested this version heavily: I have been running something similar in my tree but I just don't postpone enough messages to test it thoroughly. It unbinds rather than rebinds the press button in message pane option in tree-view (currently bound to "e"). I have some thoughts on how to deal better with attachment handling in tree-view but that can follow later. It uses message-send-hook -- we really shouldn't do that, but as we already do for tagging replies "replied" it is probably OK to do so for now. (Fixing this properly is a little tricky -- avoiding the use of message-send-hook is easy but we currently mark a message replied even if the user aborts sending the message.) Best wishes Mark Mark Walters (2): emacs: tree: move binding for pressing button in message pane to u emacs: postpone/resume support emacs/notmuch-message.el | 187 +++++++++++++++++++++++++++++++++++++++++++++++ emacs/notmuch-mua.el | 4 + emacs/notmuch-show.el | 9 +++ emacs/notmuch-tree.el | 2 +- 4 files changed, 201 insertions(+), 1 deletion(-) diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el index b8d6d07..a503296 100644 --- a/emacs/notmuch-message.el +++ b/emacs/notmuch-message.el @@ -63,11 +63,11 @@ database. It will be created if necessary." :type 'string :group 'notmuch-send) -(defcustom notmuch-message-quoted-tags '("secure") +(defcustom notmuch-message-quoted-tags '() "Mml tags to quote. -This should be a list of mml tags to quote before saving. It is -recommended that the list includes \"secure\". +This should be a list of mml tags to quote before saving. You do +not need to include \"secure\" as that is handled separately. If you include \"part\" then attachments will not be saved with the draft -- if not then they will be saved with the draft. The @@ -100,10 +100,16 @@ Used when a new version is saved, or the message is sent." (defun notmuch-message-quote-some-mml () "Quote the mml tags in `notmuch-message-quoted-tags`." + (save-excursion + ;; First we deal with any secure tag separately. + (message-goto-body) + (when (looking-at "<#secure[^\n]*>\n") + (let ((secure-tag (match-string 0))) + (delete-region (match-beginning 0) (match-end 0)) + (message-add-header (concat "X-Notmuch-Emacs-Secure: " secure-tag)))) ;; This is copied from mml-quote-region but only quotes the ;; specified tags. (when notmuch-message-quoted-tags - (save-excursion (let ((re (concat "<#!*/?\\(" (mapconcat 'identity notmuch-message-quoted-tags "\\|") "\\)"))) @@ -115,8 +121,8 @@ Used when a new version is saved, or the message is sent." (defun notmuch-message-unquote-some-mml () "Unquote the mml tags in `notmuch-message-quoted-tags`." - (when notmuch-message-quoted-tags (save-excursion + (when notmuch-message-quoted-tags (let ((re (concat "<#!+/?\\(" (mapconcat 'identity notmuch-message-quoted-tags "\\|") "\\)"))) @@ -124,7 +130,15 @@ Used when a new version is saved, or the message is sent." (while (re-search-forward re nil t) ;; Remove one ! from after the #. (goto-char (+ (match-beginning 0) 2)) - (delete-char 1)))))) + (delete-char 1)))) + (let (secure-tag) + (save-restriction + (message-narrow-to-headers) + (setq secure-tag (message-fetch-field "X-Notmuch-Emacs-Secure" 't)) + (message-remove-header "X-Notmuch-Emacs-Secure")) + (message-goto-body) + (when secure-tag + (insert secure-tag "\n"))))) (defun notmuch-message-save-draft () "Save the current draft message in the notmuch database. @@ -157,6 +171,7 @@ applied to newly inserted messages)." (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")) + (message-add-header "X-Notmuch-Emacs-Draft: True") (notmuch-message-quote-some-mml) (notmuch-maildir-setup-message-for-saving) (notmuch-maildir-notmuch-insert-current-buffer @@ -201,10 +216,11 @@ applied to newly inserted messages)." (when (member 'Message-ID message-deletable-headers) (message-remove-header "Message-ID")) (when (member 'Date message-deletable-headers) - (message-remove-header "Date"))) - ;; If the message does not appear to be a draft, the postpone - ;; code probably didn't write it, so we should not unquote any - ;; mml. + (message-remove-header "Date")) + ;; The X-Notmuch-Emacs-Draft header is a more reliable + ;; indication of whether the message really is a draft. + (setq draft (> (message-remove-header "X-Notmuch-Emacs-Draft") 0))) + ;; If the message is not a draft we should not unquote any mml. (when draft (notmuch-message-unquote-some-mml)) (notmuch-message-mode) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index a96ee4e..d4f5d30 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -51,8 +51,6 @@ (declare-function notmuch-tree-get-message-properties "notmuch-tree" nil) (declare-function notmuch-read-query "notmuch" (prompt)) (declare-function notmuch-message-resume "notmuch-message" (id)) -(declare-function notmuch-maildir-notmuch-insert-current-buffer - "notmuch-maildir-fcc" (folder &optional create tags)) (defcustom notmuch-message-headers '("Subject" "To" "Cc" "Date") "Headers that should be shown in a message, in this order. diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el index a74d45c..6c93bf9 100644 --- a/emacs/notmuch-tree.el +++ b/emacs/notmuch-tree.el @@ -257,7 +257,6 @@ FUNC." (define-key map (kbd "M-TAB") (notmuch-tree-to-message-pane #'notmuch-show-previous-button)) (define-key map (kbd "") (notmuch-tree-to-message-pane #'notmuch-show-previous-button)) (define-key map (kbd "TAB") (notmuch-tree-to-message-pane #'notmuch-show-next-button)) - (define-key map "u" (notmuch-tree-to-message-pane #'notmuch-tree-button-activate)) ;; bindings from show (or elsewhere) but we close the message pane first. (define-key map "f" (notmuch-tree-close-message-pane-and #'notmuch-show-forward-message))