Re: Hi all
[notmuch-archives.git] / bb / 14b0481b0195d9bdbb4f2d10b720358306ae5b
1 Return-Path: <markwalters1009@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5  by arlo.cworth.org (Postfix) with ESMTP id A1B316DE01D0\r
6  for <notmuch@notmuchmail.org>; Fri, 20 May 2016 04:38:29 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.316\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.316 tagged_above=-999 required=5 tests=[AWL=0.254,\r
12   DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13  FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7,\r
14  RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001]\r
15  autolearn=disabled\r
16 Received: from arlo.cworth.org ([127.0.0.1])\r
17  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
18  with ESMTP id NlKYqNX52kzc for <notmuch@notmuchmail.org>;\r
19  Fri, 20 May 2016 04:38:21 -0700 (PDT)\r
20 Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com\r
21  [74.125.82.66]) by arlo.cworth.org (Postfix) with ESMTPS id 826666DE00F5 for\r
22  <notmuch@notmuchmail.org>; Fri, 20 May 2016 04:38:21 -0700 (PDT)\r
23 Received: by mail-wm0-f66.google.com with SMTP id 67so5312157wmg.0\r
24  for <notmuch@notmuchmail.org>; Fri, 20 May 2016 04:38:21 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26  h=from:to:cc:subject:date:message-id;\r
27  bh=9Umt+YZvpt70W8T8rAVpIkYNnRC78Ea2e+bULr+eQJE=;\r
28  b=hpmTeuupXOeE78vChOBSOYbumAwobmvqaKQxskIvyjV+jv18HOXeodTSWSm+SPiFpr\r
29  n+IYw5fRSEFmYB38FUa7WmcQjjY4hSlqeBnv4O1Rh3m5pEGuL+xnduPafc/mn92N8C4K\r
30  7+PHeksUYQjKhzvu71qAJmGDnUhUChTMBJSDYNmZQFkHnxoV2aNg2wLbMAPzqWHv0Vik\r
31  H9VoVD9YQ3ExBNfRltdDo2DV9bLqamy9OSwgKpYGYdX6QdtDp6BAKpmbQ/JGgWZpxpCi\r
32  jTKuR0GdbttAlmgoQ0FIYyCRnJRPvQ0XuafbiecihuXbC2/dKHFb4jvSWi/HBdAtduY6\r
33  J23w==\r
34 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
35  d=1e100.net; s=20130820;\r
36  h=x-gm-message-state:from:to:cc:subject:date:message-id;\r
37  bh=9Umt+YZvpt70W8T8rAVpIkYNnRC78Ea2e+bULr+eQJE=;\r
38  b=Lu+Py/1TeErY8z6HyJbbFGVJ9klrblkNWbYj5Aw9ZJLHLRKJibgThYkFAyXTURJnD4\r
39  CfNZWw/MHeTR9NZkfTkwQaRKJ7XA5g6HAeBbUQlb5G9pzD2BSXRRp3O6GaFGwXmSIb/f\r
40  VLHMwib9izGsMZvKl/zIJDAb3RTkmw9J+bXopHKgIzdXibvcpeaoRIoLUQWdpwdk2EBP\r
41  2yxHd+igsF4KZNT+D7KZLJGAzFWGhs108GmkjI2vYKwbv8/2+QQAnhvitSLRgfrFMue3\r
42  v3IWZVGpwHlKZgtakVsjX4Ax12mIgcpifl28N9vxnZXM85QnTJ/TQjWgxj12oN3R00BA\r
43  ptFw==\r
44 X-Gm-Message-State:\r
45  AOPr4FUDKLg3Cl0I6BFQ3vQaFZOSZC4227Ne1nX1VAt4//aCW5+f9+8PqOpgNQc0j89keg==\r
46 X-Received: by 10.28.22.134 with SMTP id 128mr3155801wmw.16.1463744299380;\r
47  Fri, 20 May 2016 04:38:19 -0700 (PDT)\r
48 Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
49  by smtp.gmail.com with ESMTPSA id a75sm4172475wme.18.2016.05.20.04.38.18\r
50  (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
51  Fri, 20 May 2016 04:38:18 -0700 (PDT)\r
52 From: Mark Walters <markwalters1009@gmail.com>\r
53 To: notmuch@notmuchmail.org\r
54 Subject: [PATCH] emacs: show: allow user to insert rfc822 parts as messages\r
55 Date: Fri, 20 May 2016 12:38:15 +0100\r
56 Message-Id: <1463744295-12533-1-git-send-email-markwalters1009@gmail.com>\r
57 X-Mailer: git-send-email 2.1.4\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.20\r
60 Precedence: list\r
61 List-Id: "Use and development of the notmuch mail system."\r
62  <notmuch.notmuchmail.org>\r
63 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
64  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
66 List-Post: <mailto:notmuch@notmuchmail.org>\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
68 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
69  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
70 X-List-Received-Date: Fri, 20 May 2016 11:38:29 -0000\r
71 \r
72 This adds a part-handler function that uses notmuch-insert to insert\r
73 an rfc822 part as a message in its own right. This allows the user to\r
74 reply directly to that message.\r
75 ---\r
76 \r
77 I receive quite a lot of forwarded messages which include the original\r
78 message as an rfc822 part, and have used this for quite some time\r
79 without any problems.\r
80 \r
81 Best wishes\r
82 \r
83 Mark\r
84 \r
85 \r
86 emacs/notmuch-show.el | 29 ++++++++++++++++++++++++-----\r
87  1 file changed, 24 insertions(+), 5 deletions(-)\r
88 \r
89 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
90 index 5d9b7b4..de41a8f 100644\r
91 --- a/emacs/notmuch-show.el\r
92 +++ b/emacs/notmuch-show.el\r
93 @@ -141,6 +141,11 @@ indentation."\r
94                  (const :tag "View interactively"\r
95                         notmuch-show-interactively-view-part)))\r
96  \r
97 +(defcustom notmuch-show-part-insert-folder ""\r
98 +  "Default folder to insert rfc822 parts"\r
99 +  :group 'notmuch-show\r
100 +  :type 'string)\r
101 +\r
102  (defcustom notmuch-show-only-matching-messages nil\r
103    "Only matching messages are shown by default."\r
104    :type 'boolean\r
105 @@ -1403,6 +1408,7 @@ reset based on the original query."\r
106      (define-key map "v" 'notmuch-show-view-part)\r
107      (define-key map "o" 'notmuch-show-interactively-view-part)\r
108      (define-key map "|" 'notmuch-show-pipe-part)\r
109 +    (define-key map "i" 'notmuch-show-insert-part)\r
110      (define-key map "?" 'notmuch-subkeymap-help)\r
111      map)\r
112    "Submap for part commands")\r
113 @@ -2330,11 +2336,13 @@ caller is responsible for killing this buffer as appropriate."\r
114          (disposition (if filename `(attachment (filename . ,filename)))))\r
115      (mm-make-handle buf (list computed-type) nil nil disposition)))\r
116  \r
117 -(defun notmuch-show-apply-to-current-part-handle (fn)\r
118 +(defun notmuch-show-apply-to-current-part-handle (fn &rest args)\r
119    "Apply FN to an mm-handle for the part containing point.\r
120  \r
121 -This ensures that the temporary buffer created for the mm-handle\r
122 -is destroyed when FN returns."\r
123 +Any ARGS are passed to the function FN as arguments after the mm-handle.\r
124 +\r
125 +This function ensures that the temporary buffer created for the\r
126 +mm-handle is destroyed when FN returns."\r
127    (let ((handle (notmuch-show-current-part-handle)))\r
128      ;; emacs 24.3+ puts stdout/stderr into the calling buffer so we\r
129      ;; call it from a temp-buffer, unless\r
130 @@ -2343,9 +2351,9 @@ is destroyed when FN returns."\r
131      (unwind-protect\r
132         (if notmuch-show-attachment-debug\r
133             (with-current-buffer (generate-new-buffer " *notmuch-part*")\r
134 -             (funcall fn handle))\r
135 +             (apply fn handle args))\r
136           (with-temp-buffer\r
137 -           (funcall fn handle)))\r
138 +           (apply fn handle args)))\r
139        (kill-buffer (mm-handle-buffer handle)))))\r
140  \r
141  (defun notmuch-show-part-button-default (&optional button)\r
142 @@ -2379,6 +2387,17 @@ is destroyed when FN returns."\r
143    (interactive)\r
144    (notmuch-show-apply-to-current-part-handle #'mm-pipe-part))\r
145  \r
146 +(defun notmuch-show-insert-part ()\r
147 +  "If the current part is rfc822 then insert into the mailstore"\r
148 +  (interactive)\r
149 +  (let* ((part (notmuch-show-get-part-properties))\r
150 +        (computed-type (plist-get part :computed-type)))\r
151 +    (if (notmuch-match-content-type computed-type "message/rfc822")\r
152 +       (let* ((folder (read-from-minibuffer "Folder to save part to: "\r
153 +                                            notmuch-show-part-insert-folder))\r
154 +              (cmd (concat notmuch-command " insert --folder=" folder)))\r
155 +         (notmuch-show-apply-to-current-part-handle #'mm-pipe-part cmd))\r
156 +      (message "Not a message/rfc822 part."))))\r
157  \r
158  (provide 'notmuch-show)\r
159  \r
160 -- \r
161 2.1.4\r
162 \r