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 22A64431FBC
\r
6 for <notmuch@notmuchmail.org>; Sun, 6 Apr 2014 08:43:35 -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 ghZITI3M2TF2 for <notmuch@notmuchmail.org>;
\r
16 Sun, 6 Apr 2014 08:43:31 -0700 (PDT)
\r
17 Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com
\r
18 [74.125.82.41]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client
\r
19 certificate requested) by olra.theworths.org (Postfix) with ESMTPS id
\r
20 8B0D4431FB6 for <notmuch@notmuchmail.org>; Sun, 6 Apr 2014 08:43:30 -0700
\r
22 Received: by mail-wg0-f41.google.com with SMTP id n12so5719162wgh.12
\r
23 for <notmuch@notmuchmail.org>; Sun, 06 Apr 2014 08:43:27 -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:cc:subject:date:message-id:in-reply-to
\r
27 :references:mime-version:content-type:content-transfer-encoding;
\r
28 bh=IwQWOpo9fN83PjMm6/YFzIZXmGz4YIkTyYwk7M+w+0w=;
\r
29 b=KbmXkiU5NfLmmcL8R52561MidoPnY9aCYawfoGlaiHYMv2T4BuiP6O/k/T9f8sHiVb
\r
30 SIzpvKm7DqhXLCxePKaG49CmqScegu4bMQ8fZz6bkKOJ2+umhp05qNy4IBRlFnCLZGsQ
\r
31 7ewIihefsk5l5dmJNYQLbzxh5YKLXGBmpK8oEVseITFnOO1DZ8QTaQDEhfi2YL3hml6s
\r
32 uBsVApQMdKR0YWaMepxm8bA1KF8/cuvBlMAREHAdWbhhA7b0/otFo/zZAspC2gYwDwad
\r
33 ao+WYi578/EyyarMwpHlBPSO5ruSEp/6qBKPoKqcbyfRHxeBw8KGGY+fJ1knutamgFB9
\r
36 ALoCoQnuFli7e0NHAT10WeA4XC3aYbNhEbFktWcNmF/8Gu4qF7e/N95HGVJCTnZ3PmB7Dbv1rSdp
\r
37 X-Received: by 10.180.78.200 with SMTP id d8mr19673019wix.34.1396799006544;
\r
38 Sun, 06 Apr 2014 08:43:26 -0700 (PDT)
\r
39 Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.
\r
41 by mx.google.com with ESMTPSA id m8sm35281700eeg.11.2014.04.06.08.43.24
\r
42 for <multiple recipients>
\r
43 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
\r
44 Sun, 06 Apr 2014 08:43:25 -0700 (PDT)
\r
45 From: Jani Nikula <jani@nikula.org>
\r
46 To: notmuch@notmuchmail.org,
\r
47 Tomi Ollila <tomi.ollila@iki.fi>
\r
48 Subject: [PATCH v2] cli: add a tool for starting new message in the emacs ui
\r
49 Date: Sun, 6 Apr 2014 18:43:23 +0300
\r
50 Message-Id: <1396799003-14855-1-git-send-email-jani@nikula.org>
\r
51 X-Mailer: git-send-email 1.9.1
\r
52 In-Reply-To: <m2bnx1duv7.fsf@guru.guru-group.fi>
\r
53 References: <m2bnx1duv7.fsf@guru.guru-group.fi>
\r
55 Content-Type: text/plain; charset=UTF-8
\r
56 Content-Transfer-Encoding: 8bit
\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: Sun, 06 Apr 2014 15:43:35 -0000
\r
71 Add a tool to start composing an email in the Notmuch Emacs UI with
\r
72 the specified subject, recipients, and message body.
\r
74 doc/man1/notmuch-emacs-mua.rst | 50 +++++++++++++++++
\r
75 notmuch-emacs-mua | 122 +++++++++++++++++++++++++++++++++++++++++
\r
76 2 files changed, 172 insertions(+)
\r
77 create mode 100644 doc/man1/notmuch-emacs-mua.rst
\r
78 create mode 100755 notmuch-emacs-mua
\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 000000000000..6e63818492fb
\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 +For **notmuch-emacs-mua** to work, you need **emacsclient** and an
\r
102 +already running Emacs with a server.
\r
104 +Supported options for **notmuch-emacs-mua** include
\r
109 + ``-s, --subject=``\ <subject>
\r
110 + Specify the subject of the message.
\r
112 + ``--to=``\ <to-address>
\r
113 + Specify a recipient (To).
\r
115 + ``-c, --cc=``\ <cc-address>
\r
116 + Specify a carbon-copy (Cc) recipient.
\r
118 + ``-b, --bcc=``\ <bcc-address>
\r
119 + Specify a blind-carbon-copy (Bcc) recipient.
\r
121 + ``-i, --body=``\ <file>
\r
122 + Specify a file to include into the body of the message.
\r
125 + Output the resulting elisp to stdout instead of evaluating it.
\r
127 +The supported positional parameters and short options are a compatible
\r
128 +subset of the **mutt** MUA command-line options.
\r
130 +Options may be specified multiple times.
\r
135 +**notmuch(1)**, **emacsclient(1)**, **mutt(1)**
\r
136 diff --git a/notmuch-emacs-mua b/notmuch-emacs-mua
\r
137 new file mode 100755
\r
138 index 000000000000..7f94271d8a44
\r
140 +++ b/notmuch-emacs-mua
\r
142 +#!/usr/bin/env bash
\r
144 +# notmuch-emacs-mua - start composing a mail on the command line
\r
146 +# Copyright © 2014 Jani Nikula
\r
148 +# This program is free software: you can redistribute it and/or modify
\r
149 +# it under the terms of the GNU General Public License as published by
\r
150 +# the Free Software Foundation, either version 3 of the License, or
\r
151 +# (at your option) any later version.
\r
153 +# This program is distributed in the hope that it will be useful,
\r
154 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
155 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
156 +# GNU General Public License for more details.
\r
158 +# You should have received a copy of the GNU General Public License
\r
159 +# along with this program. If not, see http://www.gnu.org/licenses/ .
\r
161 +# Authors: Jani Nikula <jani@nikula.org>
\r
168 + echo "${1//\"/\\\"}"
\r
173 +# The crux of it all: construct an elisp progn and eval it.
\r
174 +ELISP="(progn (require 'notmuch) (notmuch-mua-new-mail)"
\r
176 +while getopts :s:c:b:i:h opt; do
\r
177 + # Handle errors and long options.
\r
180 + echo "$0: short option -${OPTARG} requires an argument." >&2
\r
185 + if [ "${OPTARG}" != "-" ]; then
\r
186 + echo "$0: unknown short option -${OPTARG}." >&2
\r
191 + # Long options with arguments.
\r
192 + --subject=*|--to=*|--cc=*|--bcc=*|--body=*)
\r
193 + OPTARG=${opt#--*=}
\r
196 + # Long options without arguments.
\r
200 + echo "$0: unknown long option ${opt}, or argument mismatch." >&2
\r
204 + # getopts does not do this for what it considers errors.
\r
205 + OPTIND=$((OPTIND + 1))
\r
209 + OPTARG="$(escape "${OPTARG}")"
\r
213 + exec man notmuch-emacs-mua
\r
216 + ELISP="${ELISP} (message-goto-subject) (insert \"${OPTARG}\")"
\r
219 + ELISP="${ELISP} (message-goto-to) (insert \"${OPTARG}, \")"
\r
222 + ELISP="${ELISP} (message-goto-cc) (insert \"${OPTARG}, \")"
\r
225 + ELISP="${ELISP} (message-goto-bcc) (insert \"${OPTARG}, \")"
\r
228 + ELISP="${ELISP} (message-goto-body) (cd \"${PWD}\") (insert-file \"${OPTARG}\")"
\r
234 + # We should never end up here.
\r
235 + echo "$0: internal error (option ${opt})." >&2
\r
240 + shift $((OPTIND - 1))
\r
244 +# Positional parameters.
\r
246 + arg="$(escape "${arg}")"
\r
247 + ELISP="${ELISP} (message-goto-to) (insert \"${arg}, \")"
\r
253 +if [ -n "$PRINT_ONLY" ]; then
\r
258 +# Evaluate the progn.
\r
259 +emacsclient --eval "${ELISP}" >/dev/null
\r
260 +if [ $? -ne 0 ]; then
\r
261 + echo "$0: emacsclient failed" >&2
\r