taskwiki: Move methods that affect whole buffer into common namespace

This commit is contained in:
Tomas Babej 2015-03-21 14:11:41 +01:00
parent 0b02d85049
commit 5d32666cce
2 changed files with 23 additions and 20 deletions

View file

@ -4,7 +4,7 @@ execute 'pyfile ' . s:plugin_path . '/taskwiki/taskwiki.py'
augroup taskwiki
" when saving the file sync the tasks from vimwiki to TW
autocmd!
execute "autocmd BufWrite *.".expand('%:e')." python update_to_tw()"
execute "autocmd BufWrite *.".expand('%:e')." py WholeBuffer.update_to_tw()"
augroup END
command! -range TaskWikiInfo :<line1>,<line2>py SelectedTasks().info()

View file

@ -24,6 +24,8 @@ tw = TaskWarrior()
cache = cache.TaskCache(tw)
class WholeBuffer(object):
@staticmethod
def update_from_tw():
"""
Updates all the incomplete tasks in the vimwiki file if the info from TW is different.
@ -34,7 +36,7 @@ def update_from_tw():
cache.update_buffer()
cache.evaluate_viewports()
@staticmethod
def update_to_tw():
"""
Updates all tasks that differ from their TaskWarrior representation.
@ -47,6 +49,7 @@ def update_to_tw():
cache.update_buffer()
cache.evaluate_viewports()
class SelectedTasks(object):
def __init__(self):
self.tw = tw
@ -107,4 +110,4 @@ class SelectedTasks(object):
if __name__ == '__main__':
update_from_tw()
WholeBuffer.update_from_tw()