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)

_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch

Reply via email to