[PATCH] build/ruby: use notmuch configure script values for shared lib
[notmuch-archives.git] / 33 / c36cef125b82a9da392a128f64d0de0dad88a3
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 C72B3431FBC\r
6         for <notmuch@notmuchmail.org>; Sat,  7 Mar 2015 06:12:29 -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: 1.738\r
10 X-Spam-Level: *\r
11 X-Spam-Status: No, score=1.738 tagged_above=-999 required=5\r
12         tests=[DNS_FROM_AHBL_RHSBL=2.438, RCVD_IN_DNSWL_LOW=-0.7]\r
13         autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id t01Kiu5cE2LQ for <notmuch@notmuchmail.org>;\r
17         Sat,  7 Mar 2015 06:12:26 -0800 (PST)\r
18 Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com\r
19         [209.85.212.182]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id F2EE8431FAE\r
22         for <notmuch@notmuchmail.org>; Sat,  7 Mar 2015 06:12:25 -0800 (PST)\r
23 Received: by wibbs8 with SMTP id bs8so9778792wib.4\r
24         for <notmuch@notmuchmail.org>; Sat, 07 Mar 2015 06:12:24 -0800 (PST)\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
26         d=1e100.net; s=20130820;\r
27         h=x-gm-message-state:from:to:cc:subject:in-reply-to:references\r
28         :user-agent:date:message-id:mime-version:content-type;\r
29         bh=j+4em1Oc67LC6dexZRDuRa1iUu3w02KiwUKB6BeWscY=;\r
30         b=dzRNLvAxB4lRH5weZAr7zeOTHjE7hdC4FgeU/iG0L3XwrkGeTVxwWDRX+8QnYcoAUg\r
31         SRt0CtKp/krulIUTfHAExCaE8pcM6Eu62MOJYIQX6gEvDjMZbIk9Tz1vTKT40c0d9lGa\r
32         bvAcEzm7jat+AfuPVWXu+LRoR3OPYH/iJwm4WNt7qrgd0h+V/vdYDWH5I77ITVNcCHII\r
33         ZnUSIniI9MpkUP9Wjkpu55Amad9C7PQtwbjdDAcQGvep/V8rH0/m5HvnFvdNxvTQWml+\r
34         MyNL4hl9/drrbkZJAY4jR7EkLyicni1v2ALRScS0rgH1j7+YEgg2RdD/UjdmSp01jxXT\r
35         JybQ==\r
36 X-Gm-Message-State:\r
37  ALoCoQlHLLGFFvf7YVm6VlHRUJ+ibBJecsvOO1hyc6izqXvwLgaCAP5Eigd7kk/VY8KeYfrbWThN\r
38 X-Received: by 10.194.78.231 with SMTP id e7mr39089690wjx.33.1425737544834;\r
39         Sat, 07 Mar 2015 06:12:24 -0800 (PST)\r
40 Received: from localhost (mobile-internet-bcee3b-76.dhcp.inet.fi.\r
41         [188.238.59.76])\r
42         by mx.google.com with ESMTPSA id nb18sm6844502wic.3.2015.03.07.06.12.23\r
43         (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
44         Sat, 07 Mar 2015 06:12:24 -0800 (PST)\r
45 From: Jani Nikula <jani@nikula.org>\r
46 To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org\r
47 Subject: Re: [PATCH] notmuch-emacs-mua: more options, some fixes\r
48 In-Reply-To: <1425724605-392-1-git-send-email-tomi.ollila@iki.fi>\r
49 References: <1425724605-392-1-git-send-email-tomi.ollila@iki.fi>\r
50 User-Agent: Notmuch/0.19+74~g6aeef2e (http://notmuchmail.org) Emacs/24.4.1\r
51         (x86_64-pc-linux-gnu)\r
52 Date: Sat, 07 Mar 2015 16:12:43 +0200\r
53 Message-ID: <87pp8kj3qc.fsf@nikula.org>\r
54 MIME-Version: 1.0\r
55 Content-Type: text/plain\r
56 Cc: tomi.ollila@iki.fi\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: Sat, 07 Mar 2015 14:12:29 -0000\r
70 \r
71 On Sat, 07 Mar 2015, Tomi Ollila <tomi.ollila@iki.fi> wrote:\r
72 > Two new options added:\r
73 >    --from: specify alternate From: header\r
74 >    --bodytext: possibility to give body content from command line\r
75 >\r
76 > Non-forking escape() functionality, also escaping \ (backslash) characters.\r
77 >\r
78 > Without content arguments start emacs/emacsclient and run (notmuch-hello),\r
79 > in this case without assigning anything to message-exit-actions.\r
80 >\r
81 > Point is now positioned at the end of the content given last on command\r
82 > line, unless to: or subject: is missing -- in which case point is\r
83 > positioned at one of these headers (is both missing, at to:)\r
84 >\r
85 > The -nw option is now given to emacs in case --no-window-system command\r
86 > line option is provided (--no-window-system used to work with emacsclient\r
87 > only).\r
88 >\r
89 > In case EMACS or EMACSCLIENT environment variable was defined but being\r
90 > empty (null string), use emacs/emacsclient as command instead (null string\r
91 > as executable name gives confusing error message). Also $EMACS/$EMACSCLIENT\r
92 > executable name is now quoted to *NOT* split it to separate command line\r
93 > arguments on any $IFS variables there might be.\r
94 >\r
95 > Reorganized content argument handling to combine the content of same option\r
96 > given multiple times and make it look more readable when --print option is\r
97 > used. --body option also now checks the existence of the file to be\r
98 > included and if the file included does not end with newline trailing\r
99 > newline is inserted to the message buffer.\r
100 >\r
101 > As bash supports [[ ]] command and it's special expansion (or lack thereof)\r
102 > of variables (and ==, && and || inside) the few [ ]'s there were are now\r
103 > changed to this more advanced format.\r
104 \r
105 As I mentioned on IRC, I think there are too many changes here for one\r
106 patch. One change at a time! In particular because I'm not sure if all\r
107 of this is really needed... like message_goto and point placement\r
108 handling. Starts to feel like all of this would be better handled with a\r
109 dedicated function in emacs!\r
110 \r
111 BR,\r
112 Jani.\r
113 \r
114 > ---\r
115 >\r
116 > The changes *NOT* taken from my 2 draft patches (*)\r
117 >\r
118 > 1) no -nw hacking\r
119 >\r
120 > 2) no mailto: handling\r
121 >\r
122 > (*) id:1421776424-24304-1-git-send-email-tomi.ollila@iki.fi (later, linking\r
123 > previous)\r
124 >\r
125 >\r
126 >  doc/man1/notmuch-emacs-mua.rst |   8 ++-\r
127 >  notmuch-emacs-mua              | 123 ++++++++++++++++++++++++++++++-----------\r
128 >  2 files changed, 99 insertions(+), 32 deletions(-)\r
129 >\r
130 > diff --git a/doc/man1/notmuch-emacs-mua.rst b/doc/man1/notmuch-emacs-mua.rst\r
131 > index eb47098..29f7e0c 100644\r
132 > --- a/doc/man1/notmuch-emacs-mua.rst\r
133 > +++ b/doc/man1/notmuch-emacs-mua.rst\r
134 > @@ -22,6 +22,9 @@ Supported options for **notmuch-emacs-mua** include\r
135 >          Use emacsclient, rather than emacs. This will start\r
136 >          an emacs daemon process if necessary.\r
137 >  \r
138 > +    ``--from=``\ <from>\r
139 > +        Specify alternate sender (From) of the message.\r
140 > +\r
141 >      ``-s, --subject=``\ <subject>\r
142 >          Specify the subject of the message.\r
143 >  \r
144 > @@ -37,6 +40,9 @@ Supported options for **notmuch-emacs-mua** include\r
145 >      ``-i, --body=``\ <file>\r
146 >          Specify a file to include into the body of the message.\r
147 >  \r
148 > +    ``--bodytext=``\ <text>\r
149 > +        Specify text content to be inserted into the body of the message.\r
150 > +\r
151 >      ``--no-window-system``\r
152 >          Even if a window system is available, use the current terminal\r
153 >  \r
154 > @@ -60,4 +66,4 @@ Name of emacsclient comment to invoke\r
155 >  SEE ALSO\r
156 >  ========\r
157 >  \r
158 > -**notmuch(1)**, **emacsclient(1)**, **mutt(1)**\r
159 > +**notmuch(1)**, **emacs(1)**, **emacsclient(1)**, **mutt(1)**\r
160 > diff --git a/notmuch-emacs-mua b/notmuch-emacs-mua\r
161 > index b8cbc82..17365b9 100755\r
162 > --- a/notmuch-emacs-mua\r
163 > +++ b/notmuch-emacs-mua\r
164 > @@ -1,4 +1,5 @@\r
165 >  #!/usr/bin/env bash\r
166 > +# -*- mode: shell-script; sh-basic-offset: 4; tab-width: 8 -*-\r
167 >  #\r
168 >  # notmuch-emacs-mua - start composing a mail on the command line\r
169 >  #\r
170 > @@ -18,25 +19,47 @@\r
171 >  # along with this program.  If not, see http://www.gnu.org/licenses/ .\r
172 >  #\r
173 >  # Authors: Jani Nikula <jani@nikula.org>\r
174 > +#          Tomi Ollila <tomi.ollila@iki.fi>\r
175 >  #\r
176 >  \r
177 >  set -eu\r
178 >  \r
179 > +# escape: "expand" '\' to '\\' & '"' to '\"'\r
180 > +# Calling convention: escape -v var "$arg" (like in bash printf).\r
181 >  escape ()\r
182 >  {\r
183 > -    echo "${1//\"/\\\"}"\r
184 > +    local arg=${3//\\/\\\\}\r
185 > +    eval $2='${arg//\"/\\\"}'\r
186 >  }\r
187 >  \r
188 > -EMACS=${EMACS-emacs}\r
189 > -EMACSCLIENT=${EMACSCLIENT-emacsclient}\r
190 > +EMACS=${EMACS:-emacs}\r
191 > +EMACSCLIENT=${EMACSCLIENT:-emacsclient}\r
192 >  \r
193 >  PRINT_ONLY=\r
194 >  USE_EMACSCLIENT=\r
195 > -CLIENT_TYPE="-c"\r
196 > +EMACSCLIENT_TYPE='-c'\r
197 > +EMACS_NW=\r
198 >  \r
199 > -# The crux of it all: construct an elisp progn and eval it.\r
200 > -ELISP="(prog1 'done (require 'notmuch) (notmuch-mua-new-mail)"\r
201 > -ELISP="${ELISP} (setq message-exit-actions (list #'save-buffers-kill-terminal))"\r
202 > +exec_mua ()\r
203 > +{\r
204 > +    if [[ -n $PRINT_ONLY ]]; then\r
205 > +     echo "$1"\r
206 > +     exit\r
207 > +    fi\r
208 > +\r
209 > +    if [[ -n $USE_EMACSCLIENT ]]; then\r
210 > +     # Evaluate the progn.\r
211 > +     exec "${EMACSCLIENT}" ${EMACSCLIENT_TYPE} -a '' --eval "$1"\r
212 > +    else\r
213 > +     exec "${EMACS}" ${EMACS_NW} --eval "$1"\r
214 > +    fi\r
215 > +    exit not reached\r
216 > +}\r
217 > +\r
218 > +SUBJECT= TO= CC= BCC= BODY= FROM=\r
219 > +\r
220 > +unset message_goto # Final elisp function to execute, when defined.\r
221 > +cddone=false\r
222 >  \r
223 >  while getopts :s:c:b:i:hC opt; do\r
224 >      # Handle errors and long options.\r
225 > @@ -47,14 +70,14 @@ while getopts :s:c:b:i:hC opt; do\r
226 >           ;;\r
227 >       \?)\r
228 >           opt=$1\r
229 > -         if [ "${OPTARG}" != "-" ]; then\r
230 > +         if [[ ${OPTARG} != '-' ]]; then\r
231 >               echo "$0: unknown short option -${OPTARG}." >&2\r
232 >               exit 1\r
233 >           fi\r
234 >  \r
235 >           case "${opt}" in\r
236 >               # Long options with arguments.\r
237 > -             --subject=*|--to=*|--cc=*|--bcc=*|--body=*)\r
238 > +             --subject=*|--to=*|--cc=*|--bcc=*|--body=*|--from=*|--bodytext=*)\r
239 >                   OPTARG=${opt#--*=}\r
240 >                   opt=${opt%%=*}\r
241 >                   ;;\r
242 > @@ -71,9 +94,7 @@ while getopts :s:c:b:i:hC opt; do\r
243 >           ;;\r
244 >      esac\r
245 >  \r
246 > -\r
247 > -    OPTARG="${OPTARG-none}"\r
248 > -    OPTARG="$(escape "${OPTARG}")"\r
249 > +    escape -v OPTARG "${OPTARG-}"\r
250 >  \r
251 >      case "${opt}" in\r
252 >       --help|h)\r
253 > @@ -82,26 +103,48 @@ while getopts :s:c:b:i:hC opt; do\r
254 >       --client|C)\r
255 >           USE_EMACSCLIENT="yes"\r
256 >           ;;\r
257 > +     --from)\r
258 > +         FROM=${OPTARG}\r
259 > +         ;;\r
260 >       --subject|s)\r
261 > -         ELISP="${ELISP} (message-goto-subject) (insert \"${OPTARG}\")"\r
262 > +         SUBJECT=${SUBJECT:+$SUBJECT }${OPTARG}\r
263 > +         message_goto='(message-goto-subject)'\r
264 >           ;;\r
265 >       --to)\r
266 > -         ELISP="${ELISP} (message-goto-to) (insert \"${OPTARG}, \")"\r
267 > +         TO=${TO:+$TO, }${OPTARG}\r
268 > +         message_goto='(message-goto-to)'\r
269 >           ;;\r
270 >       --cc|c)\r
271 > -         ELISP="${ELISP} (message-goto-cc) (insert \"${OPTARG}, \")"\r
272 > +         CC=${CC:+$CC, }${OPTARG}\r
273 > +         message_goto='(message-goto-cc)'\r
274 >           ;;\r
275 >       --bcc|b)\r
276 > -         ELISP="${ELISP} (message-goto-bcc) (insert \"${OPTARG}, \")"\r
277 > +         BCC=${BCC:+$BCC, }${OPTARG}\r
278 > +         message_goto='(message-goto-bcc)'\r
279 >           ;;\r
280 >       --body|i)\r
281 > -         ELISP="${ELISP} (message-goto-body) (cd \"${PWD}\") (insert-file \"${OPTARG}\")"\r
282 > +         if [[ ! -f ${OPTARG} ]]; then\r
283 > +             echo "$0: '${OPTARG}': no such file" >&2\r
284 > +             exit 1\r
285 > +         fi\r
286 > +         if [[ $cddone == 'false' ]]; then\r
287 > +             BODY=${BODY}$'\n'"  (cd \"${PWD}\")"\r
288 > +             cddone=true\r
289 > +         fi\r
290 > +         BODY=${BODY}$'\n'"  (insert-file \"${OPTARG}\")"\r
291 > +         BODY=${BODY}$'\n'"  (if (/= (point) (line-beginning-position)) (insert \"\\n\"))"\r
292 > +         unset message_goto\r
293 > +         ;;\r
294 > +     --bodytext)\r
295 > +         BODY=${BODY}$'\n'"  (insert \"${OPTARG}\\n\")"\r
296 > +         unset message_goto\r
297 >           ;;\r
298 >       --print)\r
299 >           PRINT_ONLY=1\r
300 >           ;;\r
301 >       --no-window-system)\r
302 > -         CLIENT_TYPE="-t"\r
303 > +         EMACSCLIENT_TYPE='-t'\r
304 > +         EMACS_NW='-nw'\r
305 >           ;;\r
306 >       *)\r
307 >           # We should never end up here.\r
308 > @@ -116,21 +159,39 @@ done\r
309 >  \r
310 >  # Positional parameters.\r
311 >  for arg; do\r
312 > -    arg="$(escape "${arg}")"\r
313 > -    ELISP="${ELISP} (message-goto-to) (insert \"${arg}, \")"\r
314 > +    escape -v _arg "${arg}"\r
315 > +    TO=${TO:+$TO, }${_arg}\r
316 > +    message_goto='(message-goto-to)'\r
317 >  done\r
318 >  \r
319 > -# End progn.\r
320 > -ELISP="${ELISP})"\r
321 > +# The newlines are here for better user experience when --print option is used.\r
322 > +NL=$'\n'\r
323 > +ELISP="\\r
324 > +${CC:+$NL  (message-goto-cc) (insert \"$CC\")}\\r
325 > +${BCC:+$NL  (message-goto-bcc) (insert \"$BCC\")}\\r
326 > +${BODY:+$NL  (message-goto-body)$BODY}"\r
327 >  \r
328 > -if [ -n "$PRINT_ONLY" ]; then\r
329 > -    echo ${ELISP}\r
330 > -    exit 0\r
331 > -fi\r
332 > -\r
333 > -if [ -n "$USE_EMACSCLIENT" ]; then\r
334 > -    # Evaluate the progn.\r
335 > -    exec ${EMACSCLIENT} ${CLIENT_TYPE} -a '' --eval "${ELISP}"\r
336 > +if [[ $TO == '' && $SUBJECT == '' && $ELISP == '' ]]\r
337 > +then\r
338 > +    exec_mua "(prog1 'done (require 'notmuch) (notmuch-hello))"\r
339 >  else\r
340 > -    exec ${EMACS} --eval "${ELISP}"\r
341 > +    [[ $FROM != '' ]] && OH="(list (cons 'From \"$FROM\"))" || OH=nil\r
342 > +\r
343 > +    if [[ $SUBJECT == '' ]]; then\r
344 > +     SUBJECT=nil\r
345 > +     message_goto='(message-goto-subject)'\r
346 > +    else\r
347 > +     SUBJECT=\"$SUBJECT\"\r
348 > +    fi\r
349 > +    if [[ $TO == '' ]]; then\r
350 > +     TO=nil\r
351 > +     message_goto='(message-goto-to)'\r
352 > +    else\r
353 > +     TO=\"$TO\"\r
354 > +    fi\r
355 > +    exec_mua "(prog1 'done (require 'notmuch)\r
356 > +  (setq message-exit-actions (list #'save-buffers-kill-terminal))\r
357 > +  (notmuch-mua-mail ${TO} ${SUBJECT}\r
358 > +     ${OH} nil (notmuch-mua-get-switch-function))\\r
359 > +${ELISP}${NL}  (set-buffer-modified-p nil)${message_goto+ $message_goto})"\r
360 >  fi\r
361 > -- \r
362 > 2.1.0\r
363 >\r
364 > _______________________________________________\r
365 > notmuch mailing list\r
366 > notmuch@notmuchmail.org\r
367 > http://notmuchmail.org/mailman/listinfo/notmuch\r