From: Mark Walters Date: Fri, 20 May 2016 11:38:15 +0000 (+0100) Subject: [PATCH] emacs: show: allow user to insert rfc822 parts as messages X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=6a03555dc8080dc016722b44da3fab95eb36db13;p=notmuch-archives.git [PATCH] emacs: show: allow user to insert rfc822 parts as messages --- diff --git a/bb/14b0481b0195d9bdbb4f2d10b720358306ae5b b/bb/14b0481b0195d9bdbb4f2d10b720358306ae5b new file mode 100644 index 000000000..f2239e0fd --- /dev/null +++ b/bb/14b0481b0195d9bdbb4f2d10b720358306ae5b @@ -0,0 +1,162 @@ +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 A1B316DE01D0 + for ; Fri, 20 May 2016 04:38:29 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.316 +X-Spam-Level: +X-Spam-Status: No, score=-0.316 tagged_above=-999 required=5 tests=[AWL=0.254, + DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, + 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 NlKYqNX52kzc for ; + Fri, 20 May 2016 04:38:21 -0700 (PDT) +Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com + [74.125.82.66]) by arlo.cworth.org (Postfix) with ESMTPS id 826666DE00F5 for + ; Fri, 20 May 2016 04:38:21 -0700 (PDT) +Received: by mail-wm0-f66.google.com with SMTP id 67so5312157wmg.0 + for ; Fri, 20 May 2016 04:38:21 -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=9Umt+YZvpt70W8T8rAVpIkYNnRC78Ea2e+bULr+eQJE=; + b=hpmTeuupXOeE78vChOBSOYbumAwobmvqaKQxskIvyjV+jv18HOXeodTSWSm+SPiFpr + n+IYw5fRSEFmYB38FUa7WmcQjjY4hSlqeBnv4O1Rh3m5pEGuL+xnduPafc/mn92N8C4K + 7+PHeksUYQjKhzvu71qAJmGDnUhUChTMBJSDYNmZQFkHnxoV2aNg2wLbMAPzqWHv0Vik + H9VoVD9YQ3ExBNfRltdDo2DV9bLqamy9OSwgKpYGYdX6QdtDp6BAKpmbQ/JGgWZpxpCi + jTKuR0GdbttAlmgoQ0FIYyCRnJRPvQ0XuafbiecihuXbC2/dKHFb4jvSWi/HBdAtduY6 + J23w== +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=9Umt+YZvpt70W8T8rAVpIkYNnRC78Ea2e+bULr+eQJE=; + b=Lu+Py/1TeErY8z6HyJbbFGVJ9klrblkNWbYj5Aw9ZJLHLRKJibgThYkFAyXTURJnD4 + CfNZWw/MHeTR9NZkfTkwQaRKJ7XA5g6HAeBbUQlb5G9pzD2BSXRRp3O6GaFGwXmSIb/f + VLHMwib9izGsMZvKl/zIJDAb3RTkmw9J+bXopHKgIzdXibvcpeaoRIoLUQWdpwdk2EBP + 2yxHd+igsF4KZNT+D7KZLJGAzFWGhs108GmkjI2vYKwbv8/2+QQAnhvitSLRgfrFMue3 + v3IWZVGpwHlKZgtakVsjX4Ax12mIgcpifl28N9vxnZXM85QnTJ/TQjWgxj12oN3R00BA + ptFw== +X-Gm-Message-State: + AOPr4FUDKLg3Cl0I6BFQ3vQaFZOSZC4227Ne1nX1VAt4//aCW5+f9+8PqOpgNQc0j89keg== +X-Received: by 10.28.22.134 with SMTP id 128mr3155801wmw.16.1463744299380; + Fri, 20 May 2016 04:38:19 -0700 (PDT) +Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) + by smtp.gmail.com with ESMTPSA id a75sm4172475wme.18.2016.05.20.04.38.18 + (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Fri, 20 May 2016 04:38:18 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH] emacs: show: allow user to insert rfc822 parts as messages +Date: Fri, 20 May 2016 12:38:15 +0100 +Message-Id: <1463744295-12533-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.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: Fri, 20 May 2016 11:38:29 -0000 + +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. +--- + +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 +