Re: [PATCH] emacs: show: allow user to insert rfc822 parts as messages
authorDavid Edmondson <dme@dme.org>
Mon, 23 May 2016 12:24:28 +0000 (13:24 +0100)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:21:52 +0000 (16:21 -0700)
95/a83cb86abc8927a4a4717b99b4c1aea186ba3a [new file with mode: 0644]

diff --git a/95/a83cb86abc8927a4a4717b99b4c1aea186ba3a b/95/a83cb86abc8927a4a4717b99b4c1aea186ba3a
new file mode 100644 (file)
index 0000000..221510d
--- /dev/null
@@ -0,0 +1,189 @@
+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 57B486DE0130\r
+ for <notmuch@notmuchmail.org>; Mon, 23 May 2016 05:24:43 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.19\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.19 tagged_above=-999 required=5 tests=[AWL=-0.123,\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 IZyE80VbBkXV for <notmuch@notmuchmail.org>;\r
+ Mon, 23 May 2016 05:24:35 -0700 (PDT)\r
+Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com\r
+ [74.125.82.44]) by arlo.cworth.org (Postfix) with ESMTPS id C6B2A6DE00F5 for\r
+ <notmuch@notmuchmail.org>; Mon, 23 May 2016 05:24:34 -0700 (PDT)\r
+Received: by mail-wm0-f44.google.com with SMTP id n129so75746732wmn.1\r
+ for <notmuch@notmuchmail.org>; Mon, 23 May 2016 05:24:34 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=dme-org.20150623.gappssmtp.com; s=20150623;\r
+ h=to:subject:in-reply-to:references:from:date:message-id:mime-version;\r
+ bh=uqHadXYq+wJaj4SV+THpCKadmphd2QiXY4/GLek7pL0=;\r
+ b=roffT3SkadsAJl4hy8/P6dZQysV3HF+BsXLWCRQazp+nxK2f92BSHN6I4w84tsbc66\r
+ WShapiZgbcgzIgOOd26afVsPWmdYAAHgokB/TtgG3b8zhHS0CDOScHAn0lr3vGm/dzDd\r
+ tzDDEC7KXi5+lXdLbZCwem0c1v7Gs0ZlqWSDglNFSx1k1HGQHCXnfJzIzcf2COS4J4gS\r
+ WmqvkwRSgavCYENeNPesj21iGWkagipWl9Yt2PbIga631/Q/e4yaZqHi4Y6S7CrIr1lS\r
+ SBl8Ch+v6ucqXM4bO3pHlK20ART8UZi39aag8voRY2kaKN0vtn5OWydPNXan3RQKJuCC\r
+ iIFA==\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:to:subject:in-reply-to:references:from:date\r
+ :message-id:mime-version;\r
+ bh=uqHadXYq+wJaj4SV+THpCKadmphd2QiXY4/GLek7pL0=;\r
+ b=Ci0loTgOsJv5vU4gnyJHBGJ1U0N+XLyMe1qjP0/h8fMHN7GbCGzvslDl0iHGctb0fU\r
+ YU0sbEBzuzQwll8GMVFgG/8PiJ/R3XtQdWzaHRbUGVQ0jgyHIIYT99Wmwuou8/q9MMCO\r
+ JFCrTAj0tWoIIW5cY730ACwXGuqHMK0XE6Y+FFmhtFRkhCLrSjwYPiROB17D2X+xMeiA\r
+ D4F+WAQOrt8Psl44asAJ9MphLPpHUIC5mrjDAyUtfZxt/140/hvYNZI1e82CusgvUBn1\r
+ OySmpJe4Pc5/pBbvZKpFSqfUpLeyxVv6yHjal6Ke803W5jYa3uEBU2RLBvwpD7QAP2Kz\r
+ oFzg==\r
+X-Gm-Message-State:\r
+ AOPr4FXpqS7gOyotql0eAAkN7caI/NI5sd2cE2gKPxhu80coKW8sWr5bKrF/fYDivSqYJg==\r
+X-Received: by 10.28.161.198 with SMTP id k189mr17392827wme.23.1464006270831; \r
+ Mon, 23 May 2016 05:24:30 -0700 (PDT)\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 iv1sm35017400wjb.34.2016.05.23.05.24.29\r
+ (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Mon, 23 May 2016 05:24:29 -0700 (PDT)\r
+Received: from localhost (disaster-area.hh.sledj.net [local])\r
+ by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 6a2cc922;\r
+ Mon, 23 May 2016 12:24:28 +0000 (UTC)\r
+To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] emacs: show: allow user to insert rfc822 parts as\r
+ messages\r
+In-Reply-To: <1463744295-12533-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1463744295-12533-1-git-send-email-markwalters1009@gmail.com>\r
+From: David Edmondson <dme@dme.org>\r
+Date: Mon, 23 May 2016 13:24:28 +0100\r
+Message-ID: <m2zirh3qtf.heart-of-gold@dme.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\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: Mon, 23 May 2016 12:24:43 -0000\r
+\r
+On Fri, May 20 2016, Mark Walters wrote:\r
+\r
+> This adds a part-handler function that uses notmuch-insert to insert\r
+> an rfc822 part as a message in its own right. This allows the user to\r
+> reply directly to that message.\r
+\r
+This looks useful, a couple of minor comments:\r
+\r
+- it would be nice to have a general "add a file to the database using\r
+  insert" function rather than the current smashed together with rfc822\r
+  thing,\r
+- the terminology and function naming confused me a lot initially - I\r
+  had no idea what support was being added. This probably stems from\r
+  notmuch-show using the term "insert" to mean "add content to the\r
+  display buffer". Could you come up with a more descriptive name for\r
+  `notmuch-show-insert-part'?\r
+  \r
+> ---\r
+>\r
+> I receive quite a lot of forwarded messages which include the original\r
+> message as an rfc822 part, and have used this for quite some time\r
+> without any problems.\r
+>\r
+> Best wishes\r
+>\r
+> Mark\r
+>\r
+>\r
+> emacs/notmuch-show.el | 29 ++++++++++++++++++++++++-----\r
+>  1 file changed, 24 insertions(+), 5 deletions(-)\r
+>\r
+> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+> index 5d9b7b4..de41a8f 100644\r
+> --- a/emacs/notmuch-show.el\r
+> +++ b/emacs/notmuch-show.el\r
+> @@ -141,6 +141,11 @@ indentation."\r
+>               (const :tag "View interactively"\r
+>                      notmuch-show-interactively-view-part)))\r
+>  \r
+> +(defcustom notmuch-show-part-insert-folder ""\r
+> +  "Default folder to insert rfc822 parts"\r
+> +  :group 'notmuch-show\r
+> +  :type 'string)\r
+> +\r
+>  (defcustom notmuch-show-only-matching-messages nil\r
+>    "Only matching messages are shown by default."\r
+>    :type 'boolean\r
+> @@ -1403,6 +1408,7 @@ reset based on the original query."\r
+>      (define-key map "v" 'notmuch-show-view-part)\r
+>      (define-key map "o" 'notmuch-show-interactively-view-part)\r
+>      (define-key map "|" 'notmuch-show-pipe-part)\r
+> +    (define-key map "i" 'notmuch-show-insert-part)\r
+>      (define-key map "?" 'notmuch-subkeymap-help)\r
+>      map)\r
+>    "Submap for part commands")\r
+> @@ -2330,11 +2336,13 @@ caller is responsible for killing this buffer as appropriate."\r
+>       (disposition (if filename `(attachment (filename . ,filename)))))\r
+>      (mm-make-handle buf (list computed-type) nil nil disposition)))\r
+>  \r
+> -(defun notmuch-show-apply-to-current-part-handle (fn)\r
+> +(defun notmuch-show-apply-to-current-part-handle (fn &rest args)\r
+>    "Apply FN to an mm-handle for the part containing point.\r
+>  \r
+> -This ensures that the temporary buffer created for the mm-handle\r
+> -is destroyed when FN returns."\r
+> +Any ARGS are passed to the function FN as arguments after the mm-handle.\r
+> +\r
+> +This function ensures that the temporary buffer created for the\r
+> +mm-handle is destroyed when FN returns."\r
+>    (let ((handle (notmuch-show-current-part-handle)))\r
+>      ;; emacs 24.3+ puts stdout/stderr into the calling buffer so we\r
+>      ;; call it from a temp-buffer, unless\r
+> @@ -2343,9 +2351,9 @@ is destroyed when FN returns."\r
+>      (unwind-protect\r
+>      (if notmuch-show-attachment-debug\r
+>          (with-current-buffer (generate-new-buffer " *notmuch-part*")\r
+> -          (funcall fn handle))\r
+> +          (apply fn handle args))\r
+>        (with-temp-buffer\r
+> -        (funcall fn handle)))\r
+> +        (apply fn handle args)))\r
+>        (kill-buffer (mm-handle-buffer handle)))))\r
+>  \r
+>  (defun notmuch-show-part-button-default (&optional button)\r
+> @@ -2379,6 +2387,17 @@ is destroyed when FN returns."\r
+>    (interactive)\r
+>    (notmuch-show-apply-to-current-part-handle #'mm-pipe-part))\r
+>  \r
+> +(defun notmuch-show-insert-part ()\r
+> +  "If the current part is rfc822 then insert into the mailstore"\r
+> +  (interactive)\r
+> +  (let* ((part (notmuch-show-get-part-properties))\r
+> +     (computed-type (plist-get part :computed-type)))\r
+> +    (if (notmuch-match-content-type computed-type "message/rfc822")\r
+> +    (let* ((folder (read-from-minibuffer "Folder to save part to: "\r
+> +                                         notmuch-show-part-insert-folder))\r
+> +           (cmd (concat notmuch-command " insert --folder=" folder)))\r
+> +      (notmuch-show-apply-to-current-part-handle #'mm-pipe-part cmd))\r
+> +      (message "Not a message/rfc822 part."))))\r
+>  \r
+>  (provide 'notmuch-show)\r
+>  \r
+> -- \r
+> 2.1.4\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> https://notmuchmail.org/mailman/listinfo/notmuch\r