Re: Hi all
[notmuch-archives.git] / 3d / 861e52a3a0b5c745d7ba1bf35eb1fe36681697
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
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 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
21  (PDT)\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
34         vIzg==\r
35 X-Gm-Message-State:\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
40         [88.195.111.91])\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
54 MIME-Version: 1.0\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
59 Precedence: list\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
70 \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
73 ---\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
79 \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
83 --- /dev/null\r
84 +++ b/doc/man1/notmuch-emacs-mua.rst\r
85 @@ -0,0 +1,50 @@\r
86 +=================\r
87 +notmuch-emacs-mua\r
88 +=================\r
89 +\r
90 +SYNOPSIS\r
91 +========\r
92 +\r
93 +**notmuch-emacs-mua** [options ...] [<to-address> ...]\r
94 +\r
95 +DESCRIPTION\r
96 +===========\r
97 +\r
98 +Start composing an email in the Notmuch Emacs UI with the specified\r
99 +subject, recipients, and message body.\r
100 +\r
101 +For **notmuch-emacs-mua** to work, you need **emacsclient** and an\r
102 +already running Emacs with a server.\r
103 +\r
104 +Supported options for **notmuch-emacs-mua** include\r
105 +\r
106 +    ``-h, --help``\r
107 +        Display help.\r
108 +\r
109 +    ``-s, --subject=``\ <subject>\r
110 +        Specify the subject of the message.\r
111 +\r
112 +    ``--to=``\ <to-address>\r
113 +        Specify a recipient (To).\r
114 +\r
115 +    ``-c, --cc=``\ <cc-address>\r
116 +        Specify a carbon-copy (Cc) recipient.\r
117 +\r
118 +    ``-b, --bcc=``\ <bcc-address>\r
119 +        Specify a blind-carbon-copy (Bcc) recipient.\r
120 +\r
121 +    ``-i, --body=``\ <file>\r
122 +        Specify a file to include into the body of the message.\r
123 +\r
124 +    ``--print``\r
125 +        Output the resulting elisp to stdout instead of evaluating it.\r
126 +\r
127 +The supported positional parameters and short options are a compatible\r
128 +subset of the **mutt** MUA command-line options.\r
129 +\r
130 +Options may be specified multiple times.\r
131 +\r
132 +SEE ALSO\r
133 +========\r
134 +\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
139 --- /dev/null\r
140 +++ b/notmuch-emacs-mua\r
141 @@ -0,0 +1,122 @@\r
142 +#!/usr/bin/env bash\r
143 +#\r
144 +# notmuch-emacs-mua - start composing a mail on the command line\r
145 +#\r
146 +# Copyright © 2014 Jani Nikula\r
147 +#\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
152 +#\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
157 +#\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
160 +#\r
161 +# Authors: Jani Nikula <jani@nikula.org>\r
162 +#\r
163 +\r
164 +set -eu\r
165 +\r
166 +escape ()\r
167 +{\r
168 +    echo "${1//\"/\\\"}"\r
169 +}\r
170 +\r
171 +PRINT_ONLY=\r
172 +\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
175 +\r
176 +while getopts :s:c:b:i:h opt; do\r
177 +    # Handle errors and long options.\r
178 +    case "${opt}" in\r
179 +       :)\r
180 +           echo "$0: short option -${OPTARG} requires an argument." >&2\r
181 +           exit 1\r
182 +           ;;\r
183 +       \?)\r
184 +           opt=$1\r
185 +           if [ "${OPTARG}" != "-" ]; then\r
186 +               echo "$0: unknown short option -${OPTARG}." >&2\r
187 +               exit 1\r
188 +           fi\r
189 +\r
190 +           case "${opt}" in\r
191 +               # Long options with arguments.\r
192 +               --subject=*|--to=*|--cc=*|--bcc=*|--body=*)\r
193 +                   OPTARG=${opt#--*=}\r
194 +                   opt=${opt%%=*}\r
195 +                   ;;\r
196 +               # Long options without arguments.\r
197 +               --help|--print)\r
198 +                   ;;\r
199 +               *)\r
200 +                   echo "$0: unknown long option ${opt}, or argument mismatch." >&2\r
201 +                   exit 1\r
202 +                   ;;\r
203 +           esac\r
204 +           # getopts does not do this for what it considers errors.\r
205 +           OPTIND=$((OPTIND + 1))\r
206 +           ;;\r
207 +    esac\r
208 +\r
209 +    OPTARG="$(escape "${OPTARG}")"\r
210 +\r
211 +    case "${opt}" in\r
212 +       --help|h)\r
213 +           exec man notmuch-emacs-mua\r
214 +           ;;\r
215 +       --subject|s)\r
216 +           ELISP="${ELISP} (message-goto-subject) (insert \"${OPTARG}\")"\r
217 +           ;;\r
218 +       --to)\r
219 +           ELISP="${ELISP} (message-goto-to) (insert \"${OPTARG}, \")"\r
220 +           ;;\r
221 +       --cc|c)\r
222 +           ELISP="${ELISP} (message-goto-cc) (insert \"${OPTARG}, \")"\r
223 +           ;;\r
224 +       --bcc|b)\r
225 +           ELISP="${ELISP} (message-goto-bcc) (insert \"${OPTARG}, \")"\r
226 +           ;;\r
227 +       --body|i)\r
228 +           ELISP="${ELISP} (message-goto-body) (cd \"${PWD}\") (insert-file \"${OPTARG}\")"\r
229 +           ;;\r
230 +       --print)\r
231 +           PRINT_ONLY=1\r
232 +           ;;\r
233 +       *)\r
234 +           # We should never end up here.\r
235 +           echo "$0: internal error (option ${opt})." >&2\r
236 +           exit 1\r
237 +           ;;\r
238 +    esac\r
239 +\r
240 +    shift $((OPTIND - 1))\r
241 +    OPTIND=1\r
242 +done\r
243 +\r
244 +# Positional parameters.\r
245 +for arg; do\r
246 +    arg="$(escape "${arg}")"\r
247 +    ELISP="${ELISP} (message-goto-to) (insert \"${arg}, \")"\r
248 +done\r
249 +\r
250 +# End progn.\r
251 +ELISP="${ELISP})"\r
252 +\r
253 +if [ -n "$PRINT_ONLY" ]; then\r
254 +    echo ${ELISP}\r
255 +    exit 0\r
256 +fi\r
257 +\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
262 +    exit 1\r
263 +fi\r
264 -- \r
265 1.9.1\r
266 \r