+function! s:NM_cmd_search_fmtline(line)
+ let m = matchlist(a:line, '^\(thread:\S\+\)\s\([^]]\+\]\) \([^;]\+\); \(.*\) (\([^(]*\))$')
+ if !len(m)
+ return 'ERROR PARSING: ' . a:line
+ endif
+ let max = g:notmuch_search_from_column_width
+ let from = m[3]
+ if strlen(from) >= max
+ let from = m[3][0:max-4] . '...'
+ endif
+ return printf('%s %-20s | %s (%s)', m[2], from, m[4], m[5])
+endfunction
+function! s:NM_cmd_search_mksyntax()
+ syntax clear nmSearchFrom
+ "syntax region nmSearchFrom start='\]\@<=' end='.'me=e+5,he=e+5,re=e+5 oneline contained
+ "syntax match nmSearchFrom /\]\@<=.\{10\}/ oneline contained
+ exec printf('syntax match nmSearchFrom /\(\] \)\@<=.\{%d\}/ oneline contained', g:notmuch_search_from_column_width)
+ "exec printf('syntax region nmSearchFrom start=''\%%%dv'' end=''\%%%dv'' oneline contained', 20, 30)
+endfunction
+
+" --- --- search screen action functions {{{2
+
+function! s:NM_search_show_thread()
+ let id = <SID>NM_search_find_thread_id()
+ if id != ''
+ call <SID>NM_cmd_show([id])
+ endif
+endfunction
+
+function! s:NM_search_prompt()
+ " TODO: input() can support completion
+ let text = input('NotMuch Search: ')
+ if strlen(text)
+ let tags = split(text)
+ else
+ let tags = s:notmuch_initial_search_words_defaults
+ endif
+ setlocal bufhidden=delete
+ call <SID>NM_cmd_search(tags)
+endfunction
+
+function! s:NM_search_edit()
+ " TODO: input() can support completion
+ let text = input('NotMuch Search: ', join(b:nm_search_words, ' '))
+ if strlen(text)
+ call <SID>NM_cmd_search(split(text))
+ endif
+endfunction
+
+function! s:NM_search_archive_thread()
+ call <SID>NM_add_remove_tags('-', ['inbox'])
+ " TODO: this could be made better and more generic
+ setlocal modifiable
+ s/(\([^)]*\)\<inbox\>\([^)]*\))$/(\1\2)/
+ setlocal nomodifiable
+ norm j
+endfunction
+
+function! s:NM_search_filter()
+ call <SID>NM_search_filter_helper('Filter: ', '')
+endfunction