@@ -12,25 +12,24 @@ function! vimwiki_tasks#write()
12
12
let l: task = vimwiki_tasks#parse_task (l: line , l: defaults )
13
13
" add the task if it does not have a uuid
14
14
if l: task .uuid == " "
15
- call <SID> System (l: task .task_cmd .' add ' .shellescape (l: task .description).' ' .<SID> JoinTags (l: task .tags_list).' ' .l: task .task_meta)
15
+ call <SID> Task (l: task .task_args .' add ' .shellescape (l: task .description).' ' .<SID> JoinTags (l: task .tags_list).' ' .l: task .task_meta)
16
16
" find the id and the uuid of the newly created task
17
- let l: id = substitute (<SID> System ( " task newest limit:1 rc.verbose=nothing rc.color=off rc.defaultwidth=999 rc.report.newest.columns=id rc.report.newest.labels=ID" ), " \n " , " " , " " )
18
- let l: uuid = substitute (<SID> System ( " task " . l: id ." uuid" ), " \n " , " " , " " )
17
+ let l: id = substitute (<SID> Task ( " newest limit:1 rc.verbose=nothing rc.color=off rc.defaultwidth=999 rc.report.newest.columns=id rc.report.newest.labels=ID" ), " \n " , " " , " " )
18
+ let l: uuid = substitute (<SID> Task ( l: id ." uuid" ), " \n " , " " , " " )
19
19
" add the uuid to the line and remove the #TW indicator
20
20
call setline (l: i , <SID> RemoveTwIndicator (l: line )." #" .l: uuid )
21
21
22
22
if vimwiki_tasks#config (' annotate_origin' , 0 )
23
23
" annotate the task to reference the vimwiki file
24
- let l: cmd = ' task ' .l: id .' annotate vimwiki:' .expand (' %:p' )
25
- call <SID> System (l: cmd )
24
+ call <SID> Task (l: id .' annotate vimwiki:' .expand (' %:p' ))
26
25
endif
27
26
" see if we need to update the task in TW
28
27
else
29
28
let l: tw_task = vimwiki_tasks#load_task (l: task .uuid)
30
29
" don't update deleted tasks
31
30
if l: tw_task .status !=# ' Deleted'
32
31
if l: task .description !=# l: tw_task .description || l: task .due !=# l: tw_task .due || l: task .project !=# l: defaults .project || <SID> JoinTags (l: task .tags_list) !=# <SID> JoinTags (l: tw_task .tags_list)
33
- call <SID> System (l: task .task_cmd .' rc.confirmation=no uuid:' .l: task .uuid.
32
+ call <SID> Task (l: task .task_args .' rc.confirmation=no uuid:' .l: task .uuid.
34
33
\ ' modify ' .shellescape (l: task .description).' ' .
35
34
\ <SID> JoinTags (l: task .tags_list).' ' .<SID> TagsToRemove (l: tw_task .tags_list, l: task .tags_list).
36
35
\ ' ' .l: task .task_meta)
@@ -41,7 +40,7 @@ function! vimwiki_tasks#write()
41
40
elseif match (l: line , ' \v\* \[X\].*#[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}' ) != -1
42
41
let l: task = vimwiki_tasks#parse_task (l: line , l: defaults )
43
42
if index (b: open_tasks , l: task .uuid) >= 0
44
- call <SID> System ( ' task uuid:' .l: task .uuid.' done' )
43
+ call <SID> Task ( ' uuid:' .l: task .uuid.' done' )
45
44
endif
46
45
endif
47
46
let l: i += 1
@@ -145,7 +144,7 @@ function! vimwiki_tasks#parse_task(line, defaults)
145
144
let l: match = matchlist (a: line , ' \v\* \[.\]\s+(.*)\s*' )
146
145
let l: task .description = l: match [1 ]
147
146
" construct the task creation command and create
148
- let l: task .task_cmd = ' task '
147
+ let l: task .task_args = ' '
149
148
let l: task .task_meta = ' '
150
149
" add a project if necessary
151
150
if has_key (a: defaults , ' project' )
@@ -164,8 +163,8 @@ function! vimwiki_tasks#parse_task(line, defaults)
164
163
" set the due in task_meta
165
164
let l: task .due = l: task .due_date.' T' .l: task .due_time
166
165
let l: task .task_meta .= ' due:' .l: task .due
167
- " set the dateformat in task_cmd
168
- let l: task .task_cmd .= ' rc.dateformat=Y-M-DTH:N'
166
+ " set the dateformat in task_args
167
+ let l: task .task_args .= ' rc.dateformat=Y-M-DTH:N'
169
168
endif
170
169
" get the uuid from the task if it is there, and remove it from the task description
171
170
let l: task .uuid = matchstr (a: line , ' \v#\zs([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})' )
@@ -210,8 +209,8 @@ endfunction
210
209
211
210
function ! vimwiki_tasks#load_task (uuid)
212
211
let l: task = vimwiki_tasks#empty_task ()
213
- let l: cmd = ' task rc.verbose=nothing rc.defaultwidth=999 rc.dateformat.info=Y-M-DTH:N rc.color=off uuid:' .a: uuid .' info | grep "^\(ID\|UUID\|Description\|Status\|Due\|Project\|Tags\)"'
214
- let l: result = split (<SID> System (l: cmd ), ' \n' )
212
+ let l: cmd = ' rc.verbose=nothing rc.defaultwidth=999 rc.dateformat.info=Y-M-DTH:N rc.color=off uuid:' .a: uuid .' info | grep "^\(ID\|UUID\|Description\|Status\|Due\|Project\|Tags\)"'
213
+ let l: result = split (<SID> Task (l: cmd ), ' \n' )
215
214
for l: result_line in l: result
216
215
let l: match = matchlist (l: result_line , ' \v(\w+)\s+(.*)' )
217
216
let l: task [tolower (l: match [1 ])] = l: match [2 ]
@@ -294,6 +293,11 @@ function! s:System(cmd)
294
293
return system (a: cmd )
295
294
endfunction
296
295
296
+ function ! s: Task (args )
297
+ " execute task with the given args + any optional args specified by the user
298
+ return system (' task ' .vimwiki_tasks#config (' task_args' , ' ' ).' ' .a: args )
299
+ endfunction
300
+
297
301
function ! s: ErrorMsg (error )
298
302
if a: error == # ' TASK_DELETED'
299
303
return ' Task was deleted in taskwarrior'
0 commit comments