]> git.notmuchmail.org Git - notmuch/blobdiff - vim/plugin/notmuch.vim
vim: add support to mark as read in search view
[notmuch] / vim / plugin / notmuch.vim
index 6b82abedbfe2b9a655021bd6e7d99735f25356fa..fca48568921c6d8a1965593e22302d5de28db443 100644 (file)
@@ -120,6 +120,7 @@ let g:notmuch_search_maps = {
         \ '<Space>':    ':call <SID>NM_search_show_thread(0)<CR>',
         \ '<Enter>':    ':call <SID>NM_search_show_thread(1)<CR>',
         \ '<C-]>':      ':call <SID>NM_search_expand(''<cword>'')<CR>',
+        \ 'I':          ':call <SID>NM_search_mark_read_thread()<CR>',
         \ 'a':          ':call <SID>NM_search_archive_thread()<CR>',
         \ 'A':          ':call <SID>NM_search_mark_read_then_archive_thread()<CR>',
         \ 'f':          ':call <SID>NM_search_filter()<CR>',
@@ -149,6 +150,7 @@ let g:notmuch_show_maps = {
         \ 'h':          ':call <SID>NM_show_fold_toggle(''h'', ''hdr'', !g:notmuch_show_fold_headers)<CR>',
         \ 'i':          ':call <SID>NM_show_fold_toggle(''s'', ''sig'', !g:notmuch_show_fold_signatures)<CR>',
         \
+        \ 'I':          ':call <SID>NM_show_mark_read_thread()<CR>',
         \ 'a':          ':call <SID>NM_show_archive_thread()<CR>',
         \ 'A':          ':call <SID>NM_show_mark_read_then_archive_thread()<CR>',
         \ 'N':          ':call <SID>NM_show_mark_read_then_next_open_message()<CR>',
@@ -309,6 +311,11 @@ function! s:NM_search_edit()
         endif
 endfunction
 
+function! s:NM_search_mark_read_thread()
+        call <SID>NM_tag([], ['-unread'])
+        norm j
+endfunction
+
 function! s:NM_search_archive_thread()
         call <SID>NM_tag([], ['-inbox'])
         norm j
@@ -496,6 +503,11 @@ function! s:NM_show_next_thread()
         endif
 endfunction
 
+function! s:NM_show_mark_read_thread()
+        call <SID>NM_tag(b:nm_search_words, ['-unread'])
+        call <SID>NM_show_next_thread()
+endfunction
+
 function! s:NM_show_archive_thread()
         call <SID>NM_tag(b:nm_search_words, ['-inbox'])
         call <SID>NM_show_next_thread()
@@ -962,7 +974,16 @@ function! s:NM_compose_send()
         exec printf(':0,%dd', hdr_starts)
         write
 
-        let cmdtxt = g:notmuch_sendmail . ' -t < ' . fname
+        let line = getline(1)
+        let m = matchlist(line, '^From:\s*\(.*\)\s*<\(.*\)>$')
+        if (len(m) >= 2)
+                let from = m[2]
+        else
+                let m = matchlist(line, '^From:\s*\(.*\)$')
+                let from = m[1]
+        endif
+
+        let cmdtxt = g:notmuch_sendmail . ' -t -f ' . from . ' < ' . fname
         let out = system(cmdtxt)
         let err = v:shell_error
         if err