1 Return-Path: <tomi.ollila@iki.fi>
\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 AD934431FAF
\r
6 for <notmuch@notmuchmail.org>; Sun, 18 Jan 2015 13:07:40 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=2.438 tagged_above=-999 required=5
\r
12 tests=[DNS_FROM_AHBL_RHSBL=2.438] 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 odb7M8y4-6VO for <notmuch@notmuchmail.org>;
\r
16 Sun, 18 Jan 2015 13:07:37 -0800 (PST)
\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])
\r
18 by olra.theworths.org (Postfix) with ESMTP id C17B0431FAE
\r
19 for <notmuch@notmuchmail.org>; Sun, 18 Jan 2015 13:07:36 -0800 (PST)
\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])
\r
21 by guru.guru-group.fi (Postfix) with ESMTP id D71771000E0;
\r
22 Sun, 18 Jan 2015 23:07:04 +0200 (EET)
\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
24 To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
\r
25 Subject: Re: [PATCH] cli: add a tool for starting new message in the emacs ui
\r
26 In-Reply-To: <1421598115-4889-1-git-send-email-david@tethera.net>
\r
27 References: <1404244957-3671-1-git-send-email-david@tethera.net>
\r
28 <1421598115-4889-1-git-send-email-david@tethera.net>
\r
29 User-Agent: Notmuch/0.19+29~g7367d27 (http://notmuchmail.org) Emacs/24.3.1
\r
30 (x86_64-unknown-linux-gnu)
\r
31 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL
\r
32 $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F
\r
33 !)g;OY^,BjTbr)Np:%c_o'jj,Z
\r
34 Date: Sun, 18 Jan 2015 23:07:04 +0200
\r
35 Message-ID: <m2h9vnssqv.fsf@guru.guru-group.fi>
\r
37 Content-Type: text/plain; charset=utf-8
\r
38 Content-Transfer-Encoding: quoted-printable
\r
39 X-BeenThere: notmuch@notmuchmail.org
\r
40 X-Mailman-Version: 2.1.13
\r
42 List-Id: "Use and development of the notmuch mail system."
\r
43 <notmuch.notmuchmail.org>
\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
47 List-Post: <mailto:notmuch@notmuchmail.org>
\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
51 X-List-Received-Date: Sun, 18 Jan 2015 21:07:40 -0000
\r
53 On Sun, Jan 18 2015, David Bremner <david@tethera.net> wrote:
\r
55 > From: Jani Nikula <jani@nikula.org>
\r
57 > Add a tool to start composing an email in the Notmuch Emacs UI with
\r
58 > the specified subject, recipients, and message body.
\r
61 > This version fixes my complaint about the previous version not
\r
62 > starting emacs. It does this by starting a new "frame", either at the
\r
63 > window system level, or in the current terminal. The traditional
\r
64 > "-nw" short form of the argument "--no-window-system" seems maybe more
\r
65 > work to parse than it's worth.
\r
67 Well, id:1405026779-29966-1-git-send-email-tomi.ollila@iki.fi (*) had -nw
\r
68 parsing, but I can live without...
\r
70 But more than that one important feature has to be agreed before initial
\r
71 interface is locked down -- how to provide body content from command line
\r
72 without resorting to temporary files. In (*) --body was adding those lines
\r
73 instead of reading file and I later suggested that --include or --insert
\r
74 could do the same as -i ... but I am open to any solution that gives me
\r
75 opportunity to provide body *content* from command line.
\r
80 > doc/conf.py | 4 ++
\r
81 > doc/man1/notmuch-emacs-mua.rst | 53 ++++++++++++++++++
\r
82 > notmuch-emacs-mua | 122 +++++++++++++++++++++++++++++++++++=
\r
84 > 3 files changed, 179 insertions(+)
\r
85 > create mode 100644 doc/man1/notmuch-emacs-mua.rst
\r
86 > create mode 100755 notmuch-emacs-mua
\r
88 > diff --git a/doc/conf.py b/doc/conf.py
\r
89 > index fb49f6e..8fbc854 100644
\r
92 > @@ -78,6 +78,10 @@ man_pages =3D [
\r
93 > u'creates a plain-text dump of the tags of each message',
\r
94 > [u'Carl Worth and many others'], 1),
\r
96 > +('man1/notmuch-emacs-mua','notmuch-emacs-mua',
\r
97 > + u'send mail with notmuch and emacs',
\r
98 > + [u'Carl Worth and many others'], 1),
\r
100 > ('man5/notmuch-hooks','notmuch-hooks',
\r
101 > u'hooks for notmuch',
\r
102 > [u'Carl Worth and many others'], 5),
\r
103 > diff --git a/doc/man1/notmuch-emacs-mua.rst b/doc/man1/notmuch-emacs-mua.=
\r
105 > new file mode 100644
\r
106 > index 0000000..bf8c3aa
\r
108 > +++ b/doc/man1/notmuch-emacs-mua.rst
\r
110 > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
\r
111 > +notmuch-emacs-mua
\r
112 > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
\r
115 > +=3D=3D=3D=3D=3D=3D=3D=3D
\r
117 > +**notmuch-emacs-mua** [options ...] [<to-address> ...]
\r
120 > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
\r
122 > +Start composing an email in the Notmuch Emacs UI with the specified
\r
123 > +subject, recipients, and message body.
\r
125 > +For **notmuch-emacs-mua** to work, you need **emacsclient** and an
\r
126 > +already running Emacs with a server.
\r
128 > +Supported options for **notmuch-emacs-mua** include
\r
133 > + ``-s, --subject=3D``\ <subject>
\r
134 > + Specify the subject of the message.
\r
136 > + ``--to=3D``\ <to-address>
\r
137 > + Specify a recipient (To).
\r
139 > + ``-c, --cc=3D``\ <cc-address>
\r
140 > + Specify a carbon-copy (Cc) recipient.
\r
142 > + ``-b, --bcc=3D``\ <bcc-address>
\r
143 > + Specify a blind-carbon-copy (Bcc) recipient.
\r
145 > + ``-i, --body=3D``\ <file>
\r
146 > + Specify a file to include into the body of the message.
\r
148 > + ``--no-window-system``
\r
149 > + Even if a window system is available, use the current terminal
\r
152 > + Output the resulting elisp to stdout instead of evaluating it.
\r
154 > +The supported positional parameters and short options are a compatible
\r
155 > +subset of the **mutt** MUA command-line options.
\r
157 > +Options may be specified multiple times.
\r
160 > +=3D=3D=3D=3D=3D=3D=3D=3D
\r
162 > +**notmuch(1)**, **emacsclient(1)**, **mutt(1)**
\r
163 > diff --git a/notmuch-emacs-mua b/notmuch-emacs-mua
\r
164 > new file mode 100755
\r
165 > index 0000000..fdf4024
\r
167 > +++ b/notmuch-emacs-mua
\r
168 > @@ -0,0 +1,122 @@
\r
169 > +#!/usr/bin/env bash
\r
171 > +# notmuch-emacs-mua - start composing a mail on the command line
\r
173 > +# Copyright =C2=A9 2014 Jani Nikula
\r
175 > +# This program is free software: you can redistribute it and/or modify
\r
176 > +# it under the terms of the GNU General Public License as published by
\r
177 > +# the Free Software Foundation, either version 3 of the License, or
\r
178 > +# (at your option) any later version.
\r
180 > +# This program is distributed in the hope that it will be useful,
\r
181 > +# but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
182 > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
183 > +# GNU General Public License for more details.
\r
185 > +# You should have received a copy of the GNU General Public License
\r
186 > +# along with this program. If not, see http://www.gnu.org/licenses/ .
\r
188 > +# Authors: Jani Nikula <jani@nikula.org>
\r
195 > + echo "${1//\"/\\\"}"
\r
199 > +CLIENT_TYPE=3D"-c"
\r
201 > +# The crux of it all: construct an elisp progn and eval it.
\r
202 > +ELISP=3D"(prog1 'done (require 'notmuch) (notmuch-mua-new-mail)"
\r
204 > +while getopts :s:c:b:i:h opt; do
\r
205 > + # Handle errors and long options.
\r
206 > + case "${opt}" in
\r
208 > + echo "$0: short option -${OPTARG} requires an argument." >&2
\r
213 > + if [ "${OPTARG}" !=3D "-" ]; then
\r
214 > + echo "$0: unknown short option -${OPTARG}." >&2
\r
218 > + case "${opt}" in
\r
219 > + # Long options with arguments.
\r
220 > + --subject=3D*|--to=3D*|--cc=3D*|--bcc=3D*|--body=3D*)
\r
221 > + OPTARG=3D${opt#--*=3D}
\r
222 > + opt=3D${opt%%=3D*}
\r
224 > + # Long options without arguments.
\r
225 > + --help|--print|--no-window-system)
\r
228 > + echo "$0: unknown long option ${opt}, or argument mismatch." >&2
\r
232 > + # getopts does not do this for what it considers errors.
\r
233 > + OPTIND=3D$((OPTIND + 1))
\r
237 > + OPTARG=3D"$(escape "${OPTARG}")"
\r
239 > + case "${opt}" in
\r
241 > + exec man notmuch-emacs-mua
\r
244 > + ELISP=3D"${ELISP} (message-goto-subject) (insert \"${OPTARG}\")"
\r
247 > + ELISP=3D"${ELISP} (message-goto-to) (insert \"${OPTARG}, \")"
\r
250 > + ELISP=3D"${ELISP} (message-goto-cc) (insert \"${OPTARG}, \")"
\r
253 > + ELISP=3D"${ELISP} (message-goto-bcc) (insert \"${OPTARG}, \")"
\r
256 > + ELISP=3D"${ELISP} (message-goto-body) (cd \"${PWD}\") (insert-file =
\r
262 > + --no-window-system)
\r
263 > + CLIENT_TYPE=3D"-t"
\r
266 > + # We should never end up here.
\r
267 > + echo "$0: internal error (option ${opt})." >&2
\r
272 > + shift $((OPTIND - 1))
\r
276 > +# Positional parameters.
\r
278 > + arg=3D"$(escape "${arg}")"
\r
279 > + ELISP=3D"${ELISP} (message-goto-to) (insert \"${arg}, \")"
\r
283 > +ELISP=3D"${ELISP})"
\r
285 > +if [ -n "$PRINT_ONLY" ]; then
\r
290 > +# Evaluate the progn.
\r
291 > +exec emacsclient ${CLIENT_TYPE} -a '' --eval "${ELISP}"
\r