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