Merge branch 'master' of gitlab.com:dbeniamine/todo.txt-vim into github

This commit is contained in:
David Beniamine
2019-01-23 11:01:49 +01:00
2 changed files with 9 additions and 7 deletions

View File

@@ -153,17 +153,19 @@ function! todo#RemoveCompleted()
call s:AppendToFile(l:done_file, l:completed)
endfunction
function! todo#Sort()
function! todo#Sort(type)
" vim :sort is usually stable
" we sort first on contexts, then on projects and then on priority
let g:Todo_fold_char='x'
if expand('%')=~'[Dd]one.*.txt'
let oldcursor=todo#GetCurpos()
if(a:type != "")
exec ':sort /.\{-}\ze'.a:type.'/'
elseif expand('%')=~'[Dd]one.*.txt'
" FIXME: Put some unit tests around this, and fix case sensitivity if ignorecase is set.
silent! %s/\(x\s*\d\{4}\)-\(\d\{2}\)-\(\d\{2}\)/\1\2\3/g
sort n /^x\s*/
silent! %s/\(x\s*\d\{4}\)\(\d\{2}\)/\1-\2-/g
else
let oldcursor=getpos(".")
silent normal gg
let l:first=search('^\s*x')
if l:first != 0
@@ -193,8 +195,8 @@ function! todo#Sort()
execute ':'.l:first.','.l:last.'sort /+[a-zA-Z]*/ r'
execute ':'.l:first.','.l:last.'sort /\v([A-Z])/ r'
endif
call cursor(oldcursor)
endif
call setpos('.', oldcursor)
endfunction
function! todo#SortDue()

View File

@@ -49,9 +49,9 @@ if !exists("g:Todo_txt_do_not_map") || ! g:Todo_txt_do_not_map
noremap <script> <silent> <buffer> <localleader>spc :call todo#HierarchicalSort('+', '@',1)<CR>
" Sort tasks {{{3
nnoremap <script> <silent> <buffer> <localleader>s :call todo#Sort()<CR>
nnoremap <script> <silent> <buffer> <localleader>s@ :sort /.\{-}\ze@/ <CR>
nnoremap <script> <silent> <buffer> <localleader>s+ :sort /.\{-}\ze+/ <CR>
nnoremap <script> <silent> <buffer> <localleader>s :call todo#Sort("")<CR>
nnoremap <script> <silent> <buffer> <localleader>s@ :call todo#Sort("@")<CR>
nnoremap <script> <silent> <buffer> <localleader>s+ :call todo#Sort("+")<CR>
" Priorities {{{3
" TODO: Make vim-repeat work on inc/dec priority