Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / 4f / 1e6dfbbe949c3502b256753715caeffa34823b
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
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 2.438\r
10 X-Spam-Level: **\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
18         [87.98.215.224])\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
27         -0000\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
36 MIME-Version: 1.0\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
41 Precedence: list\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
52 \r
53 From: Jani Nikula <jani@nikula.org>\r
54 \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
57 ---\r
58  doc/conf.py                    |   4 ++\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
64 \r
65 diff --git a/doc/conf.py b/doc/conf.py\r
66 index fb49f6e..8fbc854 100644\r
67 --- a/doc/conf.py\r
68 +++ b/doc/conf.py\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
72  \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
76 +\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
83 --- /dev/null\r
84 +++ b/doc/man1/notmuch-emacs-mua.rst\r
85 @@ -0,0 +1,63 @@\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 +Supported options for **notmuch-emacs-mua** include\r
102 +\r
103 +    ``-h, --help``\r
104 +        Display help.\r
105 +\r
106 +    ``-C, --client``\r
107 +        Use emacsclient, rather than emacs. This will start\r
108 +        an emacs daemon process if necessary.\r
109 +\r
110 +    ``-s, --subject=``\ <subject>\r
111 +        Specify the subject of the message.\r
112 +\r
113 +    ``--to=``\ <to-address>\r
114 +        Specify a recipient (To).\r
115 +\r
116 +    ``-c, --cc=``\ <cc-address>\r
117 +        Specify a carbon-copy (Cc) recipient.\r
118 +\r
119 +    ``-b, --bcc=``\ <bcc-address>\r
120 +        Specify a blind-carbon-copy (Bcc) recipient.\r
121 +\r
122 +    ``-i, --body=``\ <file>\r
123 +        Specify a file to include into the body of the message.\r
124 +\r
125 +    ``--no-window-system``\r
126 +        Even if a window system is available, use the current terminal\r
127 +\r
128 +    ``--print``\r
129 +        Output the resulting elisp to stdout instead of evaluating it.\r
130 +\r
131 +The supported positional parameters and short options are a compatible\r
132 +subset of the **mutt** MUA command-line options.\r
133 +\r
134 +Options may be specified multiple times.\r
135 +\r
136 +ENVIRONMENT VARIABLES\r
137 +=====================\r
138 +\r
139 +``EMACS``\r
140 +Name of emacs command to invoke\r
141 +\r
142 +``EMACSCLIENT``\r
143 +Name of emacsclient comment to invoke\r
144 +\r
145 +SEE ALSO\r
146 +========\r
147 +\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
152 --- /dev/null\r
153 +++ b/notmuch-emacs-mua\r
154 @@ -0,0 +1,136 @@\r
155 +#!/usr/bin/env bash\r
156 +#\r
157 +# notmuch-emacs-mua - start composing a mail on the command line\r
158 +#\r
159 +# Copyright © 2014 Jani Nikula\r
160 +#\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
165 +#\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
170 +#\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
173 +#\r
174 +# Authors: Jani Nikula <jani@nikula.org>\r
175 +#\r
176 +\r
177 +set -eu\r
178 +\r
179 +escape ()\r
180 +{\r
181 +    echo "${1//\"/\\\"}"\r
182 +}\r
183 +\r
184 +EMACS=${EMACS-emacs}\r
185 +EMACSCLIENT=${EMACSCLIENT-emacsclient}\r
186 +\r
187 +PRINT_ONLY=\r
188 +USE_EMACSCLIENT=\r
189 +CLIENT_TYPE="-c"\r
190 +\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
194 +\r
195 +while getopts :s:c:b:i:hC opt; do\r
196 +    # Handle errors and long options.\r
197 +    case "${opt}" in\r
198 +       :)\r
199 +           echo "$0: short option -${OPTARG} requires an argument." >&2\r
200 +           exit 1\r
201 +           ;;\r
202 +       \?)\r
203 +           opt=$1\r
204 +           if [ "${OPTARG}" != "-" ]; then\r
205 +               echo "$0: unknown short option -${OPTARG}." >&2\r
206 +               exit 1\r
207 +           fi\r
208 +\r
209 +           case "${opt}" in\r
210 +               # Long options with arguments.\r
211 +               --subject=*|--to=*|--cc=*|--bcc=*|--body=*)\r
212 +                   OPTARG=${opt#--*=}\r
213 +                   opt=${opt%%=*}\r
214 +                   ;;\r
215 +               # Long options without arguments.\r
216 +               --help|--print|--no-window-system|--client)\r
217 +                   ;;\r
218 +               *)\r
219 +                   echo "$0: unknown long option ${opt}, or argument mismatch." >&2\r
220 +                   exit 1\r
221 +                   ;;\r
222 +           esac\r
223 +           # getopts does not do this for what it considers errors.\r
224 +           OPTIND=$((OPTIND + 1))\r
225 +           ;;\r
226 +    esac\r
227 +\r
228 +\r
229 +    OPTARG="${OPTARG-none}"\r
230 +    OPTARG="$(escape "${OPTARG}")"\r
231 +\r
232 +    case "${opt}" in\r
233 +       --help|h)\r
234 +           exec man notmuch-emacs-mua\r
235 +           ;;\r
236 +       --client|C)\r
237 +           USE_EMACSCLIENT="yes"\r
238 +           ;;\r
239 +       --subject|s)\r
240 +           ELISP="${ELISP} (message-goto-subject) (insert \"${OPTARG}\")"\r
241 +           ;;\r
242 +       --to)\r
243 +           ELISP="${ELISP} (message-goto-to) (insert \"${OPTARG}, \")"\r
244 +           ;;\r
245 +       --cc|c)\r
246 +           ELISP="${ELISP} (message-goto-cc) (insert \"${OPTARG}, \")"\r
247 +           ;;\r
248 +       --bcc|b)\r
249 +           ELISP="${ELISP} (message-goto-bcc) (insert \"${OPTARG}, \")"\r
250 +           ;;\r
251 +       --body|i)\r
252 +           ELISP="${ELISP} (message-goto-body) (cd \"${PWD}\") (insert-file \"${OPTARG}\")"\r
253 +           ;;\r
254 +       --print)\r
255 +           PRINT_ONLY=1\r
256 +           ;;\r
257 +       --no-window-system)\r
258 +           CLIENT_TYPE="-t"\r
259 +           ;;\r
260 +       *)\r
261 +           # We should never end up here.\r
262 +           echo "$0: internal error (option ${opt})." >&2\r
263 +           exit 1\r
264 +           ;;\r
265 +    esac\r
266 +\r
267 +    shift $((OPTIND - 1))\r
268 +    OPTIND=1\r
269 +done\r
270 +\r
271 +# Positional parameters.\r
272 +for arg; do\r
273 +    arg="$(escape "${arg}")"\r
274 +    ELISP="${ELISP} (message-goto-to) (insert \"${arg}, \")"\r
275 +done\r
276 +\r
277 +# End progn.\r
278 +ELISP="${ELISP})"\r
279 +\r
280 +if [ -n "$PRINT_ONLY" ]; then\r
281 +    echo ${ELISP}\r
282 +    exit 0\r
283 +fi\r
284 +\r
285 +if [ -n "$USE_EMACSCLIENT" ]; then\r
286 +    # Evaluate the progn.\r
287 +    exec ${EMACSCLIENT} ${CLIENT_TYPE} -a '' --eval "${ELISP}"\r
288 +else\r
289 +    exec ${EMACS} --eval "${ELISP}"\r
290 +fi\r
291 -- \r
292 2.1.4\r
293 \r