--- /dev/null
+Return-Path: <anarcat@anarcat.ath.cx>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 5503A431FD0\r
+ for <notmuch@notmuchmail.org>; Sat, 16 Jul 2011 11:41:29 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id 0VQX-qLhOtZH for <notmuch@notmuchmail.org>;\r
+ Sat, 16 Jul 2011 11:41:28 -0700 (PDT)\r
+Received: from marcos.anarcat.ath.cx (H144.C72.B0.tor.eicat.ca [72.0.72.144])\r
+ by olra.theworths.org (Postfix) with ESMTP id 94C43431FB6\r
+ for <notmuch@notmuchmail.org>; Sat, 16 Jul 2011 11:41:28 -0700 (PDT)\r
+Received: by marcos.anarcat.ath.cx (Postfix, from userid 1000)\r
+ id 3E71F7621D; Sat, 16 Jul 2011 14:41:28 -0400 (EDT)\r
+From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= <anarcat@koumbit.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/2] add edit function to resume postponed emails\r
+Date: Sat, 16 Jul 2011 14:41:25 -0400\r
+Message-Id: <1310841685-29167-1-git-send-email-anarcat@koumbit.org>\r
+X-Mailer: git-send-email 1.7.5.4\r
+In-Reply-To: <1310807540-29960-1-git-send-email-anarcat@koumbit.org>\r
+References: <1310807540-29960-1-git-send-email-anarcat@koumbit.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\r
+Cc: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= <anarcat@koumbit.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 16 Jul 2011 18:41:29 -0000\r
+\r
+Add a new function to allow editing a new message starting from an\r
+existing one, roughly the equivalent of Mutt's resend-message\r
+functionality.\r
+\r
+Hooks into the search and show views through the "e" keybinding.\r
+\r
+"draft" tag is removed after the email is sent and the target thread\r
+is marked as deleted.\r
+\r
+Known issues:\r
+\r
+ 1. only the first MIME part of the email is used\r
+ 2. running this on a thread with more than one message has not been\r
+ tested\r
+ 3. encoding is broken when files are reloaded, because we don't parse\r
+ MIME back\r
+ 4. draft files are left around when mails are written, even if they\r
+ are not postponed\r
+\r
+Todo:\r
+\r
+ 1. use the proper gnus hooks to resume emails:\r
+ https://www.gnu.org/software/emacs/manual/html_node/message/Message-Actions.html#index-message_002dpostpone_002dactions-334\r
+\r
+ 2. write tests\r
+\r
+Signed-off-by: Antoine Beaupré <anarcat@koumbit.org>\r
+---\r
+ emacs/notmuch-mua.el | 50 +++++++++++++++++++++++++++++++++++++++++++++++++\r
+ emacs/notmuch-show.el | 6 +++++\r
+ emacs/notmuch.el | 7 ++++++\r
+ 3 files changed, 63 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
+index 274c5da..11d014d 100644\r
+--- a/emacs/notmuch-mua.el\r
++++ b/emacs/notmuch-mua.el\r
+@@ -201,6 +201,56 @@ the From: address first."\r
+ (list (cons 'from (notmuch-mua-prompt-for-sender))))))\r
+ (notmuch-mua-mail nil nil other-headers)))\r
+ \r
++(defun notmuch-mua-delete-postponed (query-string)\r
++ "Delete postponed mail after sending."\r
++ (notmuch-tag query-string "+deleted")\r
++ (notmuch-tag query-string "-draft")\r
++)\r
++\r
++(defun notmuch-mua-edit-mail (query-string)\r
++ "Create a new mail composition window based on the current mail."\r
++ (interactive)\r
++ (let (headers\r
++ body\r
++ (args '("show" "--format=raw")))\r
++ (if notmuch-show-process-crypto\r
++ (setq args (append args '("--decrypt"))))\r
++ (setq args (append args (list query-string)))\r
++ ;; This make assumptions about the output of `notmuch show', but\r
++ ;; really only that the headers come first followed by a blank\r
++ ;; line and then the body.\r
++ (with-temp-buffer\r
++ (apply 'call-process (append (list notmuch-command nil (list t t) nil) args))\r
++ (goto-char (point-min))\r
++ (if (re-search-forward "^$" nil t)\r
++ (save-excursion\r
++ (save-restriction\r
++ (narrow-to-region (point-min) (point))\r
++ (goto-char (point-min))\r
++ (setq headers (mail-header-extract))))\r
++ )\r
++ (forward-line 1)\r
++ (setq body (buffer-substring (point) (point-max)))\r
++ )\r
++\r
++ (let ((message-signature nil))\r
++ (notmuch-mua-mail (mail-header 'to headers)\r
++ (mail-header 'subject headers)\r
++ (message-headers-to-generate headers t '(to subject))\r
++ t nil nil (notmuch-mua-delete-postponed query-string))\r
++ )\r
++\r
++ ;; insert the message body - but put it in front of the signature\r
++ ;; if one is present\r
++ (goto-char (point-max))\r
++ (if (re-search-backward message-signature-separator nil t)\r
++ (forward-line -1)\r
++ (goto-char (point-max)))\r
++ (insert body))\r
++ (set-buffer-modified-p nil)\r
++\r
++ (message-goto-body))\r
++\r
+ (defun notmuch-mua-new-forward-message (&optional prompt-for-sender)\r
+ "Invoke the notmuch message forwarding window.\r
+ \r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index c83b992..1efde1c 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -865,6 +865,7 @@ function is used. "\r
+ (define-key map "m" 'notmuch-mua-new-mail)\r
+ (define-key map "f" 'notmuch-show-forward-message)\r
+ (define-key map "r" 'notmuch-show-reply)\r
++ (define-key map "e" 'notmuch-show-edit)\r
+ (define-key map "|" 'notmuch-show-pipe-message)\r
+ (define-key map "w" 'notmuch-show-save-attachments)\r
+ (define-key map "V" 'notmuch-show-view-raw-message)\r
+@@ -1165,6 +1166,11 @@ any effects from previous calls to\r
+ (interactive "P")\r
+ (notmuch-mua-new-reply (notmuch-show-get-message-id) prompt-for-sender))\r
+ \r
++(defun notmuch-show-edit ()\r
++ "Edit the current message as new."\r
++ (interactive)\r
++ (notmuch-mua-edit-mail (notmuch-show-get-message-id)))\r
++\r
+ (defun notmuch-show-forward-message (&optional prompt-for-sender)\r
+ "Forward the current message."\r
+ (interactive "P")\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index f6fb07b..b522715 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -204,6 +204,7 @@ For a mouse binding, return nil."\r
+ (define-key map "p" 'notmuch-search-previous-thread)\r
+ (define-key map "n" 'notmuch-search-next-thread)\r
+ (define-key map "r" 'notmuch-search-reply-to-thread)\r
++ (define-key map "e" 'notmuch-search-edit)\r
+ (define-key map "m" 'notmuch-mua-new-mail)\r
+ (define-key map "s" 'notmuch-search)\r
+ (define-key map "o" 'notmuch-search-toggle-order)\r
+@@ -449,6 +450,12 @@ Complete list of currently available key bindings:\r
+ (let ((message-id (notmuch-search-find-thread-id)))\r
+ (notmuch-mua-new-reply message-id prompt-for-sender)))\r
+ \r
++(defun notmuch-search-edit ()\r
++ "Edit the current message as new."\r
++ (interactive)\r
++ (let ((message-id (notmuch-search-find-thread-id)))\r
++ (notmuch-mua-edit-mail message-id)))\r
++\r
+ (defun notmuch-call-notmuch-process (&rest args)\r
+ "Synchronously invoke \"notmuch\" with the given list of arguments.\r
+ \r
+-- \r
+1.7.5.4\r
+\r