[PATCH 4/4] Update NEWS for user.other_name
[notmuch-archives.git] / cc / 4b8dd45acade351d2e8f00b15762e56dd991ee
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 1628C431FAF\r
6         for <notmuch@notmuchmail.org>; Wed, 19 Mar 2014 14:54: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.7\r
10 X-Spam-Level: \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 b546+2belAIF for <notmuch@notmuchmail.org>;\r
16         Wed, 19 Mar 2014 14:54:21 -0700 (PDT)\r
17 Received: from mail-la0-f53.google.com (mail-la0-f53.google.com\r
18         [209.85.215.53]) (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 65BD4431FAE\r
21         for <notmuch@notmuchmail.org>; Wed, 19 Mar 2014 14:54:21 -0700 (PDT)\r
22 Received: by mail-la0-f53.google.com with SMTP id b8so6288937lan.26\r
23         for <notmuch@notmuchmail.org>; Wed, 19 Mar 2014 14:54:19 -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         :content-transfer-encoding;\r
29         bh=5f1TvgYuiL9m3PlxRQ7+DlgiPangqPmJN7lxenFFImM=;\r
30         b=R4YU8esDyw0x/Ab1+zLSKdO9+c7ZHUODWgA0kzDW8llx1ZG8JUQ6FkMR+gvTrtbtUY\r
31         3DhDYmejcp2lzxwAY+iD4GHaOxwI9/i24WfrV1ctADpc3VIj6+OdylV7mQrQctXeQBKS\r
32         is+LftTb6IlqKimGTMjDMuafUej7VknwuAdGG2yn2A05Pbl6XKlaFQqmxldRjY82ZwGb\r
33         sExQlItANE0NFnGXXzjA/hTWF3lc09t77rQtDVIEjDBcxPw6eh39B1GmV2P3NcbEuHMy\r
34         oNDPtm2Yyrs+NLFAGTgkgQgdAKTLEmd+wbo9GLOdp1pqEva9flutiXQv25brn7fK3DBA\r
35         uaGw==\r
36 X-Gm-Message-State:\r
37  ALoCoQm4HWKiVXGMk0uOeHHEqHDxAportEC0yCUYnxLq/ucBcMHkSHrv1cu6ZawNF4+LTcpW+w+/\r
38 X-Received: by 10.112.137.5 with SMTP id qe5mr26138470lbb.16.1395266058612;\r
39         Wed, 19 Mar 2014 14:54:18 -0700 (PDT)\r
40 Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
41         [88.195.111.91])\r
42         by mx.google.com with ESMTPSA id rd5sm17906775lbb.0.2014.03.19.14.54.16\r
43         for <multiple recipients>\r
44         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
45         Wed, 19 Mar 2014 14:54:17 -0700 (PDT)\r
46 From: Jani Nikula <jani@nikula.org>\r
47 To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org\r
48 Subject: Re: [PATCH] cli: add a tool for starting new message in the emacs ui\r
49 In-Reply-To: <m2eh1x6fwt.fsf@guru.guru-group.fi>\r
50 References: <1395257153-29764-1-git-send-email-jani@nikula.org>\r
51         <m2eh1x6fwt.fsf@guru.guru-group.fi>\r
52 User-Agent: Notmuch/0.17+142~g30045abd801f (http://notmuchmail.org)\r
53         Emacs/24.3.1 (x86_64-pc-linux-gnu)\r
54 Date: Wed, 19 Mar 2014 23:54:15 +0200\r
55 Message-ID: <877g7pn9bs.fsf@nikula.org>\r
56 MIME-Version: 1.0\r
57 Content-Type: text/plain; charset=utf-8\r
58 Content-Transfer-Encoding: quoted-printable\r
59 X-BeenThere: notmuch@notmuchmail.org\r
60 X-Mailman-Version: 2.1.13\r
61 Precedence: list\r
62 List-Id: "Use and development of the notmuch mail system."\r
63         <notmuch.notmuchmail.org>\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
65         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
67 List-Post: <mailto:notmuch@notmuchmail.org>\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
70         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
71 X-List-Received-Date: Wed, 19 Mar 2014 21:54:30 -0000\r
72 \r
73 On Wed, 19 Mar 2014, Tomi Ollila <tomi.ollila@iki.fi> wrote:\r
74 > On Wed, Mar 19 2014, Jani Nikula <jani@nikula.org> wrote:\r
75 >\r
76 >> Add a tool to start composing an email in the Notmuch Emacs UI with\r
77 >> the specified subject, recipients, and message body.\r
78 >>\r
79 >> ---\r
80 >>\r
81 >> I need something like this to script some mails, particularly with the\r
82 >> mutt compatible options, but I also think notmuch must have long\r
83 >> options. I then got a little carried away with figuring out how to\r
84 >> support both. I think it turned out pretty neat, except due to some\r
85 >> subtlety it only works with bash.\r
86 >>\r
87 >> I didn't integrate this in the man build or install or anything,\r
88 >> because I wanted to get feedback first on whether we want to have this\r
89 >> at all. Or if it should live in contrib or something.\r
90 >>\r
91 >> BR,\r
92 >> Jani.\r
93 >> ---\r
94 >\r
95 > Quick glance to the code and some thoughts.\r
96 \r
97 Thanks!\r
98 \r
99 >\r
100 >>  doc/man1/notmuch-emacs-mua.rst |  50 ++++++++++++++++++\r
101 >>  notmuch-emacs-mua              | 113 ++++++++++++++++++++++++++++++++++=\r
102 +++++++\r
103 >>  2 files changed, 163 insertions(+)\r
104 >>  create mode 100644 doc/man1/notmuch-emacs-mua.rst\r
105 >>  create mode 100755 notmuch-emacs-mua\r
106 >>\r
107 >> diff --git a/doc/man1/notmuch-emacs-mua.rst b/doc/man1/notmuch-emacs-mua=\r
108 .rst\r
109 >> new file mode 100644\r
110 >> index 000000000000..6e63818492fb\r
111 >> --- /dev/null\r
112 >> +++ b/doc/man1/notmuch-emacs-mua.rst\r
113 >> @@ -0,0 +1,50 @@\r
114 >> +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\r
115 >> +notmuch-emacs-mua\r
116 >> +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\r
117 >> +\r
118 >> +SYNOPSIS\r
119 >> +=3D=3D=3D=3D=3D=3D=3D=3D\r
120 >> +\r
121 >> +**notmuch-emacs-mua** [options ...] [<to-address> ...]\r
122 >> +\r
123 >> +DESCRIPTION\r
124 >> +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\r
125 >> +\r
126 >> +Start composing an email in the Notmuch Emacs UI with the specified\r
127 >> +subject, recipients, and message body.\r
128 >> +\r
129 >> +For **notmuch-emacs-mua** to work, you need **emacsclient** and an\r
130 >> +already running Emacs with a server.\r
131 >> +\r
132 >> +Supported options for **notmuch-emacs-mua** include\r
133 >> +\r
134 >> +    ``-h, --help``\r
135 >> +        Display help.\r
136 >> +\r
137 >> +    ``-s, --subject=3D``\ <subject>\r
138 >> +        Specify the subject of the message.\r
139 >> +\r
140 >> +    ``--to=3D``\ <to-address>\r
141 >> +        Specify a recipient (To).\r
142 >> +\r
143 >> +    ``-c, --cc=3D``\ <cc-address>\r
144 >> +        Specify a carbon-copy (Cc) recipient.\r
145 >> +\r
146 >> +    ``-b, --bcc=3D``\ <bcc-address>\r
147 >> +        Specify a blind-carbon-copy (Bcc) recipient.\r
148 >> +\r
149 >> +    ``-i, --body=3D``\ <file>\r
150 >> +        Specify a file to include into the body of the message.\r
151 >> +\r
152 >> +    ``--print``\r
153 >> +        Output the resulting elisp to stdout instead of evaluating it.\r
154 >> +\r
155 >> +The supported positional parameters and short options are a compatible\r
156 >> +subset of the **mutt** MUA command-line options.\r
157 >> +\r
158 >> +Options may be specified multiple times.\r
159 >> +\r
160 >> +SEE ALSO\r
161 >> +=3D=3D=3D=3D=3D=3D=3D=3D\r
162 >> +\r
163 >> +**notmuch(1)**, **emacsclient(1)**, **mutt(1)**\r
164 >\r
165 > It would be convenient to the user to have the manual embedded in\r
166 > the script in case no args are given or so (or that is convenient\r
167 > to me ;) and no namual page at all...\r
168 \r
169 If this is to become part of notmuch, I think a separate man page is in\r
170 order. Otherwise, agreed (and even had that in an earlier version).\r
171 \r
172 >\r
173 >> diff --git a/notmuch-emacs-mua b/notmuch-emacs-mua\r
174 >> new file mode 100755\r
175 >> index 000000000000..a482fe1a8eca\r
176 >> --- /dev/null\r
177 >> +++ b/notmuch-emacs-mua\r
178 >> @@ -0,0 +1,113 @@\r
179 >> +#!/bin/bash\r
180 >\r
181 > #!/usr/bin/env bash\r
182 \r
183 Agreed.\r
184 \r
185 >\r
186 >> +#\r
187 >> +# notmuch-emacs-mua - start composing a mail on the command line\r
188 >> +#\r
189 >> +# Copyright =C2=A9 2014 Jani Nikula\r
190 >> +#\r
191 >> +# This program is free software: you can redistribute it and/or modify\r
192 >> +# it under the terms of the GNU General Public License as published by\r
193 >> +# the Free Software Foundation, either version 3 of the License, or\r
194 >> +# (at your option) any later version.\r
195 >> +#\r
196 >> +# This program is distributed in the hope that it will be useful,\r
197 >> +# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
198 >> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
199 >> +# GNU General Public License for more details.\r
200 >> +#\r
201 >> +# You should have received a copy of the GNU General Public License\r
202 >> +# along with this program.  If not, see http://www.gnu.org/licenses/ .\r
203 >> +#\r
204 >> +# Authors: Jani Nikula <jani@nikula.org>\r
205 >> +#\r
206 >> +\r
207 >> +set -e\r
208 >\r
209 > set -eu would be nice IMO...\r
210 >\r
211 > ... then initialize all vars to empty strings, like PRINT_ONLY=3D\r
212 > ... and in cases not possible syntax ${1-} can be used.\r
213 \r
214 Agreed.\r
215 \r
216 >\r
217 >> +\r
218 >> +# The crux of it all: construct an elisp progn and eval it.\r
219 >> +ELISP=3D"(progn (notmuch-mua-new-mail)"\r
220 >\r
221 > ELISP=3D"(progn (require 'notmuch) (notmuch-mua-new-mail)"\r
222 \r
223 Right.\r
224 \r
225 >\r
226 >> +\r
227 >> +while getopts :s:c:b:i:h opt; do\r
228 >> +    # Handle errors and long options.\r
229 >> +    case "${opt}" in\r
230 >> +    :)\r
231 >> +        echo "$0: short option -${OPTARG} requires an argument." >&2\r
232 >> +        exit 1\r
233 >> +        ;;\r
234 >> +    \?)\r
235 >> +        opt=3D$1\r
236 >> +        if [ "${OPTARG}" !=3D "-" ]; then\r
237 >> +            echo "$0: unknown short option -${OPTARG}." >&2\r
238 >> +            exit 1\r
239 >> +        fi\r
240 >> +\r
241 >> +        case "${opt}" in\r
242 >> +            # Long options with arguments.\r
243 >> +            --subject=3D*|--to=3D*|--cc=3D*|--bcc=3D*|--body=3D*)\r
244 >> +                OPTARG=3D${opt#--*=3D}\r
245 >> +                opt=3D${opt%%=3D*}\r
246 >> +                ;;\r
247 >> +            # Long options without arguments.\r
248 >> +            --help|--print)\r
249 >> +                ;;\r
250 >> +            *)\r
251 >> +                echo "$0: unknown long option ${opt}, or argument mismatch." >&2\r
252 >> +                exit 1\r
253 >> +                ;;\r
254 >> +        esac\r
255 >> +        # getopts does not do this for what it considers errors.\r
256 >> +        OPTIND=3D$((OPTIND + 1))\r
257 >> +        ;;\r
258 >> +    esac\r
259 >> +\r
260 >> +    case "${opt}" in\r
261 >> +    --help|h)\r
262 >> +        exec man notmuch-search\r
263 >> +        ;;\r
264 >> +    --subject|s)\r
265 >> +        ELISP=3D"${ELISP} (message-goto-subject) (insert \"${OPTARG}\")"\r
266 >> +        ;;\r
267 >> +    --to)\r
268 >> +        ELISP=3D"${ELISP} (message-goto-to) (insert \"${OPTARG}, \")"\r
269 >> +        ;;\r
270 >> +    --cc|c)\r
271 >> +        ELISP=3D"${ELISP} (message-goto-cc) (insert \"${OPTARG}, \")"\r
272 >> +        ;;\r
273 >> +    --bcc|b)\r
274 >> +        ELISP=3D"${ELISP} (message-goto-bcc) (insert \"${OPTARG}, \")"\r
275 >> +        ;;\r
276 >> +    --body|i)\r
277 >> +        ELISP=3D"${ELISP} (message-goto-body) (cd \"${PWD}\") (insert-file=\r
278  \"${OPTARG}\")"\r
279 >> +        ;;\r
280 >> +    --print)\r
281 >> +        PRINT_ONLY=3D1\r
282 >> +        ;;\r
283 >> +    *)\r
284 >> +        # We should never end up here.\r
285 >> +        echo "$0: internal error (option ${opt})." >&2\r
286 >> +        exit 1\r
287 >> +        ;;\r
288 >> +    esac\r
289 >> +\r
290 >> +    shift $((OPTIND - 1))\r
291 >> +    OPTIND=3D1\r
292 >> +done\r
293 >> +\r
294 >> +# Positional parameters.\r
295 >> +while [ $# -gt 0 ]; do\r
296 >> +    ELISP=3D"${ELISP} (message-goto-to) (insert \"${1}, \")"\r
297 >> +    shift\r
298 >> +done\r
299 >\r
300 > for arg; do\r
301 \r
302 for arg in $@; ?\r
303 \r
304 >    ELISP=3D"${ELISP} (message-goto-to) (insert \"${arg}, \")"\r
305 > done\r
306 >\r
307 > I tried to address Austin's comment on IRC with=20\r
308 > printf -v qarg %q "$arg"  -- that has problem if there is whitespace\r
309 > in arg. maybe  printf -v qarg '%q ' "$arg" -- then there is always one\r
310 > trailing ws (and spaces are always prefixed w/ \ -- (insert "foo\ bar")\r
311 > just makes the ' ' disappear (which is not good...).\r
312 >\r
313 > maybe arg=3D${arg//\\/\\\\}; arg=3D${arg//"/\\"};=20\r
314 >\r
315 > ${parameter/pattern/string} -- Pattern substition in bash manual.\r
316 \r
317 I'm inclined to go with "don't do that then" ;)\r
318 \r
319 >\r
320 >\r
321 >> +# End progn.\r
322 >> +ELISP=3D"${ELISP})"\r
323 >> +\r
324 >> +if [ -n "$PRINT_ONLY" ]; then\r
325 >> +    echo ${ELISP}\r
326 >> +    exit 0\r
327 >> +fi\r
328 >> +\r
329 >> +# Evaluate the progn.\r
330 >> +emacsclient --eval "${ELISP}" &>/dev/null\r
331 >\r
332 > emacsclient --eval "${ELISP}" >/dev/null 2>&1\r
333 >\r
334 > (why do you want to redirect stdout & stderr to devnull ?)\r
335 \r
336 Okay, maybe it could be just stdout (which will be the eval result, in\r
337 this case nil).\r
338 \r
339 >\r
340 >> +if [ $? -ne 0 ]; then\r
341 >> +    echo "$0: emacsclient failed" >&2\r
342 >> +    exit 1\r
343 >> +fi\r
344 >> --=20\r
345 >> 1.9.0\r