From 99fa15da36ed8cc37640f50bfa718da6fbcd6ac5 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Fri, 23 Sep 2011 15:40:23 +0200 Subject: [PATCH 1/3] BUG: Pattern "(X)" anywhere highlighted as prioritized. According to the "Todo.txt Format" specs, "Rule 1: If a priority exists, it ALWAYS appears first." Adapt AWK filtering to match priorities only directly after the task number added by the _list processing, and also matching the required trailing space. --- tests/t1330-ls-highlighting.sh | 16 ++++++++++++++++ todo.sh | 5 ++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/t1330-ls-highlighting.sh b/tests/t1330-ls-highlighting.sh index aa3db44..d5d0f0e 100755 --- a/tests/t1330-ls-highlighting.sh +++ b/tests/t1330-ls-highlighting.sh @@ -166,4 +166,20 @@ test_todo_session 'highlighting with hidden contexts/projects' < todo.txt <>> todo.sh ls +1 (D) some prioritized task +2 not prioritized +3 should not be seen as PRIORITIZE(D) task +-- +TODO: 3 of 3 tasks shown +EOF + test_done diff --git a/todo.sh b/todo.sh index a21356e..04718ca 100755 --- a/todo.sh +++ b/todo.sh @@ -720,11 +720,10 @@ _list() { return color } { - pos = match($0, /\([A-Z]\)/) if (match($0, /^[0-9]+ x /)) { print highlight("COLOR_DONE") $0 highlight("DEFAULT") - } else if (pos > 0) { - clr = highlight("PRI_" substr($0, pos+1, 1)) + } else if (match($0, /^[0-9]+ \([A-Z]\)[[:space:]]/)) { + clr = highlight("PRI_" substr($0, RSTART + RLENGTH - 3, 1)) print ( clr ? clr : highlight("PRI_X") ) $0 highlight("DEFAULT") } else { print } } From 227b9d2c0a1fa370cf4e96dfc78876d7f2e30d98 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Fri, 23 Sep 2011 16:27:30 +0200 Subject: [PATCH 2/3] BUG: Pattern "(X) " anywhere hidden with -P. The regular expression HIDE_PRIORITY_SUBSTITUTION is not anchored, so strings that look like a priority but are not at the beginning are filtered, too. Anchoring the regexp in the step after the highlighting has been applied is problematic due to the prepended dynamic priority highlighting string, and it also cannot be done before that because highlighting needs the information. Therefore, the filtering is moved into the AWK highlighting itself. --- tests/t1300-ls.sh | 24 ++++++++++++------------ todo.sh | 6 ++++-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/tests/t1300-ls.sh b/tests/t1300-ls.sh index a374c5b..7a18fde 100755 --- a/tests/t1300-ls.sh +++ b/tests/t1300-ls.sh @@ -142,7 +142,7 @@ cat > todo.txt < todo.txt < Date: Thu, 3 Nov 2011 18:37:36 +0100 Subject: [PATCH 3/3] Revert to safer POSIX AWK regexp. AWK from Ubuntu 8.04 (mawk) doesn't support [[:space:]]; so for backwards compatibility use a plain ASCII space instead. --- todo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/todo.sh b/todo.sh index b256738..4ab322c 100755 --- a/todo.sh +++ b/todo.sh @@ -722,7 +722,7 @@ _list() { { if (match($0, /^[0-9]+ x /)) { print highlight("COLOR_DONE") $0 highlight("DEFAULT") - } else if (match($0, /^[0-9]+ \([A-Z]\)[[:space:]]/)) { + } else if (match($0, /^[0-9]+ \([A-Z]\) /)) { clr = highlight("PRI_" substr($0, RSTART + RLENGTH - 3, 1)) print \ (clr ? clr : highlight("PRI_X")) \