[PATCH 7/9] vim: use mailx for sending
authorFelipe Contreras <felipe.contreras@gmail.com>
Sat, 5 Jun 2010 11:12:40 +0000 (14:12 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:37:06 +0000 (09:37 -0800)
32/125da730969bd60e37c435dc9c02cd586af198 [new file with mode: 0644]

diff --git a/32/125da730969bd60e37c435dc9c02cd586af198 b/32/125da730969bd60e37c435dc9c02cd586af198
new file mode 100644 (file)
index 0000000..3c50e77
--- /dev/null
@@ -0,0 +1,172 @@
+Return-Path: <felipe.contreras@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 2632640AB4A\r
+       for <notmuch@notmuchmail.org>; Sat,  5 Jun 2010 04:13:58 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.999\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.999 tagged_above=-999 required=5\r
+       tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,\r
+       DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001] autolearn=ham\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id UfnbxJkQRLTt for <notmuch@notmuchmail.org>;\r
+       Sat,  5 Jun 2010 04:13:47 -0700 (PDT)\r
+Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com\r
+       [209.85.161.53])\r
+       by olra.theworths.org (Postfix) with ESMTP id A77AD417339\r
+       for <notmuch@notmuchmail.org>; Sat,  5 Jun 2010 04:13:06 -0700 (PDT)\r
+Received: by mail-fx0-f53.google.com with SMTP id 4so284086fxm.26\r
+       for <notmuch@notmuchmail.org>; Sat, 05 Jun 2010 04:13:06 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=domainkey-signature:received:received:from:to:cc:subject:date\r
+       :message-id:x-mailer:in-reply-to:references;\r
+       bh=Fqd/SA3Wt4NndYdiyfkpKNXQkOUmI/r520HlnKRpbfU=;\r
+       b=mtfzm74bFklRno7ZerhiGG21/xdl+0a+aijCkxTXD4+wNXNl5wL5jkuzJUKkuC8h4y\r
+       NSmAA58OjsWtE5w42IJfZa7E2ynYiKJtuQd7D0ZKc7oj/FrRlQOzaeaYkQna5J/x1MDA\r
+       TQYY5Z2TOv0+9hnJPPUcB6052F7EHRhEg+ca0=\r
+DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       b=AWyG9SjS7FfkaSyALZYHfSnTpoKYYWrBpFZdIBWe6v2fq+pNEeMBsw0DHeh4f5p9qA\r
+       z+/48AusKdgw83BhR9RnDtISIeuUa8OTIPj1o3EUh3pu+n+dSx6X2spob496pg2UI5eF\r
+       iv84+Rh4L7OmAttOqHIf5d7/ClNd6Mt9RatFo=\r
+Received: by 10.204.151.78 with SMTP id b14mr4815886bkw.200.1275736386303;\r
+       Sat, 05 Jun 2010 04:13:06 -0700 (PDT)\r
+Received: from localhost (a91-153-253-80.elisa-laajakaista.fi [91.153.253.80])\r
+       by mx.google.com with ESMTPS id v2sm9583793bkz.19.2010.06.05.04.13.04\r
+       (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
+       Sat, 05 Jun 2010 04:13:05 -0700 (PDT)\r
+From: Felipe Contreras <felipe.contreras@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 7/9] vim: use mailx for sending\r
+Date: Sat,  5 Jun 2010 14:12:40 +0300\r
+Message-Id: <1275736362-22771-8-git-send-email-felipe.contreras@gmail.com>\r
+X-Mailer: git-send-email 1.7.1\r
+In-Reply-To: <1275736362-22771-1-git-send-email-felipe.contreras@gmail.com>\r
+References: <1275736362-22771-1-git-send-email-felipe.contreras@gmail.com>\r
+Cc: Bart Trojanowski <bart@jukie.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 05 Jun 2010 11:13:58 -0000\r
+\r
+Possilby used by more systems, and besides the code wasn't really\r
+working properly anyway.\r
+\r
+Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\r
+---\r
+ vim/README             |    4 +-\r
+ vim/plugin/notmuch.vim |   61 ++++--------------------------------------------\r
+ 2 files changed, 7 insertions(+), 58 deletions(-)\r
+\r
+diff --git a/vim/README b/vim/README\r
+index 8cd3b1a..0807166 100644\r
+--- a/vim/README\r
++++ b/vim/README\r
+@@ -7,8 +7,8 @@ Dependencies:\r
+     notmuch:\r
+         Naturally, it expects you have notmuch installed and configured.\r
\r
+-    mail:\r
+-        To send mail, notmuch.vim uses the UNIX mail command.\r
++    mailx:\r
++        To send mail, notmuch.vim uses the UNIX mailx command.\r
\r
+     git-diff:\r
+         The vim interface makes use of the git-diff.vim syntax file\r
+diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim\r
+index 968c4c1..7b49015 100644\r
+--- a/vim/plugin/notmuch.vim\r
++++ b/vim/plugin/notmuch.vim\r
+@@ -941,71 +941,20 @@ function! s:NM_compose_send()\r
+         let fname = expand('%')\r
+         let lnum = 1\r
+         let line = getline(lnum)\r
+-        let hdrs = {}\r
+         let lst_hdr = ''\r
+         while match(line, '^$') == -1\r
+-                if match(line, '^Notmuch-Help:') != -1\r
+-                        " skip it\r
+-                elseif strlen(lst_hdr) && match(line, '^\s') != -1\r
+-                        let hdrs[lst_hdr][-1] = hdrs[lst_hdr][-1] . substitute(line, '^\s*', ' ', '')\r
+-                else\r
+-                        let m = matchlist(line, '^\(\w[^:]*\):\s*\(.*\)\s*$')\r
+-                        if !len(m)\r
+-                                cursor(lnum, 0)\r
+-                                throw printf('Eeek! invalid header on line %d', lnum)\r
+-                        endif\r
+-                        let key = substitute(m[1], '\<\w', '\U&', 'g')\r
+-                        if strlen(m[2])\r
+-                                if !has_key(hdrs, key)\r
+-                                        let hdrs[key] = []\r
+-                                endif\r
+-                                call add(hdrs[key], m[2])\r
+-                        endif\r
+-                        let lst_hdr = key\r
++                if match(line, '^Notmuch-Help:') == -1\r
++                        let hdr_starts = lnum - 1\r
++                        break\r
+                 endif\r
+                 let lnum = lnum + 1\r
+                 let line = getline(lnum)\r
+         endwhile\r
+-        let body_starts = lnum\r
+-\r
+-        "[-a header] [-b bcc-addr] [-c cc-addr] [-s subject] to-addr\r
+-        let cmd = ['mail']\r
+-        let tos = []\r
+-        for [key, vals] in items(hdrs)\r
+-                if key == 'To'\r
+-                        call extend(tos, vals)\r
+-                elseif key == 'Bcc'\r
+-                        for adr in vals\r
+-                                call add(cmd, '-b')\r
+-                                call add(cmd, adr)\r
+-                        endfor\r
+-                elseif key == 'Cc'\r
+-                        for adr in vals\r
+-                                call add(cmd, '-c')\r
+-                                call add(cmd, adr)\r
+-                        endfor\r
+-                elseif key == 'Subject'\r
+-                        for txt in vals\r
+-                                call add(cmd, '-s')\r
+-                                call add(cmd, txt)\r
+-                        endfor\r
+-                else\r
+-                        for val in vals\r
+-                                call add(cmd, '-a')\r
+-                                call add(cmd, key . ': ' . val)\r
+-                        endfor\r
+-                endif\r
+-        endfor\r
+-        call extend(cmd, tos)\r
+-\r
+-        " TODO: make sure we have at least one target\r
+-        " TODO: ask about empty jubject, etc\r
\r
+-        exec printf('0,%dd', body_starts)\r
++        exec printf(':0,%dd', hdr_starts)\r
+         write\r
\r
+-        call map(cmd, 's:NM_shell_escape(v:val)')\r
+-        let cmdtxt = join(cmd) . '< ' . fname\r
++        let cmdtxt = 'mailx -t < ' . fname\r
+         let out = system(cmdtxt)\r
+         let err = v:shell_error\r
+         if err\r
+-- \r
+1.7.1\r
+\r