+" --- configuration defaults {{{1
+
+let s:notmuch_defaults = {
+ \ 'g:notmuch_cmd': 'notmuch' ,
+ \ 'g:notmuch_debug': 0 ,
+ \
+ \ 'g:notmuch_search_newest_first': 1 ,
+ \ 'g:notmuch_search_from_column_width': 20 ,
+ \
+ \ 'g:notmuch_show_fold_signatures': 1 ,
+ \ 'g:notmuch_show_fold_citations': 1 ,
+ \ 'g:notmuch_show_fold_bodies': 0 ,
+ \ 'g:notmuch_show_fold_headers': 1 ,
+ \
+ \ 'g:notmuch_show_message_begin_regexp': '\fmessage{' ,
+ \ 'g:notmuch_show_message_end_regexp': '\fmessage}' ,
+ \ 'g:notmuch_show_header_begin_regexp': '\fheader{' ,
+ \ 'g:notmuch_show_header_end_regexp': '\fheader}' ,
+ \ 'g:notmuch_show_body_begin_regexp': '\fbody{' ,
+ \ 'g:notmuch_show_body_end_regexp': '\fbody}' ,
+ \ 'g:notmuch_show_attachment_begin_regexp': '\fattachment{' ,
+ \ 'g:notmuch_show_attachment_end_regexp': '\fattachment}' ,
+ \ 'g:notmuch_show_part_begin_regexp': '\fpart{' ,
+ \ 'g:notmuch_show_part_end_regexp': '\fpart}' ,
+ \ 'g:notmuch_show_marker_regexp': '\f\\(message\\|header\\|body\\|attachment\\|part\\)[{}].*$',
+ \
+ \ 'g:notmuch_show_message_parse_regexp': '\(id:[^ ]*\) depth:\([0-9]*\) match:\([0-9]*\) filename:\(.*\)$',
+ \ 'g:notmuch_show_tags_regexp': '(\([^)]*\))$' ,
+ \
+ \ 'g:notmuch_show_signature_regexp': '^\(-- \?\|_\+\)$' ,
+ \ 'g:notmuch_show_signature_lines_max': 12 ,
+ \
+ \ 'g:notmuch_show_citation_regexp': '^\s*>' ,
+ \
+ \ 'g:notmuch_compose_insert_mode_start': 1 ,
+ \ 'g:notmuch_compose_header_help': 1 ,
+ \ 'g:notmuch_compose_temp_file_dir': '~/.notmuch/compose/' ,
+ \ }
+
+" defaults for g:notmuch_initial_search_words
+" override with: let g:notmuch_initial_search_words = [ ... ]
+let s:notmuch_initial_search_words_defaults = [
+ \ 'tag:inbox and tag:unread',
+ \ ]
+
+" defaults for g:notmuch_show_headers
+" override with: let g:notmuch_show_headers = [ ... ]
+let s:notmuch_show_headers_defaults = [
+ \ 'Subject',
+ \ 'To',
+ \ 'Cc',
+ \ 'Bcc',
+ \ 'Date',
+ \ ]
+
+" defaults for g:notmuch_folders
+" override with: let g:notmuch_folders = [ ... ]
+let s:notmuch_folders_defaults = [
+ \ [ 'new', 'tag:inbox and tag:unread' ],
+ \ [ 'inbox', 'tag:inbox' ],
+ \ [ 'unread', 'tag:unread' ],
+ \ ]
+
+" defaults for g:notmuch_signature
+" override with: let g:notmuch_signature = [ ... ]
+let s:notmuch_signature_defaults = [
+ \ '',
+ \ '-- ',
+ \ 'email sent from notmuch.vim plugin'
+ \ ]
+
+" defaults for g:notmuch_compose_headers
+" override with: let g:notmuch_compose_headers = [ ... ]
+let s:notmuch_compose_headers_defaults = [
+ \ 'From',
+ \ 'To',
+ \ 'Cc',
+ \ 'Bcc',
+ \ 'Subject'
+ \ ]
+
+" --- keyboard mapping definitions {{{1
+
+" --- --- bindings for folders mode {{{2
+
+let g:notmuch_folders_maps = {
+ \ 'm': ':call <SID>NM_new_mail()<CR>',
+ \ 's': ':call <SID>NM_search_prompt()<CR>',
+ \ 'q': ':call <SID>NM_kill_this_buffer()<CR>',
+ \ '=': ':call <SID>NM_folders_refresh_view()<CR>',
+ \ '<Enter>': ':call <SID>NM_folders_show_search()<CR>',
+ \ }
+
+" --- --- bindings for search screen {{{2
+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>',
+ \ '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>',
+ \ 'm': ':call <SID>NM_new_mail()<CR>',
+ \ 'o': ':call <SID>NM_search_toggle_order()<CR>',
+ \ 'r': ':call <SID>NM_search_reply_to_thread()<CR>',
+ \ 's': ':call <SID>NM_search_prompt()<CR>',
+ \ ',s': ':call <SID>NM_search_edit()<CR>',
+ \ 't': ':call <SID>NM_search_filter_by_tag()<CR>',
+ \ 'q': ':call <SID>NM_kill_this_buffer()<CR>',
+ \ '+': ':call <SID>NM_search_add_tags([])<CR>',
+ \ '-': ':call <SID>NM_search_remove_tags([])<CR>',
+ \ '=': ':call <SID>NM_search_refresh_view()<CR>',
+ \ '?': ':echo <SID>NM_search_thread_id() . '' @ '' . join(<SID>NM_get_search_words())<CR>',
+ \ }
+
+" --- --- bindings for show screen {{{2
+let g:notmuch_show_maps = {
+ \ '<C-P>': ':call <SID>NM_show_previous(1, 0)<CR>',
+ \ '<C-N>': ':call <SID>NM_show_next(1, 0)<CR>',
+ \ '<C-]>': ':call <SID>NM_search_expand(''<cword>'')<CR>',
+ \ 'q': ':call <SID>NM_kill_this_buffer()<CR>',
+ \ 's': ':call <SID>NM_search_prompt()<CR>',
+ \
+ \ 'b': ':call <SID>NM_show_fold_toggle(''b'', ''bdy'', !g:notmuch_show_fold_bodies)<CR>',
+ \ 'c': ':call <SID>NM_show_fold_toggle(''c'', ''cit'', !g:notmuch_show_fold_citations)<CR>',
+ \ '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>',
+ \
+ \ '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>',
+ \ 'v': ':call <SID>NM_show_view_all_mime_parts()<CR>',
+ \ '+': ':call <SID>NM_show_add_tag()<CR>',
+ \ '-': ':call <SID>NM_show_remove_tag()<CR>',
+ \ '<Space>': ':call <SID>NM_show_advance_marking_read_and_archiving()<CR>',
+ \ '\|': ':call <SID>NM_show_pipe_message()<CR>',
+ \
+ \ '<S-Tab>': ':call <SID>NM_show_previous_fold()<CR>',
+ \ '<Tab>': ':call <SID>NM_show_next_fold()<CR>',
+ \ '<Enter>': ':call <SID>NM_show_toggle_fold()<CR>',
+ \
+ \ 'r': ':call <SID>NM_show_reply()<CR>',
+ \ 'm': ':call <SID>NM_new_mail()<CR>',
+ \ '?': ':echo <SID>NM_show_message_id() . '' @ '' . join(<SID>NM_get_search_words())<CR>',
+ \ }
+
+" --- --- bindings for compose screen {{{2
+let g:notmuch_compose_nmaps = {
+ \ ',s': ':call <SID>NM_compose_send()<CR>',
+ \ ',a': ':call <SID>NM_compose_attach()<CR>',
+ \ ',q': ':call <SID>NM_kill_this_buffer()<CR>',
+ \ '<Tab>': ':call <SID>NM_compose_next_entry_area()<CR>',
+ \ }
+let g:notmuch_compose_imaps = {
+ \ '<Tab>': '<C-r>=<SID>NM_compose_next_entry_area()<CR>',
+ \ }
+
+" --- implement folders screen {{{1
+
+function! s:NM_cmd_folders(words)
+ if len(a:words)
+ throw 'Not expecting any arguments for folders command.'
+ endif
+ let cmd = ['count']
+ let disp = []
+ let searches = []
+ for entry in g:notmuch_folders
+ let [ name, search ] = entry
+ let data = s:NM_run(cmd + [search])
+ let cnt = matchlist(data, '\(\d\+\)')[1]
+ call add(disp, printf('%9d %-20s (%s)', cnt, name, search))
+ call add(searches, search)
+ endfor