Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

追加コマンドにオプションを用意

  • Loading branch information...
commit 1e49ba13b970a474aaa603e96e6b58590067c21b 1 parent 2256bfc
@kannokanno authored
View
9 README.mkd
@@ -7,6 +7,7 @@ unite-todo is a [unite.vim](https://github.com/Shougo/unite.vim)'s source
## Usage
### TODO新規作成
コマンドラインから入力
+範囲指定の場合は選択された全体に対し、1行1TODOとして追加
:UniteTodoAddSimple
@@ -14,9 +15,11 @@ unite-todo is a [unite.vim](https://github.com/Shougo/unite.vim)'s source
:UniteTodoAddBuffer
-選択された全体に対し、1行1TODOとして追加
-
- :UniteTodoAddRange
+オプションとして以下を使用できる
+* -tag
+ * TODO追加後に続けてtagを入力する
+* -memo
+ * TODO追加後に続けてノートを開く
### TODO一覧を表示
すべてのTODOを表示する
View
5 autoload/unite/kinds/todo.vim
@@ -16,8 +16,7 @@ let s:kind = {
let s:kind.action_table.open = { 'description' : 'open note of todo', 'is_selectable': 1 }
function! s:kind.action_table.open.func(candidates)
for candidate in a:candidates
- let todo = unite#todo#struct(candidate.source__line)
- execute ':edit ' . todo.note
+ call unite#todo#open(unite#todo#struct(candidate.source__line))
endfor
endfunction
@@ -25,7 +24,7 @@ let s:kind.action_table.preview = { 'description' : 'preview note' }
function! s:kind.action_table.preview.func(candidate)
let todo = unite#todo#struct(a:candidate.source__line)
if filereadable(todo.note)
- execute ':pedit ' . todo.note
+ execute ':pedit ' . todo.note
endif
endfunction
View
35 autoload/unite/todo.vim
@@ -57,8 +57,34 @@ function! unite#todo#new(id, title)
return unite#todo#struct(join([a:id, '[ ]', a:title], ','))
endfunction
+" TODO dirty
+function! unite#todo#input(args, use_range, line1, line2)
+ let args = split(a:args)
+ let todo_list = a:use_range ?
+ \ unite#todo#add(reverse(getline(a:line1, a:line2))) :
+ \ unite#todo#add([input('Todo:')])
+
+ if count(args, '-tag') > 0
+ for todo in todo_list
+ let tags = unite#todo#trim(input(printf('[%s] Tags(comma separate):', todo.title)))
+ if !empty(tags)
+ let todo.tags = map(split(tags, ','), '"@".v:val')
+ call unite#todo#rename(todo)
+ endif
+ endfor
+ unlet todo
+ endif
+ if count(args, '-memo') > 0
+ for todo in todo_list
+ tabnew
+ call unite#todo#open(todo)
+ endfor
+ endif
+endfunction
+
" TODO もうちょい綺麗に
function! unite#todo#add(title_list)
+ let added = []
let size = len(a:title_list)
if size == 0
echo 'todo is empty'
@@ -66,10 +92,13 @@ function! unite#todo#add(title_list)
for i in range(0, size-1)
let title = unite#todo#trim(a:title_list[i])
if !empty(title)
- call unite#todo#update(insert(unite#todo#all(), unite#todo#new(localtime().'_'.i, title)))
+ let todo = unite#todo#new(localtime().'_'.i, title)
+ call unite#todo#update(insert(unite#todo#all(), todo))
+ call add(added, todo)
endif
endfor
endif
+ return added
endfunction
function! unite#todo#trim(str)
@@ -109,5 +138,9 @@ function! unite#todo#toggle(todo)
call unite#todo#update(list)
endfunction
+function! unite#todo#open(todo)
+ execute ':edit ' . a:todo.note
+endfunction
+
let &cpo = s:save_cpo
unlet s:save_cpo
View
5 plugin/unite-todo.vim
@@ -10,9 +10,8 @@ let g:loaded_unite_todo = 1
let s:save_cpo = &cpo
set cpo&vim
-command! -nargs=0 UniteTodoAddSimple call unite#todo#add([input('Todo:')])
-command! -nargs=0 -range UniteTodoAddRange call unite#todo#add(reverse(getbufline('%', <line1>, <line2>)))
-command! -nargs=0 UniteTodoAddBuffer call unite#todo#add(reverse(getbufline('%', 1, '$')))
+command! -nargs=* -range=0 UniteTodoAddSimple call unite#todo#input(<q-args>, <count>, <line1>, <line2>)
+command! -nargs=* UniteTodoAddBuffer call unite#todo#input(<q-args>, 1, 1, '$')
let &cpo = s:save_cpo
unlet s:save_cpo
Please sign in to comment.
Something went wrong with that request. Please try again.