Fix #21
Better handling of priority on done tasks Also added <localleader>ff to fix format. this will remove leading whitespaces and convert old (wrong) done tasks to the correct format
This commit is contained in:
@@ -259,3 +259,7 @@ Possible values are :
|
||||
+ `<LocalLeader>X` : Mark all tasks as completed
|
||||
+ `<LocalLeader>D` : Move completed tasks to done file, see [TodoTxt
|
||||
Files](#todotxt-files)
|
||||
|
||||
### Format
|
||||
|
||||
+ `<LocalLeader>ff` : Try to fix todo.txt format
|
||||
|
||||
@@ -77,6 +77,13 @@ function! todo#ToggleMarkAsDone(status)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! todo#FixFormat()
|
||||
" Remove heading space
|
||||
silent! %s/\C^\s*//
|
||||
" Remove priority from done tasks
|
||||
silent! %s/\C^x (\([A-Z]\)) \(.*\)/x \2 pri:\1/
|
||||
endfunction
|
||||
|
||||
function! todo#UnMarkAsDone(status)
|
||||
if a:status==''
|
||||
let pat=''
|
||||
@@ -84,12 +91,14 @@ function! todo#UnMarkAsDone(status)
|
||||
let pat=' '.a:status
|
||||
endif
|
||||
exec ':s/\C^x\s*\d\{4}-\d\{1,2}-\d\{1,2}'.pat.'\s*//g'
|
||||
silent s/\C\(.*\) pri:\([A-Z]\)/(\2) \1/
|
||||
endfunction
|
||||
|
||||
function! todo#MarkAsDone(status)
|
||||
if a:status!=''
|
||||
exec 'normal! I'.a:status.' '
|
||||
endif
|
||||
exec ':s/\C^(\([A-Z]\))\(.*\)/\2 pri:\1'
|
||||
call todo#PrependDate()
|
||||
if (getline(".") =~ '^ ')
|
||||
normal! gIx
|
||||
|
||||
@@ -27,6 +27,7 @@ Table of Contents *TodoTxt-Contents* ~
|
||||
6.2 Priorities...............................|TodoTxt-Priorities|
|
||||
6.3 Dates....................................|TodoTxt-Dates|
|
||||
6.4 Done.txt.................................|TodoTxt-Done|
|
||||
6.5 Format...................................|TodoTxt-Format|
|
||||
|
||||
===============================================================================
|
||||
1. Release notes *TodoTxt-ReleaseNotes* ~
|
||||
@@ -284,3 +285,7 @@ Possible values are :
|
||||
`<LocalLeader>D` : Move completed tasks to done file, see |TodoTxt-Files|
|
||||
|
||||
`<LocalLeader>` is \ by default, so ̀`<LocaLeader>-s` means you type \s
|
||||
|
||||
6.5 Format *TodoTxt-format*
|
||||
|
||||
`<LocalLeader>ff` : Try to fix todo.txt format
|
||||
|
||||
@@ -71,6 +71,8 @@ if !exists("g:Todo_txt_do_not_map")
|
||||
|
||||
" Sort by due: date {{{2
|
||||
nnoremap <script> <silent> <buffer> <localleader>sd :call todo#SortDue()<CR>
|
||||
" try fix format {{{2
|
||||
nnoremap <script> <silent> <buffer> <localleader>ff :call todo#FixFormat()<CR>
|
||||
endif
|
||||
|
||||
" Folding {{{1
|
||||
|
||||
@@ -460,7 +460,7 @@ Given todo (Tasks):
|
||||
Active task
|
||||
2017-09-01 Active task with a created date
|
||||
(A) Active priority task
|
||||
(A) 2017-09-01 Active priority task with a created date
|
||||
(C) 2017-09-01 Active priority task with a created date
|
||||
X 2017-09-18 Not to be confused for a complete task
|
||||
XNot to be confused for a complete task
|
||||
x 2017-09-18 Rules are not clear on leading whitespace, see comments in test
|
||||
@@ -476,8 +476,8 @@ Expect todo (Toggled tasks with today as **TODAY**):
|
||||
x **TODAY** X 2017-09-18 Not to be confused for a complete task
|
||||
x **TODAY** Active task
|
||||
x **TODAY** 2017-09-01 Active task with a created date
|
||||
x (A) **TODAY** Active priority task
|
||||
x (A) **TODAY** 2017-09-01 Active priority task with a created date
|
||||
x **TODAY** Active priority task pri:A
|
||||
x **TODAY** 2017-09-01 Active priority task with a created date pri:C
|
||||
x **TODAY** X 2017-09-18 Not to be confused for a complete task
|
||||
x **TODAY** XNot to be confused for a complete task
|
||||
x **TODAY** x 2017-09-18 Rules are not clear on leading whitespace, see comments in test
|
||||
|
||||
Reference in New Issue
Block a user