From c429b062cf76368989c9f6ef830b9b7652ff2487 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Tue, 10 May 2011 15:20:29 +0200 Subject: [PATCH] BUG: listpri picked up non-priority patterns. The regexp for the priority wasn't anchored to the beginning of the task. (As the filtering is done inside the _list pipeline, the task number has already been prepended.) Also, by passing the regexp directly to _list, a case-insensitive search was performed, so despite [A-Z], lowercase characters were picked up, too. Need to make use of post_filter_command to inject a separate, case-sensitive grep into the pipeline. Bonus: Added test for highlighting of listpri command. --- tests/t1250-listpri.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ todo.sh | 4 ++-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/tests/t1250-listpri.sh b/tests/t1250-listpri.sh index ea6b63d..b01ad73 100755 --- a/tests/t1250-listpri.sh +++ b/tests/t1250-listpri.sh @@ -26,4 +26,46 @@ TODO: 0 of 3 tasks shown -- TODO: 1 of 3 tasks shown EOF + +test_todo_session 'listpri highlighting' <>> todo.sh listpri +1 (B) smell the uppercase Roses +flowers @outside +2 (C) notice the sunflowers +-- +TODO: 2 of 3 tasks shown +EOF + +cat > todo.txt <>> todo.sh -p listpri +1 (B) smell the uppercase Roses +flowers @outside +2 (C) notice the sunflowers +-- +TODO: 2 of 5 tasks shown + +>>> todo.sh -p listpri b +1 (B) smell the uppercase Roses +flowers @outside +-- +TODO: 1 of 5 tasks shown + +>>> todo.sh -p listpri c +2 (C) notice the sunflowers +-- +TODO: 1 of 5 tasks shown + +>>> todo.sh -p listpri m +-- +TODO: 0 of 5 tasks shown + +>>> todo.sh -p listpri n +-- +TODO: 0 of 5 tasks shown +EOF + test_done diff --git a/todo.sh b/todo.sh index 6a1caef..f24b638 100755 --- a/todo.sh +++ b/todo.sh @@ -1022,9 +1022,9 @@ note: PRIORITY must a single letter from A to Z." ## No priority specified; show all priority tasks pri="[A-Z]" fi - pri="($pri)" - _list "$TODO_FILE" "$pri" + post_filter_command="grep '^ *[0-9]\+ (${pri}) '" + _list "$TODO_FILE" ;; "move" | "mv" )