--- /dev/null
+Return-Path: <telenczuk@unic.cnrs-gif.fr>\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 CB5B5429E4B\r
+ for <notmuch@notmuchmail.org>; Sat, 10 Jan 2015 04:03:36 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 2.438\r
+X-Spam-Level: **\r
+X-Spam-Status: No, score=2.438 tagged_above=-999 required=5\r
+ tests=[DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled\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 Z9kNyH+GDWUS for <notmuch@notmuchmail.org>;\r
+ Sat, 10 Jan 2015 04:03:34 -0800 (PST)\r
+Received: from smtp.webfaction.com (mail6.webfaction.com [74.55.86.74])\r
+ by olra.theworths.org (Postfix) with ESMTP id 0C336429E44\r
+ for <notmuch@notmuchmail.org>; Sat, 10 Jan 2015 04:03:34 -0800 (PST)\r
+Received: from localhost (87-231-242-54.rev.numericable.fr [87.231.242.54])\r
+ by smtp.webfaction.com (Postfix) with ESMTP id 776BC59A3AC5;\r
+ Sat, 10 Jan 2015 12:03:33 +0000 (UTC)\r
+From: Bartosz <telenczuk@unic.cnrs-gif.fr>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 3/4] VIM: save sent message to maildir\r
+Date: Sat, 10 Jan 2015 13:03:03 +0100\r
+Message-Id: <1420891384-992-4-git-send-email-telenczuk@unic.cnrs-gif.fr>\r
+X-Mailer: git-send-email 1.9.3 (Apple Git-50)\r
+In-Reply-To: <1420891384-992-1-git-send-email-telenczuk@unic.cnrs-gif.fr>\r
+References: <1420891384-992-1-git-send-email-telenczuk@unic.cnrs-gif.fr>\r
+X-Mailman-Approved-At: Sat, 10 Jan 2015 10:22:23 -0800\r
+Cc: Bartosz <telenczuk@unic.cnrs-gif.fr>\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, 10 Jan 2015 12:03:37 -0000\r
+\r
+maildir folder is slected based on the address in\r
+from header and it is configurable via notmuch\r
+config.\r
+---\r
+ vim/notmuch.vim | 20 ++++++++++++++++++++\r
+ 1 file changed, 20 insertions(+)\r
+\r
+diff --git a/vim/notmuch.vim b/vim/notmuch.vim\r
+index 4f90d79..e95db4d 100644\r
+--- a/vim/notmuch.vim\r
++++ b/vim/notmuch.vim\r
+@@ -110,6 +110,9 @@ EOF\r
+ echohl None\r
+ return\r
+ endif\r
++\r
++ call s:save_to_sent(fname)\r
++\r
+ call delete(fname)\r
+ echo 'Mail sent successfully.'\r
+ call s:kill_this_buffer()\r
+@@ -257,6 +260,20 @@ function! s:folders_refresh()\r
+ setlocal nomodifiable\r
+ endfunction\r
+ \r
++function! s:save_to_sent(fname)\r
++ruby << EOF\r
++ if $sent_dirs\r
++ fname = VIM::evaluate('a:fname')\r
++ m = Mail.read(fname)\r
++ from_address = m.from[0]\r
++ sent_box = $sent_dirs[from_address]\r
++ if sent_box\r
++ system "notmuch insert --folder:#{sent_box} +sent < #{fname}"\r
++ end\r
++ end\r
++EOF\r
++endfunction\r
++\r
+ "" basic\r
+ \r
+ function! s:show_cursor_moved()\r
+@@ -505,6 +522,8 @@ ruby << EOF\r
+ $email_address = get_config_item('user.primary_email')\r
+ $email_name = get_config_item('user.name')\r
+ $email = "%s <%s>" % [$email_name, $email_address]\r
++ sent_dirs_config = get_config_item('vim.sent_dirs')\r
++ $sent_dirs = Hash[sent_dirs_config.split("\n").collect{|x| x.strip.split("=>")}]\r
+ end\r
+ \r
+ def vim_puts(s)\r
+@@ -698,6 +717,7 @@ ruby << EOF\r
+ end\r
+ end\r
+ \r
++\r
+ module DbHelper\r
+ def init(name)\r
+ @name = name\r
+-- \r
+1.9.3 (Apple Git-50)\r
+\r