1 Return-Path: <bremner@tesseract.cs.unb.ca>
\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 57963431FD5
\r
6 for <notmuch@notmuchmail.org>; Sun, 22 Feb 2015 12:45:59 -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 KI4agDOOaDXw for <notmuch@notmuchmail.org>;
\r
16 Sun, 22 Feb 2015 12:45:56 -0800 (PST)
\r
17 Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net
\r
19 (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 0D7D4431FD4
\r
22 for <notmuch@notmuchmail.org>; Sun, 22 Feb 2015 12:45:56 -0800 (PST)
\r
23 Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim
\r
24 4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)
\r
25 id 1YPdEy-0005zp-Ji; Sun, 22 Feb 2015 20:35:00 +0000
\r
26 Received: (nullmailer pid 611 invoked by uid 1000); Sun, 22 Feb 2015 20:34:47
\r
28 From: David Bremner <david@tethera.net>
\r
29 To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
\r
30 Subject: [PATCH] cli: add a tool for starting new message in the emacs ui
\r
31 Date: Sun, 22 Feb 2015 21:34:44 +0100
\r
32 Message-Id: <1424637284-567-1-git-send-email-david@tethera.net>
\r
33 X-Mailer: git-send-email 2.1.4
\r
34 In-Reply-To: <1421598115-4889-1-git-send-email-david@tethera.net>
\r
35 References: <1421598115-4889-1-git-send-email-david@tethera.net>
\r
37 Content-Type: text/plain; charset=UTF-8
\r
38 Content-Transfer-Encoding: 8bit
\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, 22 Feb 2015 20:45:59 -0000
\r
53 From: Jani Nikula <jani@nikula.org>
\r
55 Add a tool to start composing an email in the Notmuch Emacs UI with
\r
56 the specified subject, recipients, and message body.
\r
59 doc/man1/notmuch-emacs-mua.rst | 63 +++++++++++++++++++
\r
60 notmuch-emacs-mua | 136 +++++++++++++++++++++++++++++++++++++++++
\r
61 3 files changed, 203 insertions(+)
\r
62 create mode 100644 doc/man1/notmuch-emacs-mua.rst
\r
63 create mode 100755 notmuch-emacs-mua
\r
65 diff --git a/doc/conf.py b/doc/conf.py
\r
66 index fb49f6e..8fbc854 100644
\r
69 @@ -78,6 +78,10 @@ man_pages = [
\r
70 u'creates a plain-text dump of the tags of each message',
\r
71 [u'Carl Worth and many others'], 1),
\r
73 +('man1/notmuch-emacs-mua','notmuch-emacs-mua',
\r
74 + u'send mail with notmuch and emacs',
\r
75 + [u'Carl Worth and many others'], 1),
\r
77 ('man5/notmuch-hooks','notmuch-hooks',
\r
78 u'hooks for notmuch',
\r
79 [u'Carl Worth and many others'], 5),
\r
80 diff --git a/doc/man1/notmuch-emacs-mua.rst b/doc/man1/notmuch-emacs-mua.rst
\r
81 new file mode 100644
\r
82 index 0000000..eb47098
\r
84 +++ b/doc/man1/notmuch-emacs-mua.rst
\r
93 +**notmuch-emacs-mua** [options ...] [<to-address> ...]
\r
98 +Start composing an email in the Notmuch Emacs UI with the specified
\r
99 +subject, recipients, and message body.
\r
101 +Supported options for **notmuch-emacs-mua** include
\r
107 + Use emacsclient, rather than emacs. This will start
\r
108 + an emacs daemon process if necessary.
\r
110 + ``-s, --subject=``\ <subject>
\r
111 + Specify the subject of the message.
\r
113 + ``--to=``\ <to-address>
\r
114 + Specify a recipient (To).
\r
116 + ``-c, --cc=``\ <cc-address>
\r
117 + Specify a carbon-copy (Cc) recipient.
\r
119 + ``-b, --bcc=``\ <bcc-address>
\r
120 + Specify a blind-carbon-copy (Bcc) recipient.
\r
122 + ``-i, --body=``\ <file>
\r
123 + Specify a file to include into the body of the message.
\r
125 + ``--no-window-system``
\r
126 + Even if a window system is available, use the current terminal
\r
129 + Output the resulting elisp to stdout instead of evaluating it.
\r
131 +The supported positional parameters and short options are a compatible
\r
132 +subset of the **mutt** MUA command-line options.
\r
134 +Options may be specified multiple times.
\r
136 +ENVIRONMENT VARIABLES
\r
137 +=====================
\r
140 +Name of emacs command to invoke
\r
143 +Name of emacsclient comment to invoke
\r
148 +**notmuch(1)**, **emacsclient(1)**, **mutt(1)**
\r
149 diff --git a/notmuch-emacs-mua b/notmuch-emacs-mua
\r
150 new file mode 100755
\r
151 index 0000000..b8cbc82
\r
153 +++ b/notmuch-emacs-mua
\r
155 +#!/usr/bin/env bash
\r
157 +# notmuch-emacs-mua - start composing a mail on the command line
\r
159 +# Copyright © 2014 Jani Nikula
\r
161 +# This program is free software: you can redistribute it and/or modify
\r
162 +# it under the terms of the GNU General Public License as published by
\r
163 +# the Free Software Foundation, either version 3 of the License, or
\r
164 +# (at your option) any later version.
\r
166 +# This program is distributed in the hope that it will be useful,
\r
167 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
168 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
169 +# GNU General Public License for more details.
\r
171 +# You should have received a copy of the GNU General Public License
\r
172 +# along with this program. If not, see http://www.gnu.org/licenses/ .
\r
174 +# Authors: Jani Nikula <jani@nikula.org>
\r
181 + echo "${1//\"/\\\"}"
\r
184 +EMACS=${EMACS-emacs}
\r
185 +EMACSCLIENT=${EMACSCLIENT-emacsclient}
\r
191 +# The crux of it all: construct an elisp progn and eval it.
\r
192 +ELISP="(prog1 'done (require 'notmuch) (notmuch-mua-new-mail)"
\r
193 +ELISP="${ELISP} (setq message-exit-actions (list #'save-buffers-kill-terminal))"
\r
195 +while getopts :s:c:b:i:hC opt; do
\r
196 + # Handle errors and long options.
\r
199 + echo "$0: short option -${OPTARG} requires an argument." >&2
\r
204 + if [ "${OPTARG}" != "-" ]; then
\r
205 + echo "$0: unknown short option -${OPTARG}." >&2
\r
210 + # Long options with arguments.
\r
211 + --subject=*|--to=*|--cc=*|--bcc=*|--body=*)
\r
212 + OPTARG=${opt#--*=}
\r
215 + # Long options without arguments.
\r
216 + --help|--print|--no-window-system|--client)
\r
219 + echo "$0: unknown long option ${opt}, or argument mismatch." >&2
\r
223 + # getopts does not do this for what it considers errors.
\r
224 + OPTIND=$((OPTIND + 1))
\r
229 + OPTARG="${OPTARG-none}"
\r
230 + OPTARG="$(escape "${OPTARG}")"
\r
234 + exec man notmuch-emacs-mua
\r
237 + USE_EMACSCLIENT="yes"
\r
240 + ELISP="${ELISP} (message-goto-subject) (insert \"${OPTARG}\")"
\r
243 + ELISP="${ELISP} (message-goto-to) (insert \"${OPTARG}, \")"
\r
246 + ELISP="${ELISP} (message-goto-cc) (insert \"${OPTARG}, \")"
\r
249 + ELISP="${ELISP} (message-goto-bcc) (insert \"${OPTARG}, \")"
\r
252 + ELISP="${ELISP} (message-goto-body) (cd \"${PWD}\") (insert-file \"${OPTARG}\")"
\r
257 + --no-window-system)
\r
261 + # We should never end up here.
\r
262 + echo "$0: internal error (option ${opt})." >&2
\r
267 + shift $((OPTIND - 1))
\r
271 +# Positional parameters.
\r
273 + arg="$(escape "${arg}")"
\r
274 + ELISP="${ELISP} (message-goto-to) (insert \"${arg}, \")"
\r
280 +if [ -n "$PRINT_ONLY" ]; then
\r
285 +if [ -n "$USE_EMACSCLIENT" ]; then
\r
286 + # Evaluate the progn.
\r
287 + exec ${EMACSCLIENT} ${CLIENT_TYPE} -a '' --eval "${ELISP}"
\r
289 + exec ${EMACS} --eval "${ELISP}"
\r