Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 40 / d3bd1a65b7dba15b6c3a9008cafbb487bc1a87
1 Return-Path: <dme@dme.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 11C5B431FC2\r
6         for <notmuch@notmuchmail.org>; Wed, 29 Oct 2014 01:41:30 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.699\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7, UNPARSEABLE_RELAY=0.001]\r
13         autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id PCKsS4z3Flxo for <notmuch@notmuchmail.org>;\r
17         Wed, 29 Oct 2014 01:41:26 -0700 (PDT)\r
18 Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com\r
19         [209.85.212.180]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 7E821431FB6\r
22         for <notmuch@notmuchmail.org>; Wed, 29 Oct 2014 01:41:26 -0700 (PDT)\r
23 Received: by mail-wi0-f180.google.com with SMTP id hi2so3872526wib.7\r
24         for <notmuch@notmuchmail.org>; Wed, 29 Oct 2014 01:41:25 -0700 (PDT)\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
26         d=1e100.net; s=20130820;\r
27         h=x-gm-message-state:to:subject:in-reply-to:references:user-agent\r
28         :from:date:message-id:mime-version:content-type;\r
29         bh=XVN2pKdK1fVnTPtKrk0Z5163MfV1YKiwneEeMIioY/I=;\r
30         b=g/SkJdzsRf2X2I7ZEtqVfrxvMY6G5n2JE9OsCKW5ffpnmbJCTwKC+pC3YGpBbwEpYg\r
31         l2H+8Y+l37N0/xmkk/kkaXbHWYnyM9s2uuJs2qxMwqRetnKf26/+oWbByCg49kikvMzG\r
32         te7ExTFQ+lcq3YkPlv+jrMgrmBvSLH8xQQBlpMJ7exKuT7sfVwd2vKGZKzVeOzDCpow4\r
33         DRoh2rKGpGwRHi5DTOXJmSEu2ss1CKpOt/wnwMfDJGYhNl94otjYb1tBomAuM+zrn2ZV\r
34         kIGfcGgszK7oR5OLzdfRPkA6fZ4A+DDD3OYUXVgMyXDKC65W3KfZDPd9btkz5zXYJytV\r
35         3mpg==\r
36 X-Gm-Message-State:\r
37  ALoCoQkNWXrAxPZ7D3XBCXcfZbx7S0gu5M9/Vad7PlMU/IG2GNw+fMqcfRec5jQ0O2baReQlqhdQ\r
38 X-Received: by 10.180.82.7 with SMTP id e7mr10702666wiy.27.1414572084207;\r
39         Wed, 29 Oct 2014 01:41:24 -0700 (PDT)\r
40 Received: from disaster-area.hh.sledj.net\r
41         ([2a01:348:1a2:1:ea39:35ff:fe2c:a227])\r
42         by mx.google.com with ESMTPSA id\r
43         bg10sm4377180wjc.47.2014.10.29.01.41.23 for <multiple recipients>\r
44         (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
45         Wed, 29 Oct 2014 01:41:23 -0700 (PDT)\r
46 Received: from localhost (30000@localhost [local]);\r
47         by localhost (OpenSMTPD) with ESMTPA id 1cc0af54;\r
48         Wed, 29 Oct 2014 08:41:22 +0000 (UTC)\r
49 To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
50 Subject: Re: [PATCH] emacs: add stash support for git send-email command line\r
51 In-Reply-To: <1414525138-838-1-git-send-email-jani@nikula.org>\r
52 References: <1414525138-838-1-git-send-email-jani@nikula.org>\r
53 User-Agent: Notmuch/0.18.1 (http://notmuchmail.org) Emacs/24.3.1\r
54         (x86_64-apple-darwin14.0.0)\r
55 From: David Edmondson <dme@dme.org>\r
56 Date: Wed, 29 Oct 2014 08:41:22 +0000\r
57 Message-ID: <m2h9yn6zf1.fsf@dme.org>\r
58 MIME-Version: 1.0\r
59 Content-Type: text/plain\r
60 X-BeenThere: notmuch@notmuchmail.org\r
61 X-Mailman-Version: 2.1.13\r
62 Precedence: list\r
63 List-Id: "Use and development of the notmuch mail system."\r
64         <notmuch.notmuchmail.org>\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
66         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
68 List-Post: <mailto:notmuch@notmuchmail.org>\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
72 X-List-Received-Date: Wed, 29 Oct 2014 08:41:30 -0000\r
73 \r
74 On Tue, Oct 28 2014, Jani Nikula wrote:\r
75 > Stash From/To/Cc as --to/--to/--cc, respectively, and Message-Id as\r
76 > --in-reply-to, suitable for pasting to git send-email command line.\r
77 > ---\r
78 >  emacs/notmuch-show.el | 25 +++++++++++++++++++++++++\r
79 >  1 file changed, 25 insertions(+)\r
80 >\r
81 > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
82 > index a9974826e824..328c93ba0584 100644\r
83 > --- a/emacs/notmuch-show.el\r
84 > +++ b/emacs/notmuch-show.el\r
85 > @@ -1274,6 +1274,7 @@ reset based on the original query."\r
86 >      (define-key map "t" 'notmuch-show-stash-to)\r
87 >      (define-key map "l" 'notmuch-show-stash-mlarchive-link)\r
88 >      (define-key map "L" 'notmuch-show-stash-mlarchive-link-and-go)\r
89 > +    (define-key map "G" 'notmuch-show-stash-git-send-email)\r
90 >      (define-key map "?" 'notmuch-subkeymap-help)\r
91 >      map)\r
92 >    "Submap for stash commands")\r
93 > @@ -2125,6 +2126,30 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')."\r
94 >    (notmuch-show-stash-mlarchive-link mla)\r
95 >    (browse-url (current-kill 0 t)))\r
96 >  \r
97 > +(defun notmuch-show-stash-git-helper (addresses prefix)\r
98 > +  "Escape, trim, and add PREFIX to each address in list of ADDRESSES."\r
99 > +  (when addresses\r
100 > +    (mapconcat (lambda (x)\r
101 > +              (concat prefix "\""\r
102 > +                      ;; escape double-quotes\r
103 > +                      (replace-regexp-in-string\r
104 > +                       "\"" "\\\\\""\r
105 > +                       ;; trim leading and trailing spaces\r
106 > +                       (replace-regexp-in-string\r
107 > +                        "\\(^ *\\| *$\\)" ""\r
108 > +                        x)) "\" "))\r
109 > +            addresses "")))\r
110 \r
111 This doesn't seem quite right. You leave a spurious trailing\r
112 space. Maybe that's because you need it in the following function to\r
113 separate the from/to/cc elements? That kind of interaction between the\r
114 two functions is icky.\r
115 \r
116 There's no need to test `addresses' at the head of the list - mapconcat\r
117 is fine with nil.\r
118 \r
119 How about:\r
120 \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
127                         "\"" "\\\\\""\r
128                         ;; trim leading and trailing spaces\r
129                         (replace-regexp-in-string\r
130                          "\\(^ *\\| *$\\)" ""\r
131                          x)) "\""))\r
132              addresses " "))\r
133 \r
134 This would remove the trailing space, so...\r
135 \r
136 > +\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
139 > +  (interactive)\r
140 > +  (notmuch-common-do-stash\r
141 > +   (concat\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
146 \r
147 ...this would have to use something like:\r
148 \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
154              "")\r
155 \r
156 to separate the chunks (untested).\r
157 \r
158 Could you avoid the double-quote quoting by using single quotes inside\r
159 the strings? Do the leading and trailing spaces really matter?\r
160 \r
161 (Domo: Look, I managed to write 'separate', twice!)\r
162 \r
163 > +\r
164 >  ;; Interactive part functions and their helpers\r
165 >  \r
166 >  (defun notmuch-show-generate-part-buffer (message-id nth)\r
167 > -- \r
168 > 2.1.1\r
169 >\r
170 > _______________________________________________\r
171 > notmuch mailing list\r
172 > notmuch@notmuchmail.org\r
173 > http://notmuchmail.org/mailman/listinfo/notmuch\r