X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=vim%2Fplugin%2Fnotmuch.vim;h=8f27fb9273d2efb124c6de8f27cd8ceeaee23deb;hb=b9effbba387924d51d9437ea8186d78d7825f5a7;hp=f4a4f2334ac476831031052244ee2ae9ffe64666;hpb=3cac5f8acb3bf98636a81e44c620fd550843ed53;p=notmuch
diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim
index f4a4f233..8f27fb92 100644
--- a/vim/plugin/notmuch.vim
+++ b/vim/plugin/notmuch.vim
@@ -18,12 +18,14 @@
" along with Notmuch. If not, see .
"
" Authors: Bart Trojanowski
-" Contributors: Peter Hartman
+" Contributors: Felipe Contreras ,
+" Peter Hartman
"
" --- configuration defaults {{{1
let s:notmuch_defaults = {
\ 'g:notmuch_cmd': 'notmuch' ,
+ \ 'g:notmuch_sendmail': '/usr/sbin/sendmail' ,
\ 'g:notmuch_debug': 0 ,
\
\ 'g:notmuch_search_newest_first': 1 ,
@@ -46,7 +48,7 @@ let s:notmuch_defaults = {
\ 'g:notmuch_show_part_end_regexp': 'part}' ,
\ 'g:notmuch_show_marker_regexp': '\\(message\\|header\\|body\\|attachment\\|part\\)[{}].*$',
\
- \ 'g:notmuch_show_message_parse_regexp': '\(id:[^ ]*\) depth:\([0-9]*\) match:\([0-9]*\) filename:\(.*\)$',
+ \ 'g:notmuch_show_message_parse_regexp': '\(id:[^ ]*\) depth:\([0-9]*\) match:\([0-9]*\) excluded:\([0-9]*\) filename:\(.*\)$',
\ 'g:notmuch_show_tags_regexp': '(\([^)]*\))$' ,
\
\ 'g:notmuch_show_signature_regexp': '^\(-- \?\|_\+\)$' ,
@@ -56,7 +58,7 @@ let s:notmuch_defaults = {
\
\ 'g:notmuch_compose_insert_mode_start': 1 ,
\ 'g:notmuch_compose_header_help': 1 ,
- \ 'g:notmuch_compose_temp_file_dir': '~/.notmuch/compose/' ,
+ \ 'g:notmuch_compose_temp_file_dir': '~/.notmuch/compose' ,
\ }
" defaults for g:notmuch_initial_search_words
@@ -118,8 +120,10 @@ let g:notmuch_search_maps = {
\ '': ':call NM_search_show_thread(0)',
\ '': ':call NM_search_show_thread(1)',
\ '': ':call NM_search_expand('''')',
+ \ 'I': ':call NM_search_mark_read_thread()',
\ 'a': ':call NM_search_archive_thread()',
\ 'A': ':call NM_search_mark_read_then_archive_thread()',
+ \ 'D': ':call NM_search_delete_thread()',
\ 'f': ':call NM_search_filter()',
\ 'm': ':call NM_new_mail()',
\ 'o': ':call NM_search_toggle_order()',
@@ -145,10 +149,13 @@ let g:notmuch_show_maps = {
\ 'b': ':call NM_show_fold_toggle(''b'', ''bdy'', !g:notmuch_show_fold_bodies)',
\ 'c': ':call NM_show_fold_toggle(''c'', ''cit'', !g:notmuch_show_fold_citations)',
\ 'h': ':call NM_show_fold_toggle(''h'', ''hdr'', !g:notmuch_show_fold_headers)',
- \ 'i': ':call NM_show_fold_toggle(''s'', ''sig'', !g:notmuch_show_fold_signatures)',
+ \ 'i': ':call NM_show_fold_toggle(''i'', ''sig'', !g:notmuch_show_fold_signatures)',
\
+ \ 'I': ':call NM_show_mark_read_thread()',
\ 'a': ':call NM_show_archive_thread()',
\ 'A': ':call NM_show_mark_read_then_archive_thread()',
+ \ 'D': ':call NM_show_delete_thread()',
+ \ 'd': ':call NM_show_delete_message()',
\ 'N': ':call NM_show_mark_read_then_next_open_message()',
\ 'v': ':call NM_show_view_all_mime_parts()',
\ '+': ':call NM_show_add_tag()',
@@ -255,12 +262,12 @@ function! s:NM_cmd_search_fmtline(line)
return 'ERROR PARSING: ' . a:line
endif
let max = g:notmuch_search_from_column_width
- let flist = []
- for at in split(m[4], ", ")
- let p = min([stridx(at, "."), stridx(at, "@")])
- call insert(flist, tolower(at[0:p - 1]))
+ let flist = {}
+ for at in split(m[4], '[|,] ')
+ let p = split(at, '[@.]')
+ let flist[p[0]] = 1
endfor
- let from = join(flist, ", ")
+ let from = join(keys(flist), ", ")
return printf("%-12s %3s %-20.20s | %s (%s)", m[2], m[3], from, m[5], m[6])
endfunction
@@ -307,6 +314,11 @@ function! s:NM_search_edit()
endif
endfunction
+function! s:NM_search_mark_read_thread()
+ call NM_tag([], ['-unread'])
+ norm j
+endfunction
+
function! s:NM_search_archive_thread()
call NM_tag([], ['-inbox'])
norm j
@@ -317,6 +329,11 @@ function! s:NM_search_mark_read_then_archive_thread()
norm j
endfunction
+function! s:NM_search_delete_thread()
+ call NM_tag([], ['+delete','-inbox','-unread'])
+ norm j
+endfunction
+
function! s:NM_search_filter()
call NM_search_filter_helper('Filter: ', '', '')
endfunction
@@ -494,8 +511,14 @@ function! s:NM_show_next_thread()
endif
endfunction
+function! s:NM_show_mark_read_thread()
+ call NM_tag(b:nm_search_words, ['-unread'])
+ call NM_show_next_thread()
+endfunction
+
function! s:NM_show_archive_thread()
- echo 'not implemented'
+ call NM_tag(b:nm_search_words, ['-inbox'])
+ call NM_show_next_thread()
endfunction
function! s:NM_show_mark_read_then_archive_thread()
@@ -503,6 +526,16 @@ function! s:NM_show_mark_read_then_archive_thread()
call NM_show_next_thread()
endfunction
+function! s:NM_show_delete_thread()
+ call NM_tag(b:nm_search_words, ['+delete', '-inbox', '-unread'])
+ call NM_show_next_thread()
+endfunction
+
+function! s:NM_show_delete_message()
+ let msg = NM_show_get_message_for_line(line('.'))
+ call NM_tag([msg['id']], ['+delete', '-inbox', '-unread'])
+endfunction
+
function! s:NM_show_mark_read_then_next_open_message()
echo 'not implemented'
endfunction
@@ -563,7 +596,7 @@ function! s:NM_show_advance_marking_read_and_archiving()
let filter = NM_combine_tags('tag:', advance_tags, 'OR', '()')
\ + ['AND']
\ + NM_combine_tags('', ids, 'OR', '()')
- call map(advance_tags, '"+" . v:val')
+ call map(advance_tags, '"-" . v:val')
call NM_tag(filter, advance_tags)
call NM_show_next(1, 1)
return
@@ -714,8 +747,11 @@ function! s:NM_cmd_show_parse(inlines)
elseif mode_type == 'cit'
if part_end || match(line, g:notmuch_show_citation_regexp) == -1
let outlnum = len(info['disp'])
- let foldinfo = [ mode_type, mode_start, outlnum-1, len(info['msgs']),
- \ printf('[ %d-line citation. Press "c" to show. ]', outlnum - mode_start) ]
+ if !part_end
+ let outlnum = outlnum - 1
+ endif
+ let foldinfo = [ mode_type, mode_start, outlnum, len(info['msgs']),
+ \ printf('[ %d-line citation. Press "c" to show. ]', 1 + outlnum - mode_start) ]
let mode_type = ''
endif
elseif mode_type == 'sig'
@@ -723,8 +759,8 @@ function! s:NM_cmd_show_parse(inlines)
if (outlnum - mode_start) > g:notmuch_show_signature_lines_max
let mode_type = ''
elseif part_end
- let foldinfo = [ mode_type, mode_start, outlnum-1, len(info['msgs']),
- \ printf('[ %d-line signature. Press "s" to show. ]', outlnum - mode_start) ]
+ let foldinfo = [ mode_type, mode_start, outlnum, len(info['msgs']),
+ \ printf('[ %d-line signature. Press "i" to show. ]', 1 + outlnum - mode_start) ]
let mode_type = ''
endif
endif
@@ -732,7 +768,7 @@ function! s:NM_cmd_show_parse(inlines)
if part_end
" FIXME: this is a hack for handling two folds being added for one line
- " we should handle addinga fold in a function
+ " we should handle adding a fold in a function
if len(foldinfo) && foldinfo[1] < foldinfo[2]
call add(info['folds'], foldinfo[0:3])
let info['foldtext'][foldinfo[1]] = foldinfo[4]
@@ -763,7 +799,14 @@ function! s:NM_cmd_show_parse(inlines)
endif
call add(info['disp'],
\ printf('--- %s ---', in_part))
- let part_start = len(info['disp']) + 1
+ " We don't yet handle nested parts, so pop
+ " multipart/* immediately so text/plain
+ " sub-parts are parsed properly
+ if match(in_part, '^multipart/') != -1
+ let in_part = ''
+ else
+ let part_start = len(info['disp']) + 1
+ endif
endif
elseif in_header
@@ -827,7 +870,8 @@ function! s:NM_cmd_show_parse(inlines)
let msg['id'] = m[1]
let msg['depth'] = m[2]
let msg['match'] = m[3]
- let msg['filename'] = m[4]
+ let msg['excluded'] = m[4]
+ let msg['filename'] = m[5]
endif
let in_message = 1
@@ -947,18 +991,28 @@ function! s:NM_compose_send()
let line = getline(lnum)
let lst_hdr = ''
while match(line, '^$') == -1
- if match(line, '^Notmuch-Help:') == -1
+ if !exists("hdr_starts") && match(line, '^Notmuch-Help:') == -1
let hdr_starts = lnum - 1
- break
endif
let lnum = lnum + 1
let line = getline(lnum)
endwhile
+ let body_starts = lnum - 1
+ call append(body_starts, 'Date: ' . strftime('%a, %d %b %Y %H:%M:%S %z'))
exec printf(':0,%dd', hdr_starts)
write
- let cmdtxt = 'mailx -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
@@ -1271,7 +1325,7 @@ endfunction
function! s:NM_tag(filter, tags)
let filter = len(a:filter) ? a:filter : [NM_search_thread_id()]
if !len(filter)
- throw 'Eeek! I couldn''t find the thead id!'
+ throw 'Eeek! I couldn''t find the thread id!'
endif
let args = ['tag']
call extend(args, a:tags)