Cancel tasks with <localleader>c

This commit is contained in:
David Beniamine
2015-09-16 17:02:42 +02:00
parent d3b011b718
commit 644b6d6628
3 changed files with 30 additions and 9 deletions

View File

@@ -164,6 +164,8 @@ like this behavior, you can set the default done.txt name:
`<LocalLeader>x` is a toggle which allow you to unmark a task as done. `<LocalLeader>x` is a toggle which allow you to unmark a task as done.
`<LocalLeader>c` Mark a task cancelled
Syntax highlighting for couples key:value Syntax highlighting for couples key:value
If the current buffer is a done.txt file, the basic sort sorts on completion If the current buffer is a done.txt file, the basic sort sorts on completion

View File

@@ -58,19 +58,27 @@ function! todo#PrependDate()
normal! 0"=strftime("%Y-%m-%d ") normal! 0"=strftime("%Y-%m-%d ")
P P
endfunction endfunction
function! todo#ToggleMarkAsDone(status) function! todo#ToggleMarkAsDone(status)
if (getline(".") =~ 'x\s*\d\{4\}') if (getline(".") =~ 'x\s*\d\{4\}')
:call todo#UnMarkAsDone(a:status) :call todo#UnMarkAsDone(a:status)
else else
:call todo#MarkAsDone(a:status) :call todo#MarkAsDone(a:status)
endif endif
endfunction endfunction
function! todo#UnMarkAsDone() function! todo#UnMarkAsDone(status)
if a:status==''
let pat=''
else
let pat=' '.a:status
endif
exec ':s/\s*x\s*\d\{4}-\d\{1,2}-\d\{1,2}'.pat.'\s*//g' exec ':s/\s*x\s*\d\{4}-\d\{1,2}-\d\{1,2}'.pat.'\s*//g'
endfunction endfunction
function! todo#MarkAsDone(status)
if a:status!=''
exec 'normal! I'.a:status.' '
endif endif
call todo#PrependDate() call todo#PrependDate()
normal! Ix normal! Ix

View File

@@ -122,16 +122,27 @@ endif
" Mark done {{{2 " Mark done {{{2
if !hasmapto("<localleader>x",'n') if !hasmapto("<localleader>x",'n')
nnoremap <script> <silent> <buffer> <localleader>x :call todo#ToggleMarkAsDone()<CR> nnoremap <script> <silent> <buffer> <localleader>x :call todo#ToggleMarkAsDone('')<CR>
endif endif
if !hasmapto("<localleader>x",'v') if !hasmapto("<localleader>x",'v')
vnoremap <script> <silent> <buffer> <localleader>x :call todo#ToggleMarkAsDone()<CR> vnoremap <script> <silent> <buffer> <localleader>x :call todo#ToggleMarkAsDone('')<CR>
endif endif
" Mark done {{{2
if !hasmapto("<localleader>c",'n')
nnoremap <script> <silent> <buffer> <localleader>c :call todo#ToggleMarkAsDone('Cancelled')<CR>
endif
if !hasmapto("<localleader>c",'v')
vnoremap <script> <silent> <buffer> <localleader>c :call todo#ToggleMarkAsDone('Cancelled')<CR>
endif
" Mark all done {{{2 " Mark all done {{{2
if !hasmapto("<localleader>X",'n') if !hasmapto("<localleader>X",'n')
nnoremap <script> <silent> <buffer> <localleader>X :call todo#MarkAllAsDone()<CR> nnoremap <script> <silent> <buffer> <localleader>X :call todo#MarkAllAsDone('')<CR>
endif endif
" Remove completed {{{2 " Remove completed {{{2