1 Return-Path: <jani@nikula.org>
\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 olra.theworths.org (Postfix) with ESMTP id 7187D431FD0
\r
6 for <notmuch@notmuchmail.org>; Tue, 20 Dec 2011 12:05:38 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id SS+dfB9k31tH for <notmuch@notmuchmail.org>;
\r
16 Tue, 20 Dec 2011 12:05:37 -0800 (PST)
\r
17 Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com
\r
18 [74.125.83.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client
\r
19 certificate requested) by olra.theworths.org (Postfix) with ESMTPS id
\r
20 A2473431FB6 for <notmuch@notmuchmail.org>; Tue, 20 Dec 2011 12:05:37 -0800
\r
22 Received: by eekd41 with SMTP id d41so8152887eek.26
\r
23 for <notmuch@notmuchmail.org>; Tue, 20 Dec 2011 12:05:36 -0800 (PST)
\r
24 Received: by 10.204.149.212 with SMTP id u20mr1405437bkv.120.1324411536181;
\r
25 Tue, 20 Dec 2011 12:05:36 -0800 (PST)
\r
26 Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.
\r
28 by mx.google.com with ESMTPS id fa8sm6275186bkc.14.2011.12.20.12.05.33
\r
29 (version=SSLv3 cipher=OTHER); Tue, 20 Dec 2011 12:05:34 -0800 (PST)
\r
30 From: Jani Nikula <jani@nikula.org>
\r
31 To: notmuch@notmuchmail.org
\r
32 Subject: Re: [PATCH] emacs: create patch filename from subject for inline
\r
34 In-Reply-To: <1321657368-13872-1-git-send-email-jani@nikula.org>
\r
35 References: <1321657368-13872-1-git-send-email-jani@nikula.org>
\r
36 User-Agent: Notmuch/0.10.2+114~gf57278c (http://notmuchmail.org) Emacs/23.3.1
\r
38 Date: Tue, 20 Dec 2011 22:05:31 +0200
\r
39 Message-ID: <87aa6nxb3o.fsf@nikula.org>
\r
41 Content-Type: text/plain; charset=us-ascii
\r
42 X-BeenThere: notmuch@notmuchmail.org
\r
43 X-Mailman-Version: 2.1.13
\r
45 List-Id: "Use and development of the notmuch mail system."
\r
46 <notmuch.notmuchmail.org>
\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
50 List-Post: <mailto:notmuch@notmuchmail.org>
\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
54 X-List-Received-Date: Tue, 20 Dec 2011 20:05:38 -0000
\r
57 Shameless promotion of own patches... I suppose not many use the
\r
58 notmuch-wash-convert-inline-patch-to-part option, but with this patch
\r
59 I've actually started to like it better. An actual patch name from
\r
60 subject instead of "inline patch".
\r
62 As I said, the lisp is less than perfect here, but this is still better
\r
63 than what's existing.
\r
72 On Sat, 19 Nov 2011 01:02:48 +0200, Jani Nikula <jani@nikula.org> wrote:
\r
73 > Use the mail subject line for creating a descriptive filename for the wash
\r
74 > generated inline patch fake parts. The names are similar to the ones
\r
75 > created by 'git format-patch', just without the leading numbers.
\r
77 > Signed-off-by: Jani Nikula <jani@nikula.org>
\r
81 > I know notmuch-subject-to-patch-filename is totally un-lispy. Suggestions
\r
82 > welcome on how to make it lispy and keep it somewhat readable.
\r
84 > If we later want to have a '>' counterpart to '|' to save messages to files
\r
85 > rather than pipe, then this could be generalized and re-used for creating
\r
86 > the suggested filename for that.
\r
88 > I don't even use the notmuch-wash-convert-inline-patch-to-part option that
\r
89 > much, but having it suggest "inline patch" as filename is just ugly...
\r
91 > emacs/notmuch-wash.el | 16 +++++++++++++++-
\r
92 > 1 files changed, 15 insertions(+), 1 deletions(-)
\r
94 > diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
\r
95 > index 1f420b2..755d64a 100644
\r
96 > --- a/emacs/notmuch-wash.el
\r
97 > +++ b/emacs/notmuch-wash.el
\r
98 > @@ -290,6 +290,17 @@ When doing so, maintaining citation leaders in the wrapped text."
\r
100 > (defvar diff-file-header-re) ; From `diff-mode.el'.
\r
102 > +(defun notmuch-subject-to-patch-filename (str)
\r
103 > + "Convert a typical patch mail subject line into a suitable filename."
\r
105 > + (setq s (replace-regexp-in-string "^ *\\(\\[[^]]*\\]\\)? *" "" s))
\r
106 > + (setq s (replace-regexp-in-string "[. ]*$" "" s))
\r
107 > + (setq s (replace-regexp-in-string "[^A-Za-z0-9._-]+" "-" s))
\r
108 > + (setq s (replace-regexp-in-string "\\.+" "." s))
\r
109 > + (when (> (length s) 52)
\r
110 > + (setq s (substring s 0 52)))
\r
111 > + (concat s ".patch")))
\r
113 > (defun notmuch-wash-convert-inline-patch-to-part (msg depth)
\r
114 > "Convert an inline patch into a fake 'text/x-diff' attachment.
\r
116 > @@ -316,7 +327,10 @@ for error."
\r
117 > (setq part (plist-put part :content-type "text/x-diff"))
\r
118 > (setq part (plist-put part :content (buffer-string)))
\r
119 > (setq part (plist-put part :id -1))
\r
120 > - (setq part (plist-put part :filename "inline patch"))
\r
121 > + (setq part (plist-put part :filename
\r
122 > + (notmuch-subject-to-patch-filename
\r
124 > + (plist-get msg :headers) :Subject))))
\r
125 > (delete-region (point-min) (point-max))
\r
126 > (notmuch-show-insert-bodypart nil part depth))))))
\r