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