]> git.notmuchmail.org Git - notmuch/blob - vim/plugin/notmuch.vim
more endless toil with syntax
[notmuch] / vim / plugin / notmuch.vim
1 " notmuch.vim plugin --- run notmuch within vim
2 "
3 " Copyright © Carl Worth
4 "
5 " This file is part of Notmuch.
6 "
7 " Notmuch is free software: you can redistribute it and/or modify it
8 " under the terms of the GNU General Public License as published by
9 " the Free Software Foundation, either version 3 of the License, or
10 " (at your option) any later version.
11 "
12 " Notmuch is distributed in the hope that it will be useful, but
13 " WITHOUT ANY WARRANTY; without even the implied warranty of
14 " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 " General Public License for more details.
16 "
17 " You should have received a copy of the GNU General Public License
18 " along with Notmuch.  If not, see <http://www.gnu.org/licenses/>.
19 "
20 " Authors: Bart Trojanowski <bart@jukie.net>
21
22 " --- configuration defaults {{{1
23
24 let s:notmuch_defaults = {
25         \ 'g:notmuch_cmd':                           'notmuch'                    ,
26         \
27         \ 'g:notmuch_search_newest_first':           1                            ,
28         \ 'g:notmuch_search_from_column_width':      20                           ,
29         \
30         \ 'g:notmuch_show_fold_signatures':          1                            ,
31         \ 'g:notmuch_show_fold_citations':           1                            ,
32         \
33         \ 'g:notmuch_show_message_begin_regexp':     '^\fmessage{'                ,
34         \ 'g:notmuch_show_message_end_regexp':       '^\fmessage}'                ,
35         \ 'g:notmuch_show_header_begin_regexp':      '^\fheader{'                 ,
36         \ 'g:notmuch_show_header_end_regexp':        '^\fheader}'                 ,
37         \ 'g:notmuch_show_body_begin_regexp':        '^\fbody{'                   ,
38         \ 'g:notmuch_show_body_end_regexp':          '^\fbody}'                   ,
39         \ 'g:notmuch_show_attachment_begin_regexp':  '^\fattachment{'             ,
40         \ 'g:notmuch_show_attachment_end_regexp':    '^\fattachment}'             ,
41         \ 'g:notmuch_show_part_begin_regexp':        '^\fpart{'                   ,
42         \ 'g:notmuch_show_part_end_regexp':          '^\fpart}'                   ,
43         \ 'g:notmuch_show_marker_regexp':            '^\f\\(message\\|header\\|body\\|attachment\\|part\\)[{}].*$',
44         \
45         \ 'g:notmuch_show_message_parse_regexp':     '\(id:[^ ]*\) depth:\([0-9]*\) filename:\(.*\)$',
46         \ 'g:notmuch_show_tags_regexp':              '(\([^)]*\))$'               ,
47         \
48         \ 'g:notmuch_show_signature_regexp':         '^\(-- \?\|_\+\)$'           ,
49         \ 'g:notmuch_show_signature_lines_max':      12                           ,
50         \
51         \ 'g:notmuch_show_citation_regexp':          '^\s*>'                      ,
52         \ }
53
54 " defaults for g:notmuch_initial_search_words
55 " override with: let g:notmuch_initial_search_words = [ ... ]
56 let s:notmuch_initial_search_words_defaults = [
57         \ 'tag:inbox'
58         \ ]
59
60 " defaults for g:notmuch_show_headers
61 " override with: let g:notmuch_show_headers = [ ... ]
62 let s:notmuch_show_headers_defaults = [
63         \ 'Subject',
64         \ 'From'
65         \ ]
66
67 " --- keyboard mapping definitions {{{1
68
69 " --- --- bindings for search screen {{{2
70 let g:notmuch_search_maps = {
71         \ '<Enter>':    ':call <SID>NM_search_show_thread()<CR>',
72         \ 'a':          ':call <SID>NM_search_archive_thread()<CR>',
73         \ 'f':          ':call <SID>NM_search_filter()<CR>',
74         \ 'm':          ':call <SID>NM_new_mail()<CR>',
75         \ 'o':          ':call <SID>NM_search_toggle_order()<CR>',
76         \ 'r':          ':call <SID>NM_search_reply_to_thread()<CR>',
77         \ 's':          ':call <SID>NM_search_prompt()<CR>',
78         \ 'S':          ':call <SID>NM_search_edit()<CR>',
79         \ 't':          ':call <SID>NM_search_filter_by_tag()<CR>',
80         \ 'q':          ':call <SID>NM_kill_buffer()<CR>',
81         \ '+':          ':call <SID>NM_search_add_tags([])<CR>',
82         \ '-':          ':call <SID>NM_search_remove_tags([])<CR>',
83         \ '=':          ':call <SID>NM_search_refresh_view()<CR>',
84         \ }
85
86 " --- --- bindings for show screen {{{2
87 let g:notmuch_show_maps = {
88         \ '<C-N>':      ':call <SID>NM_cmd_show_next()<CR>',
89         \ 'c':          ':call <SID>NM_cmd_show_fold_toggle(''c'', ''cit'', !g:notmuch_show_fold_citations)<CR>',
90         \ 's':          ':call <SID>NM_cmd_show_fold_toggle(''s'', ''sig'', !g:notmuch_show_fold_signatures)<CR>',
91         \ 'q':          ':call <SID>NM_kill_buffer()<CR>',
92         \ }
93
94 " --- implement search screen {{{1
95
96 function! s:NM_cmd_search(words)
97         let cmd = ['search']
98         if g:notmuch_search_newest_first
99                 let cmd = cmd + ['--sort=newest-first']
100         else
101                 let cmd = cmd + ['--sort=oldest-first']
102         endif
103         let data = s:NM_run(cmd + a:words)
104         "let data = substitute(data, '27/27', '25/27', '')
105         "let data = substitute(data, '\[4/4\]', '[0/4]', '')
106         let lines = split(data, "\n")
107         let disp = copy(lines)
108         "call map(disp, 'substitute(v:val, "^thread:\\S* ", "", "")' )
109         call map(disp, 's:NM_cmd_search_fmtline(v:val)')
110
111         call <SID>NM_newBuffer('search', join(disp, "\n"))
112         let b:nm_raw_lines = lines
113         let b:nm_search_words = a:words
114
115         call <SID>NM_cmd_search_mksyntax()
116         call <SID>NM_set_map(g:notmuch_search_maps)
117         setlocal cursorline
118         setlocal nowrap
119 endfunction
120 function! s:NM_cmd_search_fmtline(line)
121         let m = matchlist(a:line, '^\(thread:\S\+\)\s\([^]]\+\]\) \([^;]\+\); \(.*\) (\([^(]*\))$')
122         if !len(m)
123                 return 'ERROR PARSING: ' . a:line
124         endif
125         let max = g:notmuch_search_from_column_width
126         let from = m[3]
127         if strlen(from) >= max
128                 let from = m[3][0:max-4] . '...'
129         endif
130         return printf('%s %-20s | %s (%s)', m[2], from, m[4], m[5])
131 endfunction
132 function! s:NM_cmd_search_mksyntax()
133         syntax clear nmSearchFrom
134         "syntax region nmSearchFrom start='\]\@<=' end='.'me=e+5,he=e+5,re=e+5 oneline contained
135         "syntax match nmSearchFrom /\]\@<=.\{10\}/ oneline contained
136         exec printf('syntax match nmSearchFrom /\(\] \)\@<=.\{%d\}/ oneline contained', g:notmuch_search_from_column_width)
137         "exec printf('syntax region nmSearchFrom start=''\%%%dv'' end=''\%%%dv'' oneline contained', 20, 30)
138 endfunction
139
140 " --- --- search screen action functions {{{2
141
142 function! s:NM_search_show_thread()
143         let id = <SID>NM_search_find_thread_id()
144         if id != ''
145                 call <SID>NM_cmd_show([id])
146         endif
147 endfunction
148
149 function! s:NM_search_prompt()
150         " TODO: input() can support completion
151         let text = input('NotMuch Search: ')
152         if strlen(text)
153                 let tags = split(text)
154         else
155                 let tags = s:notmuch_initial_search_words_defaults
156         endif
157         setlocal bufhidden=delete
158         call <SID>NM_cmd_search(tags)
159 endfunction
160
161 function! s:NM_search_edit()
162         " TODO: input() can support completion
163         let text = input('NotMuch Search: ', join(b:nm_search_words, ' '))
164         if strlen(text)
165                 call <SID>NM_cmd_search(split(text))
166         endif
167 endfunction
168
169 function! s:NM_search_archive_thread()
170         call <SID>NM_add_remove_tags('-', ['inbox'])
171         " TODO: this could be made better and more generic
172         setlocal modifiable
173         s/(\([^)]*\)\<inbox\>\([^)]*\))$/(\1\2)/
174         setlocal nomodifiable
175         norm j
176 endfunction
177
178 function! s:NM_search_filter()
179         call <SID>NM_search_filter_helper('Filter: ', '')
180 endfunction
181
182 function! s:NM_search_filter_by_tag()
183         call <SID>NM_search_filter_helper('Filter Tag(s): ', 'tag:')
184 endfunction
185
186 function! s:NM_search_filter_helper(prompt, prefix)
187         " TODO: input() can support completion
188         let text = input(a:prompt)
189         if !strlen(text)
190                 return
191         endif
192
193         let tags = split(text)
194         map(tags, 'and a:prefix . v:val')
195         let tags = b:nm_search_words + tags
196         echo tags
197
198         let prev_bufnr = bufnr('%')
199         setlocal bufhidden=hide
200         call <SID>NM_cmd_search(tags)
201         setlocal bufhidden=delete
202         let b:nm_prev_bufnr = prev_bufnr
203 endfunction
204
205 function! s:NM_new_mail()
206         echoe 'Not implemented'
207 endfunction
208
209 function! s:NM_search_toggle_order()
210         let g:notmuch_search_newest_first = !g:notmuch_search_newest_first
211         " FIXME: maybe this would be better done w/o reading re-reading the lines
212         "         reversing the b:nm_raw_lines and the buffer lines would be better
213         call <SID>NM_search_refresh_view()
214 endfunction
215
216 function! s:NM_search_reply_to_thread()
217         echoe 'Not implemented'
218 endfunction
219
220 function! s:NM_search_add_tags(tags)
221         call <SID>NM_search_add_remove_tags('Add Tag(s): ', '+', a:tags)
222 endfunction
223
224 function! s:NM_search_remove_tags(tags)
225         call <SID>NM_search_add_remove_tags('Remove Tag(s): ', '-', a:tags)
226 endfunction
227
228 function! s:NM_search_refresh_view()
229         let lno = line('.')
230         setlocal bufhidden=delete
231         call <SID>NM_cmd_search(b:nm_search_words)
232         " FIXME: should find the line of the thread we were on if possible
233         exec printf('norm %dG', lno)
234 endfunction
235
236 " --- --- search screen helper functions {{{2
237
238 function! s:NM_search_find_thread_id()
239         if !exists('b:nm_raw_lines')
240                 echoe 'no b:nm_raw_lines'
241                 return ''
242         else
243                 let line = line('.')
244                 let info = b:nm_raw_lines[line-1]
245                 let what = split(info, '\s\+')[0]
246                 return what
247         endif
248 endfunction
249
250 function! s:NM_search_add_remove_tags(prompt, prefix, intags)
251         if type(a:intags) != type([]) || len(a:intags) == 0
252                 " TODO: input() can support completion
253                 let text = input(a:prompt)
254                 if !strlen(text)
255                         return
256                 endif
257                 call <SID>NM_add_remove_tags(a:prefix, split(text, ' '))
258         else
259                 call <SID>NM_add_remove_tags(a:prefix, a:intags)
260         endif
261         call <SID>NM_search_refresh_view()
262 endfunction
263
264 function! s:NM_add_remove_tags(prefix, tags)
265         let id = <SID>NM_search_find_thread_id()
266         if id == ''
267                 echoe 'Eeek! I couldn''t find the thead id!'
268         endif
269         call map(a:tags, 'a:prefix . v:val')
270         " TODO: handle errors
271         call <SID>NM_run(['tag'] + a:tags + ['--', id])
272 endfunction
273
274 " --- implement show screen {{{1
275
276 function! s:NM_cmd_show(words)
277         let prev_bufnr = bufnr('%')
278         let data = s:NM_run(['show'] + a:words)
279         let lines = split(data, "\n")
280
281         let info = s:NM_cmd_show_parse(lines)
282
283         setlocal bufhidden=hide
284         call <SID>NM_newBuffer('show', join(info['disp'], "\n"))
285         setlocal bufhidden=delete
286         let b:nm_raw_info = info
287         let b:nm_prev_bufnr = prev_bufnr
288
289         call <SID>NM_cmd_show_mkfolds()
290         call <SID>NM_cmd_show_mksyntax()
291         call <SID>NM_set_map(g:notmuch_show_maps)
292         setlocal foldtext=NM_cmd_show_foldtext()
293         setlocal fillchars=
294         setlocal foldcolumn=6
295
296 endfunction
297
298 function! s:NM_kill_buffer()
299         if exists('b:nm_prev_bufnr')
300                 setlocal bufhidden=delete
301                 exec printf(":buffer %d", b:nm_prev_bufnr)
302         else
303                 echo "Nothing to kill."
304         endif
305 endfunction
306
307 function! s:NM_cmd_show_next()
308         let info = b:nm_raw_info
309         let lnum = line('.')
310         let cnt = 0
311         for msg in info['msgs']
312                 let cnt = cnt + 1
313                 if lnum >= msg['start']
314                         continue
315                 endif
316
317                 exec printf('norm %dG', msg['start'])
318                 norm zz
319                 return
320         endfor
321         norm qj
322         call <SID>NM_search_show_thread()
323 endfunction
324
325 function! s:NM_cmd_show_fold_toggle(key, type, fold)
326         let info = b:nm_raw_info
327         let act = 'open'
328         if a:fold
329                 let act = 'close'
330         endif
331         for fld in info['folds']
332                 if fld[0] == a:type
333                         exec printf('%dfold%s', fld[1], act)
334                 endif
335         endfor
336         exec printf('nnoremap <buffer> %s :call <SID>NM_cmd_show_fold_toggle(''%s'', ''%s'', %d)<CR>', a:key, a:key, a:type, !a:fold)
337 endfunction
338
339
340 " s:NM_cmd_show_parse returns the following dictionary:
341 "    'disp':     lines to display
342 "    'msgs':     message info dicts { start, end, id, depth, filename, descr, header }
343 "    'folds':    fold info arrays [ type, start, end ]
344 "    'foldtext': fold text indexed by start line
345 function! s:NM_cmd_show_parse(inlines)
346         let info = { 'disp': [],       
347                    \ 'msgs': [],       
348                    \ 'folds': [],      
349                    \ 'foldtext': {} }  
350         let msg = {}
351         let hdr = {}
352
353         let in_message = 0
354         let in_header = 0
355         let in_body = 0
356         let in_part = ''
357
358         let body_start = -1
359         let part_start = -1
360
361         let mode_type = ''
362         let mode_start = -1
363
364         let inlnum = 0
365         for line in a:inlines
366                 let inlnum = inlnum + 1
367                 let foldinfo = []
368
369                 if strlen(in_part)
370                         let part_end = 0
371
372                         if match(line, g:notmuch_show_part_end_regexp) != -1
373                                 let part_end = len(info['disp'])
374                         else
375                                 call add(info['disp'], line)
376                         endif
377
378                         if in_part == 'text/plain'
379                                 if !part_end && mode_type == ''
380                                         if match(line, g:notmuch_show_signature_regexp) != -1
381                                                 let mode_type = 'sig'
382                                                 let mode_start = len(info['disp'])
383                                         elseif match(line, g:notmuch_show_citation_regexp) != -1
384                                                 let mode_type = 'cit'
385                                                 let mode_start = len(info['disp'])
386                                         endif
387                                 elseif mode_type == 'cit'
388                                         if part_end || match(line, g:notmuch_show_citation_regexp) == -1
389                                                 let outlnum = len(info['disp'])
390                                                 let foldinfo = [ mode_type, mode_start, outlnum,
391                                                                \ printf('[ %d-line citation.  Press "c" to show. ]', outlnum - mode_start) ]
392                                                 let mode_type = ''
393                                         endif
394                                 elseif mode_type == 'sig'
395                                         let outlnum = len(info['disp'])
396                                         if (outlnum - mode_start) > g:notmuch_show_signature_lines_max
397                                                 echoe 'line ' . outlnum . ' stopped matching'
398                                                 let mode_type = ''
399                                         elseif part_end
400                                                 let foldinfo = [ mode_type, mode_start, outlnum,
401                                                                \ printf('[ %d-line signature.  Press "s" to show. ]', outlnum - mode_start) ]
402                                                 let mode_type = ''
403                                         endif
404                                 endif
405                         endif
406
407                         if part_end
408                                 " FIXME: this is a hack for handling two folds being added for one line
409                                 "         we should handle addinga fold in a function
410                                 if len(foldinfo)
411                                         call add(info['folds'], foldinfo[0:2])
412                                         let info['foldtext'][foldinfo[1]] = foldinfo[3]
413                                 endif
414
415                                 let foldinfo = [ 'text', part_start, part_end,
416                                                \ printf('[ %d-line %s.  Press "p" to show. ]', part_end - part_start, in_part) ]
417                                 let in_part = ''
418                                 call add(info['disp'], '')
419                         endif
420
421                 elseif in_body
422                         if !has_key(msg,'body_start')
423                                 let msg['body_start'] = len(info['disp']) + 1
424                         endif
425                         if match(line, g:notmuch_show_body_end_regexp) != -1
426                                 let body_end = len(info['disp'])
427                                 let foldinfo = [ 'body', body_start, body_end,
428                                                \ printf('[ BODY %d - %d lines ]', len(info['msgs']), body_end - body_start) ]
429
430                                 let in_body = 0
431
432                         elseif match(line, g:notmuch_show_part_begin_regexp) != -1
433                                 let m = matchlist(line, 'ID: \(\d\+\), Content-type: \(\S\+\)')
434                                 let in_part = 'unknown'
435                                 if len(m)
436                                         let in_part = m[2]
437                                 endif
438                                 call add(info['disp'],
439                                          \ printf('--- %s ---', in_part))
440                                 let part_start = len(info['disp']) + 1
441                         endif
442
443                 elseif in_header
444                         if in_header == 1
445                                 let msg['descr'] = line
446                                 call add(info['disp'], line)
447                                 let in_header = 2
448                                 let msg['hdr_start'] = len(info['disp']) + 1
449
450                         else
451                                 if match(line, g:notmuch_show_header_end_regexp) != -1
452                                         let msg['header'] = hdr
453                                         let in_header = 0
454                                         let hdr = {}
455                                 else
456                                         let m = matchlist(line, '^\(\w\+\):\s*\(.*\)$')
457                                         if len(m)
458                                                 let hdr[m[1]] = m[2]
459                                                 if match(g:notmuch_show_headers, m[1]) != -1
460                                                         call add(info['disp'], line)
461                                                 endif
462                                         endif
463                                 endif
464                         endif
465
466                 elseif in_message
467                         if match(line, g:notmuch_show_message_end_regexp) != -1
468                                 let msg['end'] = len(info['disp'])
469                                 call add(info['disp'], '')
470
471                                 let foldinfo = [ 'match', msg['start'], msg['end'],
472                                                \ printf('[ MSG %d - %s ]', len(info['msgs']), msg['descr']) ]
473
474                                 call add(info['msgs'], msg)
475                                 let msg = {}
476                                 let in_message = 0
477                                 let in_header = 0
478                                 let in_body = 0
479                                 let in_part = ''
480
481                         elseif match(line, g:notmuch_show_header_begin_regexp) != -1
482                                 let in_header = 1
483                                 continue
484
485                         elseif match(line, g:notmuch_show_body_begin_regexp) != -1
486                                 let body_start = len(info['disp']) + 1
487                                 let in_body = 1
488                                 continue
489                         endif
490
491                 else
492                         if match(line, g:notmuch_show_message_begin_regexp) != -1
493                                 let msg['start'] = len(info['disp']) + 1
494
495                                 let m = matchlist(line, g:notmuch_show_message_parse_regexp)
496                                 if len(m)
497                                         let msg['id'] = m[1]
498                                         let msg['depth'] = m[2]
499                                         let msg['filename'] = m[3]
500                                 endif
501
502                                 let in_message = 1
503                         endif
504                 endif
505
506                 if len(foldinfo)
507                         call add(info['folds'], foldinfo[0:2])
508                         let info['foldtext'][foldinfo[1]] = foldinfo[3]
509                 endif
510         endfor
511         return info
512 endfunction
513
514 function! s:NM_cmd_show_mkfolds()
515         let info = b:nm_raw_info
516
517         for afold in info['folds']
518                 exec printf('%d,%dfold', afold[1], afold[2])
519                 if (afold[0] == 'sig' && g:notmuch_show_fold_signatures)
520                  \ || (afold[0] == 'cit' && g:notmuch_show_fold_citations)
521                         exec printf('%dfoldclose', afold[1])
522                 else
523                         exec printf('%dfoldopen', afold[1])
524                 endif
525         endfor
526 endfunction
527
528 function! s:NM_cmd_show_mksyntax()
529         let info = b:nm_raw_info
530         let cnt = 0
531         for msg in info['msgs']
532                 let cnt = cnt + 1
533                 let start = msg['start']
534                 let hdr_start = msg['hdr_start']
535                 let body_start = msg['body_start']
536                 let end = msg['end']
537                 exec printf('syntax region nmShowMsg%dDesc start=''\%%%dl'' end=''\%%%dl'' contains=@nmShowMsgDesc', cnt, start, start+1)
538                 exec printf('syntax region nmShowMsg%dHead start=''\%%%dl'' end=''\%%%dl'' contains=@nmShowMsgHead', cnt, hdr_start, body_start)
539                 exec printf('syntax region nmShowMsg%dBody start=''\%%%dl'' end=''\%%%dl'' contains=@nmShowMsgBody', cnt, body_start, end)
540         endfor
541 endfunction
542
543 function! NM_cmd_show_foldtext()
544         let foldtext = b:nm_raw_info['foldtext']
545         return foldtext[v:foldstart]
546 endfunction
547
548
549 " --- notmuch helper functions {{{1
550
551 function! s:NM_newBuffer(ft, content)
552         enew
553         setlocal buftype=nofile readonly modifiable
554         silent put=a:content
555         keepjumps 0d
556         setlocal nomodifiable
557         execute printf('set filetype=notmuch-%s', a:ft)
558         execute printf('set syntax=notmuch-%s', a:ft)
559 endfunction
560
561 function! s:NM_run(args)
562         let cmd = g:notmuch_cmd . ' ' . join(a:args) . '< /dev/null'
563         let out = system(cmd)
564         if v:shell_error
565                 echohl Error
566                 echo substitute(out, '\n*$', '', '')
567                 echohl None
568                 return ''
569         else
570                 return out
571         endif
572 endfunction
573
574 " --- process and set the defaults {{{1
575
576 function! NM_set_defaults(force)
577         for [key, dflt] in items(s:notmuch_defaults)
578                 let cmd = ''
579                 if !a:force && exists(key) && type(dflt) == type(eval(key))
580                         continue
581                 elseif type(dflt) == type(0)
582                         let cmd = printf('let %s = %d', key, dflt)
583                 elseif type(dflt) == type('')
584                         let cmd = printf('let %s = ''%s''', key, dflt)
585                 "elseif type(dflt) == type([])
586                 "        let cmd = printf('let %s = %s', key, string(dflt))
587                 else
588                         echoe printf('E: Unknown type in NM_set_defaults(%d) using [%s,%s]',
589                                                 \ a:force, key, string(dflt))
590                         continue
591                 endif
592                 exec cmd
593         endfor
594 endfunction
595 call NM_set_defaults(0)
596
597 " for some reason NM_set_defaults() didn't work for arrays...
598 if !exists('g:notmuch_show_headers')
599         let g:notmuch_show_headers = s:notmuch_show_headers_defaults
600 endif
601 if !exists('g:notmuch_initial_search_words')
602         let g:notmuch_initial_search_words = s:notmuch_initial_search_words_defaults
603 endif
604
605
606 " --- assign keymaps {{{1
607
608 function! s:NM_set_map(maps)
609         for [key, code] in items(a:maps)
610                 exec printf('nnoremap <buffer> %s %s', key, code)
611         endfor
612 endfunction
613
614 " --- command handler {{{1
615
616 function! NotMuch(args)
617         if !strlen(a:args)
618                 if exists('b:nm_search_words')
619                         let words = b:nm_search_words
620                 else
621                         let words = g:notmuch_initial_search_words
622                 endif
623                 call <SID>NM_cmd_search(words)
624                 return
625         endif
626
627         echo "blarg!"
628
629         let words = split(a:args)
630         " TODO: handle commands passed as arguments
631 endfunction
632 function! CompleteNotMuch(arg_lead, cmd_line, cursor_pos)
633         return []
634 endfunction
635
636
637 " --- glue {{{1
638
639 command! -nargs=* -complete=customlist,CompleteNotMuch NotMuch call NotMuch(<q-args>)
640 cabbrev  notmuch <c-r>=(getcmdtype()==':' && getcmdpos()==1 ? 'NotMuch' : 'notmuch')<CR>
641
642 " --- hacks, only for development :) {{{1
643
644 nnoremap ,nmr :source ~/.vim/plugin/notmuch.vim<CR>:call NotMuch('')<CR>
645
646 " vim: set ft=vim ts=8 sw=8 et foldmethod=marker :