added support for archive command
authorBart Trojanowski <bart@jukie.net>
Fri, 20 Nov 2009 16:13:49 +0000 (11:13 -0500)
committerBart Trojanowski <bart@jukie.net>
Wed, 25 Nov 2009 05:48:51 +0000 (00:48 -0500)
vim/README
vim/plugin/notmuch.vim

index ba6eb5feea189642b8840b38571a334ab8e53ab4..dffc88a42f9241ca29f8e4242b504a35d99a0e65 100644 (file)
@@ -18,6 +18,7 @@ Buffer types:
 
         Keybindings:
             <Enter> - show the selected message
 
         Keybindings:
             <Enter> - show the selected message
+            a       - archive message (remove inbox tag)
             s       - enter search criteria
             S       - alter search criteria
             +       - add tag(s) to selected message
             s       - enter search criteria
             S       - alter search criteria
             +       - add tag(s) to selected message
index d661c5658b6b5f4ebde85d289ae16ed925b556d5..ecf7b9defe94859f581528a078407383b0c64043 100644 (file)
@@ -136,7 +136,10 @@ function! s:NM_search_edit()
 endfunction
 
 function! s:NM_search_archive_thread()
 endfunction
 
 function! s:NM_search_archive_thread()
-        call <SID>NM_search_remove_tags('inbox')
+        call <SID>NM_add_remove_tags('-', ['inbox'])
+        setlocal modifiable
+        s/(\([^)]*\)\<inbox\>\([^)]*\))$/(\1\2)/
+        setlocal nomodifiable
         norm j
 endfunction
 
         norm j
 endfunction
 
@@ -190,23 +193,27 @@ function! s:NM_search_find_thread_id()
 endfunction
 
 function! s:NM_search_add_remove_tags(prompt, prefix, intags)
 endfunction
 
 function! s:NM_search_add_remove_tags(prompt, prefix, intags)
-        let id = <SID>NM_search_find_thread_id()
-        if id != ''
-                if type(a:intags) != type([]) || len(a:intags) == 0
-                        " TODO: input() can support completion
-                        let text = input(a:prompt)
-                        if !strlen(text)
-                                return
-                        endif
-                        let tags = split(text, ' ')
-                else
-                        let tags = a:intags
+        if type(a:intags) != type([]) || len(a:intags) == 0
+                " TODO: input() can support completion
+                let text = input(a:prompt)
+                if !strlen(text)
+                        return
                 endif
                 endif
-                call map(tags, 'a:prefix . v:val')
-                " TODO: handle errors
-                call <SID>NM_run(['tag'] + tags + ['--', id])
-                call <SID>NM_search_refresh_view()
+                call <SID>NM_add_remove_tags(prefix, split(text, ' '))
+        else
+                call <SID>NM_add_remove_tags(prefix, a:intags)
+        endif
+        call <SID>NM_search_refresh_view()
+endfunction
+
+function! s:NM_add_remove_tags(prefix, tags)
+        let id = <SID>NM_search_find_thread_id()
+        if id == ''
+                echoe 'Eeek! I couldn''t find the thead id!'
         endif
         endif
+        call map(a:tags, 'a:prefix . v:val')
+        " TODO: handle errors
+        call <SID>NM_run(['tag'] + a:tags + ['--', id])
 endfunction
 
 " --- implement show screen {{{1
 endfunction
 
 " --- implement show screen {{{1