[PATCH v2] VIM: Make an option to save sent mail locally

Ian Main imain at stemwinder.org
Mon Oct 20 10:58:50 PDT 2014


Add an option to use 'notmuch insert' to save your sent mail.
---

This update changes the 'system' line and adds a sent mailbox
option.

 vim/notmuch.vim | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/vim/notmuch.vim b/vim/notmuch.vim
index 331e930..b0c6ebd 100644
--- a/vim/notmuch.vim
+++ b/vim/notmuch.vim
@@ -58,6 +58,8 @@ let s:notmuch_date_format_default = '%d.%m.%y'
 let s:notmuch_datetime_format_default = '%d.%m.%y %H:%M:%S'
 let s:notmuch_reader_default = 'mutt -f %s'
 let s:notmuch_sendmail_default = 'sendmail'
+let s:notmuch_save_sent_locally_default = 1
+let s:notmuch_save_sent_mailbox_default = 'Sent'
 let s:notmuch_folders_count_threads_default = 0
 
 function! s:new_file_buffer(type, fname)
@@ -108,6 +110,18 @@ EOF
 		echohl None
 		return
 	endif
+
+	if g:notmuch_save_sent_locally
+		let out = system('notmuch insert --create-folder --folder=' . g:notmuch_save_sent_mailbox . ' +sent -unread -inbox < ' . fname)
+		let err = v:shell_error
+		if err
+			echohl Error
+			echo 'Eeek! unable to save sent mail'
+			echo out
+			echohl None
+			return
+		endif
+	endif
 	call delete(fname)
 	echo 'Mail sent successfully.'
 	call s:kill_this_buffer()
@@ -388,6 +402,14 @@ endfunction
 "" root
 
 function! s:set_defaults()
+	if !exists('g:notmuch_save_sent_locally')
+		let g:notmuch_save_sent_locally = s:notmuch_save_sent_locally_default
+	endif
+
+	if !exists('g:notmuch_save_sent_mailbox')
+		let g:notmuch_save_sent_mailbox = s:notmuch_save_sent_mailbox_default
+	endif
+
 	if !exists('g:notmuch_date_format')
 		if exists('g:notmuch_rb_date_format')
 			let g:notmuch_date_format = g:notmuch_rb_date_format
-- 
1.9.3



More information about the notmuch mailing list