From 38d75afeffd2e391f84869571a0ab8e0b13a24ba Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Tue, 8 May 2012 10:55:00 +0200 Subject: [PATCH 1/2] BUG: completion of task number didn't remove add date. Need to make match of preceding priority optional. Also tighten patterns for priority and done marker by anchoring them to the front, as the leading task number has already been substituted away. --- tests/t6030-completion-tasks.sh | 2 ++ todo_completion | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/t6030-completion-tasks.sh b/tests/t6030-completion-tasks.sh index 8b344bb..45818db 100755 --- a/tests/t6030-completion-tasks.sh +++ b/tests/t6030-completion-tasks.sh @@ -14,6 +14,7 @@ notice the sunflowers +sunflowers @outside @garden +shared +landscape (C) 2012-02-28 @outside mow the lawn x 2012-02-21 +herbs @oriental buy spices x 2012-02-28 2012-02-21 +slack @home watch tv +2012-02-28 +herbs buy cinnamon @grocer EOF test_todo_completion 'simple task' 'todo.sh list 1' '"1 # simple task"' test_todo_completion 'remove projects and contents from task' 'todo.sh list 2' '"2 # notice the sunflowers"' @@ -21,5 +22,6 @@ test_todo_completion 'keep priority' 'todo.sh list 3' '"3 # (B) smell the flower test_todo_completion 'keep priority and remove timestamp' 'todo.sh list 4' '"4 # (C) mow the lawn"' test_todo_completion 'keep done marker and remove done date' 'todo.sh list 5' '"5 # x buy spices"' test_todo_completion 'keep done marker and remove timestamp and done date' 'todo.sh list 6' '"6 # x watch tv"' +test_todo_completion 'remove add date' 'todo.sh list 7' '"7 # buy cinnamon"' test_done diff --git a/todo_completion b/todo_completion index 3f9d308..31ffc30 100644 --- a/todo_completion +++ b/todo_completion @@ -58,8 +58,8 @@ _todo() # a safety check of the ls action output. local todo=$( \ eval TODOTXT_VERBOSE=0 $_todo_sh '-@ -+ -p -x command ls "^ *${cur} "' | \ - sed -e 's/^ *[0-9]\{1,\} //' -e 's/\((.) \)[0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} /\1/' \ - -e 's/\([xX] \)\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{1,2\}/\1/' \ + sed -e 's/^ *[0-9]\{1,\} //' -e 's/^\((.) \)\{0,1\}[0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} /\1/' \ + -e 's/^\([xX] \)\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{1,2\}/\1/' \ -e 's/[[:space:]]*$//' \ -e '1q' \ ) From a5481990fdc7f462634f308800be7386ef8aec3b Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Tue, 8 May 2012 11:10:22 +0200 Subject: [PATCH 2/2] completion: Add recommendation about where to put alias customization. There was a discussion on the mailing list about upgrades and where to put it. --- todo_completion | 3 +++ 1 file changed, 3 insertions(+) diff --git a/todo_completion b/todo_completion index 31ffc30..e3b5a30 100644 --- a/todo_completion +++ b/todo_completion @@ -85,6 +85,9 @@ complete -F _todo todo.sh # If you define an alias (e.g. "t") to todo.sh, you need to explicitly enable # completion for it, too: #complete -F _todo t +# It is recommended to put this line next to your alias definition in your +# ~/.bashrc (or wherever else you're defining your alias). If you simply +# uncomment it here, you will need to redo this on every todo.txt update! # If you have renamed the todo.sh executable, or if it is not accessible through # PATH, you need to add and use a wrapper completion function, like this: