From 9e13dfd2907d92bf6b400afb5edcbd65c4eb3c44 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Tue, 21 Feb 2012 12:11:45 +0100 Subject: [PATCH] ENH: TODOTXT_SOURCEVAR enables different source file for listcon. To be used by todo_completion (to offer candidates from done.txt when there are no matches in todo.txt), and maybe by custom addons. --- tests/t1310-listcon.sh | 19 +++++++++++++++++++ todo.sh | 7 +++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/t1310-listcon.sh b/tests/t1310-listcon.sh index 4ea6756..c96ea27 100755 --- a/tests/t1310-listcon.sh +++ b/tests/t1310-listcon.sh @@ -55,4 +55,23 @@ test_todo_session 'listcon e-mail address test' < todo.txt < done.txt <>> TODOTXT_SOURCEVAR=\$DONE_FILE todo.sh listcon +@done01 +@done02 +EOF +test_todo_session 'listcon from combined open + done tasks' <<'EOF' +>>> TODOTXT_SOURCEVAR='("$TODO_FILE" "$DONE_FILE")' todo.sh listcon +@con01 +@done01 +@done02 +EOF + test_done diff --git a/todo.sh b/todo.sh index 070f865..d93c619 100755 --- a/todo.sh +++ b/todo.sh @@ -136,7 +136,7 @@ help() EndOptionsHelp - [ $TODOTXT_VERBOSE -gt 1 ] && cat <<-EndVerboseHelp + [ $TODOTXT_VERBOSE -gt 1 ] && cat <<-'EndVerboseHelp' Environment variables: TODOTXT_AUTO_ARCHIVE is same as option -a (0)/-A (1) TODOTXT_CFG_FILE=CONFIG_FILE is same as option -d CONFIG_FILE @@ -149,6 +149,7 @@ help() TODOTXT_DEFAULT_ACTION="" run this when called with no arguments TODOTXT_SORT_COMMAND="sort ..." customize list output TODOTXT_FINAL_FILTER="sed ..." customize list after color, P@+ hiding + TODOTXT_SOURCEVAR=\$DONE_FILE use another source for listcon EndVerboseHelp @@ -1128,7 +1129,9 @@ case $action in ;; "listcon" | "lsc" ) - grep -o '[^ ]*@[^ ]\+' "$TODO_FILE" | grep '^@' | sort -u + FILE=$TODO_FILE + [ "$TODOTXT_SOURCEVAR" ] && eval "FILE=$TODOTXT_SOURCEVAR" + grep -ho '[^ ]*@[^ ]\+' "${FILE[@]}" | grep '^@' | sort -u ;; "listproj" | "lsprj" )