This commit is contained in:
Leandro Freitas
2014-11-01 21:39:09 -02:00
parent 5ad30f3ee8
commit 635de6dca0
5 changed files with 29 additions and 4 deletions

View File

@@ -31,7 +31,7 @@ This plugin gives syntax highlighting to [todo.txt](http://todotxt.com/) files.
`<leader>-X` : Mark all tasks as completed `<leader>-X` : Mark all tasks as completed
`<leader>-D` : Remove completed tasks `<leader>-D` : Move completed tasks to done.txt
If you want the help installed, run ":helptags ~/.vim/doc" inside vim after having copied the files. If you want the help installed, run ":helptags ~/.vim/doc" inside vim after having copied the files.
Then you will be able to get the commands help with: :h todo.txt Then you will be able to get the commands help with: :h todo.txt

View File

@@ -27,6 +27,6 @@ COMMANDS *todo-commands*
`<leader>-X` : Mark all tasks as completed `<leader>-X` : Mark all tasks as completed
`<leader>-D` : Remove completed tasks `<leader>-D` : Move completed tasks to done.txt
<leader> is \ by default, so <leader>-s means you type \s <leader> is \ by default, so <leader>-s means you type \s

View File

@@ -1,4 +1,3 @@
2014-11-01 Find a way to import text into markdown and vim doc @doc
x 2011-05-30 Create README.markdown to be published in github @doc x 2011-05-30 Create README.markdown to be published in github @doc
x 2011-05-30 Implement colorized priorities @syntax x 2011-05-30 Implement colorized priorities @syntax
x 2011-05-30 Implement filetype detection @ftdetect x 2011-05-30 Implement filetype detection @ftdetect

View File

@@ -35,8 +35,33 @@ function! TodoTxtMarkAllAsDone()
function! TodoTxtMarkAllAsDone() function! TodoTxtMarkAllAsDone()
:g!/^x /:call TodoTxtMarkAsDone() :g!/^x /:call TodoTxtMarkAsDone()
endfunction endfunction
function! s:AppendToFile(file, lines)
let l:lines = []
" Place existing tasks in done.txt at the beggining of the list.
if filereadable(a:file)
call extend(l:lines, readfile(a:file))
endif
" Append new completed tasks to the list.
call extend(l:lines, a:lines)
" Write to file.
call writefile(l:lines, a:file)
endfunction
function! TodoTxtRemoveCompleted() function! TodoTxtRemoveCompleted()
" Check if we can write to done.txt before proceeding.
let l:target_dir = expand('%:p:h')
let l:done_file = l:target_dir.'/done.txt'
if !filewritable(l:done_file) && !filewritable(l:target_dir)
echoerr "Can't write to file 'done.txt'"
return
endif
let l:completed = []
:g/^x /call add(l:completed, getline(line(".")))|d
call s:AppendToFile(l:done_file, l:completed) call s:AppendToFile(l:done_file, l:completed)
endfunction endfunction

1
todo.txt Normal file
View File

@@ -0,0 +1 @@
2014-11-01 Find a way to import text into markdown and vim doc @doc