Renamed function to reflect its implementation

This commit is contained in:
Leandro Freitas
2015-05-20 17:12:46 -03:00
parent ddbcdd823f
commit 79e4d352a2
3 changed files with 11 additions and 11 deletions

View File

@@ -25,7 +25,7 @@ function! s:get_current_date()
return strftime('%Y-%m-%d') return strftime('%Y-%m-%d')
endfunction endfunction
function! todo#txt#prepend_date() function! todo#txt#replace_date()
let current_line = getline('.') let current_line = getline('.')
if (current_line =~ '^\(([a-zA-Z]) \)\?\d\{2,4\}-\d\{2\}-\d\{2\} ') && if (current_line =~ '^\(([a-zA-Z]) \)\?\d\{2,4\}-\d\{2\}-\d\{2\} ') &&
\ exists('g:todo_existing_date') && g:todo_existing_date == 'n' \ exists('g:todo_existing_date') && g:todo_existing_date == 'n'

View File

@@ -97,11 +97,11 @@ if !hasmapto("date<Tab>",'i')
endif endif
if !hasmapto("<localleader>d",'n') if !hasmapto("<localleader>d",'n')
nnoremap <script> <silent> <buffer> <localleader>d :call todo#txt#prepend_date()<CR> nnoremap <script> <silent> <buffer> <localleader>d :call todo#txt#replace_date()<CR>
endif endif
if !hasmapto("<localleader>d",'v') if !hasmapto("<localleader>d",'v')
vnoremap <script> <silent> <buffer> <localleader>d :call todo#txt#prepend_date()<CR> vnoremap <script> <silent> <buffer> <localleader>d :call todo#txt#replace_date()<CR>
endif endif
" Mark done {{{2 " Mark done {{{2

View File

@@ -32,7 +32,7 @@ let s:NON_EXISTING_DATE_INSERTED_DO_NOTHING = [
function! s:tc.test_insert_date_normal_mode() function! s:tc.test_insert_date_normal_mode()
call self.data.goto('lorem_ipsum') call self.data.goto('lorem_ipsum')
call todo#txt#prepend_date() call todo#txt#replace_date()
call self.assert_equal(s:DATE_INSERTED, self.data.get('lorem_ipsum')) call self.assert_equal(s:DATE_INSERTED, self.data.get('lorem_ipsum'))
endfunction endfunction
@@ -43,40 +43,40 @@ function! s:tc.test_insert_date_insert_mode()
endfunction endfunction
function! s:tc.test_insert_date_visual_mode() function! s:tc.test_insert_date_visual_mode()
call self.data.visual_execute('call todo#txt#prepend_date()', 'lorem_ipsum') call self.data.visual_execute('call todo#txt#replace_date()', 'lorem_ipsum')
call self.assert_equal(s:DATE_INSERTED, self.data.get('lorem_ipsum')) call self.assert_equal(s:DATE_INSERTED, self.data.get('lorem_ipsum'))
endfunction endfunction
function! s:tc.test_insert_date_after_priority_normal_mode() function! s:tc.test_insert_date_after_priority_normal_mode()
call self.data.execute('call todo#txt#prepend_date()', 'date_after_priority') call self.data.execute('call todo#txt#replace_date()', 'date_after_priority')
call self.assert_equal(s:DATE_INSERTED_AFTER_PRIORITY, self.data.get('date_after_priority')) call self.assert_equal(s:DATE_INSERTED_AFTER_PRIORITY, self.data.get('date_after_priority'))
endfunction endfunction
function! s:tc.test_insert_date_after_priority_visual_mode() function! s:tc.test_insert_date_after_priority_visual_mode()
call self.data.visual_execute('call todo#txt#prepend_date()', 'date_after_priority_visual') call self.data.visual_execute('call todo#txt#replace_date()', 'date_after_priority_visual')
call self.assert_equal(s:DATE_INSERTED_AFTER_PRIORITY_VISUAL, self.data.get('date_after_priority_visual')) call self.assert_equal(s:DATE_INSERTED_AFTER_PRIORITY_VISUAL, self.data.get('date_after_priority_visual'))
endfunction endfunction
function! s:tc.test_insert_with_existing_date() function! s:tc.test_insert_with_existing_date()
call self.data.execute('call todo#txt#prepend_date()', 'existing_date_no_priority') call self.data.execute('call todo#txt#replace_date()', 'existing_date_no_priority')
call self.assert_equal(s:DATE_INSERTED, self.data.get('existing_date_no_priority')) call self.assert_equal(s:DATE_INSERTED, self.data.get('existing_date_no_priority'))
endfunction endfunction
function! s:tc.test_insert_with_existing_date_and_priority() function! s:tc.test_insert_with_existing_date_and_priority()
call self.data.execute('call todo#txt#prepend_date()', 'existing_date_after_priority') call self.data.execute('call todo#txt#replace_date()', 'existing_date_after_priority')
call self.assert_equal(s:DATE_INSERTED_AFTER_PRIORITY, self.data.get('existing_date_after_priority')) call self.assert_equal(s:DATE_INSERTED_AFTER_PRIORITY, self.data.get('existing_date_after_priority'))
endfunction endfunction
function! s:tc.test_insert_with_existing_date_and_priority() function! s:tc.test_insert_with_existing_date_and_priority()
let g:todo_existing_date = 'n' let g:todo_existing_date = 'n'
call self.data.execute('call todo#txt#prepend_date()', 'existing_date_do_nothing') call self.data.execute('call todo#txt#replace_date()', 'existing_date_do_nothing')
call self.assert_equal(s:DATE_INSERTED_DO_NOTHING, self.data.get('existing_date_do_nothing')) call self.assert_equal(s:DATE_INSERTED_DO_NOTHING, self.data.get('existing_date_do_nothing'))
unlet g:todo_existing_date unlet g:todo_existing_date
endfunction endfunction
function! s:tc.test_insert_with_existing_date_and_priority() function! s:tc.test_insert_with_existing_date_and_priority()
let g:todo_existing_date = 'n' let g:todo_existing_date = 'n'
call self.data.execute('call todo#txt#prepend_date()', 'non_existing_date_do_nothing') call self.data.execute('call todo#txt#replace_date()', 'non_existing_date_do_nothing')
call self.assert_equal(s:NON_EXISTING_DATE_INSERTED_DO_NOTHING, self.data.get('non_existing_date_do_nothing')) call self.assert_equal(s:NON_EXISTING_DATE_INSERTED_DO_NOTHING, self.data.get('non_existing_date_do_nothing'))
unlet g:todo_existing_date unlet g:todo_existing_date
endfunction endfunction