From 92322e7064bd4f6a7c98cf4cce367b92df3cc38c Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Fri, 13 Apr 2012 10:47:56 +0200 Subject: [PATCH 1/3] Accept filters for listcon, too. This has been implemented for listproj already, for consistency in use and implementation, the same should be available for listcon, too. --- tests/t1310-listcon.sh | 10 ++++++++++ todo.sh | 10 ++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/t1310-listcon.sh b/tests/t1310-listcon.sh index b3d8d8a..9e44def 100755 --- a/tests/t1310-listcon.sh +++ b/tests/t1310-listcon.sh @@ -55,6 +55,16 @@ test_todo_session 'listcon e-mail address test' < todo.txt <>> todo.sh listcon +landscape +@garden +EOF + cat > todo.txt < Date: Fri, 13 Apr 2012 10:51:43 +0200 Subject: [PATCH 2/3] FIX: Mention filter capability in long help for listproj. This was forgotten in the original enhancement in b824479. --- todo.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/todo.sh b/todo.sh index 1c159a8..23adf9c 100755 --- a/todo.sh +++ b/todo.sh @@ -246,10 +246,11 @@ help() Hides all tasks that contain TERM(s) preceded by a minus sign (i.e. -TERM). - listproj - lsprj + listproj [TERM...] + lsprj [TERM...] Lists all the projects (terms that start with a + sign) in todo.txt. + If TERM specified, considers only tasks that contain TERM(s). move ITEM# DEST [SRC] mv ITEM# DEST [SRC] From e5e31b0f75fb7c58113f4be3e09a3e8d52c6b7a7 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Fri, 13 Apr 2012 21:16:33 +0200 Subject: [PATCH 3/3] Refactoring: Extract listWordsWithSigil() from listcon and listproj. --- todo.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/todo.sh b/todo.sh index 23adf9c..200143a 100755 --- a/todo.sh +++ b/todo.sh @@ -860,7 +860,17 @@ _format() fi } -export -f cleaninput getPrefix getTodo getNewtodo shellquote filtercommand _list getPadding _format die +listWordsWithSigil() +{ + sigil=$1 + shift + + FILE=$TODO_FILE + [ "$TODOTXT_SOURCEVAR" ] && eval "FILE=$TODOTXT_SOURCEVAR" + eval "$(filtercommand 'cat "${FILE[@]}"' '' "$@")" | grep -o "[^ ]*${sigil}[^ ]\\+" | grep "^$sigil" | sort -u +} + +export -f cleaninput getPrefix getTodo getNewtodo shellquote filtercommand _list listWordsWithSigil getPadding _format die # == HANDLE ACTION == action=$( printf "%s\n" "$ACTION" | tr 'A-Z' 'a-z' ) @@ -1135,17 +1145,13 @@ case $action in ;; "listcon" | "lsc" ) - FILE=$TODO_FILE - [ "$TODOTXT_SOURCEVAR" ] && eval "FILE=$TODOTXT_SOURCEVAR" shift - eval "$(filtercommand 'cat "${FILE[@]}"' '' "$@")" | grep -o '[^ ]*@[^ ]\+' | grep '^@' | sort -u + listWordsWithSigil '@' "$@" ;; "listproj" | "lsprj" ) - FILE=$TODO_FILE - [ "$TODOTXT_SOURCEVAR" ] && eval "FILE=$TODOTXT_SOURCEVAR" shift - eval "$(filtercommand 'cat "${FILE[@]}"' '' "$@")" | grep -o '[^ ]*+[^ ]\+' | grep '^+' | sort -u + listWordsWithSigil '+' "$@" ;; "listpri" | "lsp" )