[PATCH v1] emacs: Add `notmuch-show-forward-open-messages'.
authorDavid Edmondson <dme@dme.org>
Sat, 6 Feb 2016 19:24:19 +0000 (19:24 +0000)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:20:59 +0000 (16:20 -0700)
08/adbe2df6d526507a3612bc19980b564e056195 [new file with mode: 0644]

diff --git a/08/adbe2df6d526507a3612bc19980b564e056195 b/08/adbe2df6d526507a3612bc19980b564e056195
new file mode 100644 (file)
index 0000000..4000b2e
--- /dev/null
@@ -0,0 +1,177 @@
+Return-Path: <dme@dme.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id D5EB76DE09ED\r
+ for <notmuch@notmuchmail.org>; Sat,  6 Feb 2016 11:24:27 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.171\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.171 tagged_above=-999 required=5 tests=[AWL=0.238, \r
+ DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7,\r
+ RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_NEUTRAL=0.652,\r
+ UNPARSEABLE_RELAY=0.001] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id dBC6hnANEcRa for <notmuch@notmuchmail.org>;\r
+ Sat,  6 Feb 2016 11:24:25 -0800 (PST)\r
+Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com\r
+ [74.125.82.66]) by arlo.cworth.org (Postfix) with ESMTPS id 623166DE0B25 for\r
+ <notmuch@notmuchmail.org>; Sat,  6 Feb 2016 11:24:25 -0800 (PST)\r
+Received: by mail-wm0-f66.google.com with SMTP id 128so8517430wmz.3\r
+ for <notmuch@notmuchmail.org>; Sat, 06 Feb 2016 11:24:25 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=dme-org.20150623.gappssmtp.com; s=20150623;\r
+ h=from:to:subject:date:message-id:in-reply-to:references;\r
+ bh=7p3ufQXjlDwLNzox++RAkNzH/ySW2+srx60RBLJFVLM=;\r
+ b=uKSodKKCNE9YzoFPo1Fvqi6lpS5Yu7lVNL15jo9XsBfzHu3hw2YjnkAFDdQ8GLJsYh\r
+ fUWP/3TgcKvVCdgvEflgdURZ8pnCWiunrSWQmSv3hOG0PbO0qV3T7wcQFNP3Z3VUKxO3\r
+ XeguE1oePJpK4cO+kFfCrSlbU2TAHfX37mjrhzGJoNmzdj58kwRm5DGj222Vrgk03SDo\r
+ 4gix6dU5TLc7R/0BL3Klk5nxTtqoy/qgspeOV35ql1S6LvkNh0XIFeZnxex2TcCbgVor\r
+ wbsuAenVPXdkWi6o9PyUO5rHUukAcRuKHNThoj2VamtBYq6o7c1P0ZlfPGl67cOJPmtm\r
+ tsZg==\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to\r
+ :references;\r
+ bh=7p3ufQXjlDwLNzox++RAkNzH/ySW2+srx60RBLJFVLM=;\r
+ b=gVc3ie/hYZAh6tBdfgx2WDMZ5lgXWckzDqq9rIgyuj0xQGNQ0DgG3hNCu7Eez1sH3m\r
+ dJGzT6T06QrkfnG49MBOmZvOlMYiuXd4/Wk7MWirB40E3u1viRZL9tZ49t3Cecu4yx1T\r
+ Oedw8oA/JXrvHMhbKD9Yyu6YtIAfHdd2ocJV54NNR5RaS8Fw0JXcRf456aut1zPneYmv\r
+ hmx3wshhtsIyr/6MEI+ZqIzoQFgsaPXfyUlkRGDGy0bvrwSo39dB7TiqWjONKvYedXKV\r
+ aAh0LM9A4hoT+W3s5bZx08UT0oGkDMuxMhaY2dymuAzejQjSdsdoNZvdMWXizvjoVvE2\r
+ mtOg==\r
+X-Gm-Message-State:\r
+ AG10YOQLGimfu5e4gyaM2yL39WsvF7qgV4uVyV2Y+tYuuXNQ29U5pWO9WeMPUa1mCH6ZPw==\r
+X-Received: by 10.28.9.71 with SMTP id 68mr22323709wmj.33.1454786663702;\r
+ Sat, 06 Feb 2016 11:24:23 -0800 (PST)\r
+Received: from disaster-area.hh.sledj.net\r
+ ([2a01:348:1a2:1:ea39:35ff:fe2c:a227])\r
+ by smtp.gmail.com with ESMTPSA id q75sm4510195wmd.6.2016.02.06.11.24.22\r
+ for <notmuch@notmuchmail.org>\r
+ (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Sat, 06 Feb 2016 11:24:22 -0800 (PST)\r
+Received: from localhost (disaster-area.hh.sledj.net [local])\r
+ by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 867e8815\r
+ for <notmuch@notmuchmail.org>; Sat, 6 Feb 2016 19:24:19 +0000 (UTC)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v1] emacs: Add `notmuch-show-forward-open-messages'.\r
+Date: Sat,  6 Feb 2016 19:24:19 +0000\r
+Message-Id: <1454786659-3615-2-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1454786659-3615-1-git-send-email-dme@dme.org>\r
+References: <1454786659-3615-1-git-send-email-dme@dme.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 06 Feb 2016 19:24:28 -0000\r
+\r
+Add a function to forward all open messages in the current view of a\r
+thread. Bind this to "F".\r
+---\r
+ emacs/notmuch-mua.el  | 48 ++++++++++++++++++++++++++++++++++++++++++++++++\r
+ emacs/notmuch-show.el | 11 +++++++++++\r
+ 2 files changed, 59 insertions(+)\r
+\r
+diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
+index 5462f54..be2967f 100644\r
+--- a/emacs/notmuch-mua.el\r
++++ b/emacs/notmuch-mua.el\r
+@@ -425,6 +425,54 @@ the From: address first."\r
+     (message-hide-headers)\r
+     (set-buffer-modified-p nil)))\r
\r
++(defun notmuch-mua-new-forward-messages (messages &optional prompt-for-sender)\r
++  "Compose a new message forwarding MESSAGES.\r
++\r
++If PROMPT-FOR-SENDER is non-nil, the user will be prompteed for\r
++the From: address."\r
++  (let* ((other-headers\r
++        (when (or prompt-for-sender notmuch-always-prompt-for-sender)\r
++          (list (cons 'From (notmuch-mua-prompt-for-sender)))))\r
++       forward-subject) ;; Comes from the first message and is\r
++                        ;; applied later.\r
++\r
++    ;; Generate the template for the outgoing message.\r
++    (notmuch-mua-mail nil "" other-headers nil (notmuch-mua-get-switch-function))\r
++\r
++    (save-excursion\r
++      ;; Insert all of the forwarded messages.\r
++      (mapc (lambda (id)\r
++            (let ((temp-buffer (get-buffer-create\r
++                                (concat "*notmuch-fwd-raw-" id "*"))))\r
++              ;; Get the raw version of this message in the buffer.\r
++              (with-current-buffer temp-buffer\r
++                (erase-buffer)\r
++                (let ((coding-system-for-read 'no-conversion))\r
++                  (call-process notmuch-command nil t nil "show" "--format=raw" id))\r
++                ;; Because we process the messages in reverse order,\r
++                ;; always generate a forwarded subject, then use the\r
++                ;; last (i.e. first) one.\r
++                (setq forward-subject (message-make-forward-subject)))\r
++              ;; Make a copy ready to be forwarded in the\r
++              ;; composition buffer.\r
++              (message-forward-make-body temp-buffer)\r
++              ;; Kill the temporary buffer.\r
++              (kill-buffer temp-buffer)))\r
++          ;; `message-forward-make-body' always puts the message at\r
++          ;; the top, so do them in reverse order.\r
++          (reverse messages))\r
++\r
++      ;; Add in the appropriate subject.\r
++      (save-restriction\r
++      (message-narrow-to-headers)\r
++      (message-remove-header "Subject")\r
++      (message-add-header (concat "Subject: " forward-subject)))\r
++\r
++      ;; `message-forward-make-body' shows the User-agent header.  Hide\r
++      ;; it again.\r
++      (message-hide-headers)\r
++      (set-buffer-modified-p nil))))))\r
++\r
+ (defun notmuch-mua-new-reply (query-string &optional prompt-for-sender reply-all)\r
+   "Compose a reply to the message identified by QUERY-STRING.\r
\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 3345878..a8c6f1e 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1371,6 +1371,7 @@ reset based on the original query."\r
+     (define-key map (kbd "<backtab>") 'notmuch-show-previous-button)\r
+     (define-key map (kbd "TAB") 'notmuch-show-next-button)\r
+     (define-key map "f" 'notmuch-show-forward-message)\r
++    (define-key map "F" 'notmuch-show-forward-open-messages)\r
+     (define-key map "l" 'notmuch-show-filter-thread)\r
+     (define-key map "r" 'notmuch-show-reply-sender)\r
+     (define-key map "R" 'notmuch-show-reply)\r
+@@ -1798,6 +1799,16 @@ any effects from previous calls to\r
+   (with-current-notmuch-show-message\r
+    (notmuch-mua-new-forward-message prompt-for-sender)))\r
\r
++(put 'notmuch-show-forward-open-messages 'notmuch-prefix-doc\r
++     "... and prompt for sender")\r
++(defun notmuch-show-forward-open-messages (&optional prompt-for-sender)\r
++  "Forward the currently open messages."\r
++  (interactive "P")\r
++  (let ((open-messages (notmuch-show-get-message-ids-for-open-messages)))\r
++    (unless open-messages\r
++      (error "No open messages to forward."))\r
++    (notmuch-mua-new-forward-messages open-messages prompt-for-sender)))\r
++\r
+ (defun notmuch-show-next-message (&optional pop-at-end)\r
+   "Show the next message.\r
\r
+-- \r
+2.1.4\r
+\r