Compare commits

..

2 Commits

Author SHA1 Message Date
Ingo Karkat
b131b3e2d0 Add HIDE_CUSTOM_SUBSTITUTION for customization and add-ons.
Add-ons or users may want to hide parts of the task text from the output.
Though this can already be solved through TODOTXT_FINAL_FILTER, augmenting the configured value is not trivial, and it introduces another SED command into the already long _list() pipeline. Putting an additional HIDE_CUSTOM_SUBSTITUTION into the existing pipeline has hardly any performance implications, and makes the realization of this use case trivial.
2012-01-07 23:06:54 +01:00
Ingo Karkat
d2af44d8d3 BUG: SED error when HIDE_..._SUBSTITUTION contains whitespace.
This error only occurs when add-ons override either HIDE_PROJECTS_SUBSTITUTION or HIDE_CONTEXTS_SUBSTITUTION with a pattern that contains whitespace, not with the values used within todo.sh. But correcting the sloppy quoting doesn't hurt, neither.
2012-01-07 22:53:40 +01:00
2 changed files with 23 additions and 13 deletions

View File

@@ -53,6 +53,18 @@ test_todo_session 'checking TODOTXT_FINAL_FILTER' <<EOF
TODO: 3 of 3 tasks shown TODO: 3 of 3 tasks shown
EOF EOF
#
# check the custom hiding
#
test_todo_session 'checking HIDE_CUSTOM_SUBSTITUTION' <<EOF
>>> HIDE_CUSTOM_SUBSTITUTION='[tT]h' todo.sh ls
2 aaa zzz is line should be first.
3 bbb yyy is line should be second.
1 ccc xxx is line should be ird.
--
TODO: 3 of 3 tasks shown
EOF
# #
# check the filtering of TERM # check the filtering of TERM
# #

14
todo.sh
View File

@@ -199,10 +199,7 @@ help()
list [TERM...] list [TERM...]
ls [TERM...] ls [TERM...]
Displays all tasks that contain TERM(s) sorted by priority with line Displays all tasks that contain TERM(s) sorted by priority with line
numbers. Each task must match all TERMs (logical AND); to display numbers. If no TERM specified, lists entire todo.txt.
tasks that contain any TERM (logical OR), use
"TERM1\|TERM2\|..." (with quotes), or TERM1\\\|TERM2 (unquoted).
If no TERM specified, lists entire todo.txt.
listall [TERM...] listall [TERM...]
lsa [TERM...] lsa [TERM...]
@@ -218,7 +215,7 @@ help()
lf [SRC [TERM...]] lf [SRC [TERM...]]
Displays all the lines in SRC file located in the todo.txt directory, Displays all the lines in SRC file located in the todo.txt directory,
sorted by priority with line numbers. If TERM specified, lists sorted by priority with line numbers. If TERM specified, lists
all lines that contain TERM(s) in SRC file. all lines that contain TERM in SRC file.
Without any arguments, the names of all text files in the todo.txt Without any arguments, the names of all text files in the todo.txt
directory are listed. directory are listed.
@@ -226,7 +223,7 @@ help()
lsp [PRIORITY] [TERM...] lsp [PRIORITY] [TERM...]
Displays all tasks prioritized PRIORITY. Displays all tasks prioritized PRIORITY.
If no PRIORITY specified, lists all prioritized tasks. If no PRIORITY specified, lists all prioritized tasks.
If TERM specified, lists only prioritized tasks that contain TERM(s). If TERM specified, lists only prioritized tasks that contain TERM.
listproj listproj
lsprj lsprj
@@ -815,8 +812,9 @@ _list() {
} }
''' \ ''' \
| sed ''' | sed '''
s/'${HIDE_PROJECTS_SUBSTITUTION:-^}'//g s/'"${HIDE_PROJECTS_SUBSTITUTION:-^}"'//g
s/'${HIDE_CONTEXTS_SUBSTITUTION:-^}'//g s/'"${HIDE_CONTEXTS_SUBSTITUTION:-^}"'//g
s/'"${HIDE_CUSTOM_SUBSTITUTION:-^}"'//g
''' \ ''' \
| eval ${TODOTXT_FINAL_FILTER} \ | eval ${TODOTXT_FINAL_FILTER} \
) )