mirror of
https://github.com/tbabej/taskwiki.git
synced 2025-08-19 06:43:06 +02:00
taskwiki: Add TaskWikiDelete command
This commit is contained in:
parent
82223ed2df
commit
97691df5bb
2 changed files with 14 additions and 2 deletions
|
@ -9,3 +9,4 @@ augroup END
|
||||||
|
|
||||||
command! -range TaskWikiInfo :<line1>,<line2>py SelectedTasks().info()
|
command! -range TaskWikiInfo :<line1>,<line2>py SelectedTasks().info()
|
||||||
command! -range TaskWikiLink :<line1>,<line2>py SelectedTasks().link()
|
command! -range TaskWikiLink :<line1>,<line2>py SelectedTasks().link()
|
||||||
|
command! -range TaskWikiDelete :<line1>,<line2>py SelectedTasks().delete()
|
||||||
|
|
|
@ -55,8 +55,7 @@ class SelectedTasks(object):
|
||||||
cache.reset()
|
cache.reset()
|
||||||
|
|
||||||
# Load the current tasks
|
# Load the current tasks
|
||||||
range_tasks = [vwtask.VimwikiTask.from_line(cache, i)
|
range_tasks = [cache[i] for i in util.selected_line_numbers()]
|
||||||
for i in util.selected_line_numbers()]
|
|
||||||
self.tasks = [t for t in range_tasks if t is not None]
|
self.tasks = [t for t in range_tasks if t is not None]
|
||||||
|
|
||||||
if not self.tasks:
|
if not self.tasks:
|
||||||
|
@ -74,5 +73,17 @@ class SelectedTasks(object):
|
||||||
vimwikitask.task.add_annotation("wiki: {0}".format(path))
|
vimwikitask.task.add_annotation("wiki: {0}".format(path))
|
||||||
print("Task \"{0}\" linked.".format(vimwikitask['description']))
|
print("Task \"{0}\" linked.".format(vimwikitask['description']))
|
||||||
|
|
||||||
|
def delete(self):
|
||||||
|
# Delete the tasks in TaskWarrior
|
||||||
|
# Multiple VimwikiTasks might refer to the same task, so make sure
|
||||||
|
# we do not delete one task twice
|
||||||
|
for task in set(vimwikitask.task for vimwikitask in self.tasks):
|
||||||
|
task.delete()
|
||||||
|
|
||||||
|
# Remove the lines in the buffer
|
||||||
|
for vimwikitask in self.tasks:
|
||||||
|
cache.remove_line(vimwikitask['line_number'])
|
||||||
|
print("Task \"{0}\" deleted.".format(vimwikitask['description']))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
update_from_tw()
|
update_from_tw()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue