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 0F3A2431FC2
\r
6 for <notmuch@notmuchmail.org>; Wed, 29 Oct 2014 13:45:18 -0700 (PDT)
\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 shKk7to4iLk0 for <notmuch@notmuchmail.org>;
\r
16 Wed, 29 Oct 2014 13:45:09 -0700 (PDT)
\r
17 Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com
\r
18 [209.85.212.177]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id B442B431FB6
\r
21 for <notmuch@notmuchmail.org>; Wed, 29 Oct 2014 13:45:09 -0700 (PDT)
\r
22 Received: by mail-wi0-f177.google.com with SMTP id ex7so5692978wid.16
\r
23 for <notmuch@notmuchmail.org>; Wed, 29 Oct 2014 13:45:08 -0700 (PDT)
\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
25 d=1e100.net; s=20130820;
\r
26 h=x-gm-message-state:from:to:subject:in-reply-to:references
\r
27 :user-agent:date:message-id:mime-version:content-type;
\r
28 bh=SVKru4Azns5MQ5g6p1U6Cdf8+hNkM/wPcqhApBnQu1E=;
\r
29 b=OkNBAfypXVjfIQBcWKa/T6tPKffCXLCwLqA+6/V/xZXZkIMAenDIKf1wJedL8tssVk
\r
30 46pBWiE90tO5XQOy+MBTIw6YS9tY0jvK2rBhHLZvbqDYXd0cqKQzrIelJo4S1dDpRLoZ
\r
31 YF8VcIAH9TyN1dFYfaBIaGWJyvjT8YUk5JfXNbIl6MVmMuhXDo+k9oQb/OhBy5J5yRQk
\r
32 Aka0zYxfiR2L4wDORqvflq0uNfQ9EsiNPd6bMLfRWSjP2jOXYb8hB8Rfjgi0yZXmNCfC
\r
33 hVYO34isgj5RsaFp1AxZATB1354phv3Na1gmb9x/ANZAuEEqYONeD+4kGYjE28qXdEID
\r
36 ALoCoQnw6qprKYqc4ecLw72/lL0x+YM1DDe0UKT4SOyvRLHy/nXtH0vGObf1cH8cyoB7WLs/cu4p
\r
37 X-Received: by 10.180.104.99 with SMTP id gd3mr15085080wib.10.1414615508357;
\r
38 Wed, 29 Oct 2014 13:45:08 -0700 (PDT)
\r
39 Received: from localhost (dsl-hkibrasgw2-58c36d-48.dhcp.inet.fi.
\r
41 by mx.google.com with ESMTPSA id eu8sm15030747wic.1.2014.10.29.13.45.07
\r
42 for <multiple recipients>
\r
43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
\r
44 Wed, 29 Oct 2014 13:45:07 -0700 (PDT)
\r
45 From: Jani Nikula <jani@nikula.org>
\r
46 To: David Edmondson <dme@dme.org>, notmuch@notmuchmail.org
\r
47 Subject: Re: [PATCH] emacs: add stash support for git send-email command line
\r
48 In-Reply-To: <m2h9yn6zf1.fsf@dme.org>
\r
49 References: <1414525138-838-1-git-send-email-jani@nikula.org>
\r
50 <m2h9yn6zf1.fsf@dme.org>
\r
51 User-Agent: Notmuch/0.18.2+148~g4214adf (http://notmuchmail.org) Emacs/24.3.1
\r
52 (x86_64-pc-linux-gnu)
\r
53 Date: Wed, 29 Oct 2014 22:45:05 +0200
\r
54 Message-ID: <87y4ryzju6.fsf@nikula.org>
\r
56 Content-Type: text/plain
\r
57 X-BeenThere: notmuch@notmuchmail.org
\r
58 X-Mailman-Version: 2.1.13
\r
60 List-Id: "Use and development of the notmuch mail system."
\r
61 <notmuch.notmuchmail.org>
\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
63 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
65 List-Post: <mailto:notmuch@notmuchmail.org>
\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
69 X-List-Received-Date: Wed, 29 Oct 2014 20:45:18 -0000
\r
71 On Wed, 29 Oct 2014, David Edmondson <dme@dme.org> wrote:
\r
72 > On Tue, Oct 28 2014, Jani Nikula wrote:
\r
73 >> Stash From/To/Cc as --to/--to/--cc, respectively, and Message-Id as
\r
74 >> --in-reply-to, suitable for pasting to git send-email command line.
\r
76 >> emacs/notmuch-show.el | 25 +++++++++++++++++++++++++
\r
77 >> 1 file changed, 25 insertions(+)
\r
79 >> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
80 >> index a9974826e824..328c93ba0584 100644
\r
81 >> --- a/emacs/notmuch-show.el
\r
82 >> +++ b/emacs/notmuch-show.el
\r
83 >> @@ -1274,6 +1274,7 @@ reset based on the original query."
\r
84 >> (define-key map "t" 'notmuch-show-stash-to)
\r
85 >> (define-key map "l" 'notmuch-show-stash-mlarchive-link)
\r
86 >> (define-key map "L" 'notmuch-show-stash-mlarchive-link-and-go)
\r
87 >> + (define-key map "G" 'notmuch-show-stash-git-send-email)
\r
88 >> (define-key map "?" 'notmuch-subkeymap-help)
\r
90 >> "Submap for stash commands")
\r
91 >> @@ -2125,6 +2126,30 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')."
\r
92 >> (notmuch-show-stash-mlarchive-link mla)
\r
93 >> (browse-url (current-kill 0 t)))
\r
95 >> +(defun notmuch-show-stash-git-helper (addresses prefix)
\r
96 >> + "Escape, trim, and add PREFIX to each address in list of ADDRESSES."
\r
97 >> + (when addresses
\r
98 >> + (mapconcat (lambda (x)
\r
99 >> + (concat prefix "\""
\r
100 >> + ;; escape double-quotes
\r
101 >> + (replace-regexp-in-string
\r
103 >> + ;; trim leading and trailing spaces
\r
104 >> + (replace-regexp-in-string
\r
105 >> + "\\(^ *\\| *$\\)" ""
\r
107 >> + addresses "")))
\r
109 > This doesn't seem quite right. You leave a spurious trailing
\r
110 > space. Maybe that's because you need it in the following function to
\r
111 > separate the from/to/cc elements? That kind of interaction between the
\r
112 > two functions is icky.
\r
114 Agreed, thanks for pointing it out.
\r
116 > There's no need to test `addresses' at the head of the list - mapconcat
\r
117 > is fine with nil.
\r
121 > (defun notmuch-show-stash-git-helper (addresses prefix)
\r
122 > "Escape, trim, and add PREFIX to each address in list of ADDRESSES."
\r
123 > (mapconcat (lambda (x)
\r
124 > (concat prefix "\""
\r
125 > ;; escape double-quotes
\r
126 > (replace-regexp-in-string
\r
128 > ;; trim leading and trailing spaces
\r
129 > (replace-regexp-in-string
\r
130 > "\\(^ *\\| *$\\)" ""
\r
134 > This would remove the trailing space, so...
\r
137 >> +(defun notmuch-show-stash-git-send-email ()
\r
138 >> + "Copy From/To/Cc/Message-Id of current message to kill-ring in a form suitable for pasting to git send-email command line."
\r
140 >> + (notmuch-common-do-stash
\r
142 >> + (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-from)) "--to=")
\r
143 >> + (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-to)) "--to=")
\r
144 >> + (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-cc)) "--cc=")
\r
145 >> + (concat "--in-reply-to=\"" (notmuch-show-get-message-id t) "\""))))
\r
147 > ...this would have to use something like:
\r
149 > (mapconcat 'identity (list
\r
150 > (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-from)) "--to=")
\r
151 > (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-to)) "--to=")
\r
152 > (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-cc)) "--cc=")
\r
153 > (concat "--in-reply-to=\"" (notmuch-show-get-message-id t) "\""))
\r
156 > to separate the chunks (untested).
\r
158 The last "" has to be " " to separate the elements, but this brings
\r
159 another small wrinkle: if one of the headers is missing, typically Cc:,
\r
160 it will be nil in the list, and mapconcat adds spaces both sides of
\r
161 that, i.e. double space. Any ideas how to fix that?
\r
163 > Could you avoid the double-quote quoting by using single quotes inside
\r
166 The addresses may contain both single quotes and double quotes, so
\r
167 escaping either of them seems like the only option.
\r
169 > Do the leading and trailing spaces really matter?
\r
171 Does aesthetically displeasing count? Because message-tokenize-header
\r
172 splits using "," but headers typically have ", " between addresses, the
\r
173 end result will practically always have --to=" user@example.com" without
\r
176 Thanks for the helpful review; I'm not much of a lisp coder...
\r
183 > (Domo: Look, I managed to write 'separate', twice!)
\r
186 >> ;; Interactive part functions and their helpers
\r
188 >> (defun notmuch-show-generate-part-buffer (message-id nth)
\r
192 >> _______________________________________________
\r
193 >> notmuch mailing list
\r
194 >> notmuch@notmuchmail.org
\r
195 >> http://notmuchmail.org/mailman/listinfo/notmuch
\r