Commit Graph

245 Commits

Author SHA1 Message Date
Ingo Karkat
0fa5f6d1dd 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.
2011-07-09 13:41:20 -07:00
Ingo Karkat
f8b66f117a ENH: Allow listpri filtering via TERM.
This even simplified the argument handling, since there can be no invalid priority any more; all other strings are taken as TERMs. And the check for empty ${1:-} was superfluous, anyway. Apart from these simplifications, it's basically just passing $@ to _list.
2011-07-09 13:36:14 -07:00
Ingo Karkat
b00ca1074a Simplified check for done task.
Use simple comparison with slice of string (already used e.g. in _list()) instead of grep -c pipeline.

Closes #42
2011-07-07 23:29:45 -07:00
Ingo Karkat
a60dfb668d Perform cleaninput() filtering without tr.
Again, Bash's global pattern substitution can be used. This only depends on the "extquote" shell option, which is set by default, but we set this just to be sure.
2011-07-07 23:14:11 -07:00
Ingo Karkat
899687f0ef BUG: Multiple whitespace was condensed, CR/LF not turned to space.
Missing quoting inside cleaninput() condensed multiple subsequent spaces into a single space, even when the user took pains to preserve whitespace by properly quoting the task in the shell.
The 'tr' command completely removed CR and LF characters instead of replacing them with a single space.
Add test cases for the whitespace handling to the add, append, prepend and replace actions.
2011-07-07 23:14:11 -07:00
Ingo Karkat
301dbcf297 Expose cleaninput() for use in addons.
Despite its hard-coded use of $input, this can be useful in addons, too.
(I, for example, use this in a "todo.sh subst" addon that delegates to the "todo.sh replace" action after performing a sed-style replacement on the passed pattern and replacement.)
2011-07-07 23:13:47 -07:00
Ingo Karkat
e79b1629f5 Perform cleaninput() escaping without sed.
No need for invoking sed; Bash's global pattern substitution can be used.
2011-07-07 23:13:47 -07:00
Ingo Karkat
a4db95166d Escape the substitution separator in cleaninput().
Improving on the previous fix and commit, no search for an unused substitution separator is actually needed; sed supports escaping of the substitution separator. Revert the $inputSep abstraction in favor of the former, hard-coded "|" character.
2011-07-07 23:13:47 -07:00
Ingo Karkat
afe6d9dfd5 FIX: cleaninput() for sed-replacement needs more escaping and unique separator.
Commit 8e4364f5e1 removed the deletion of the "|" character from cleaninput. That was okay for the cleaninput() use in _addto(), but not in those cases that used $input for replacement via sed.

Added corresponding tests for replace, append and prepend actions similar to what was added for the add action in the above commit.

To really fix the problem (and not just remove all "|" characters from the text), a separator character must be found that is not part of $input, and this must be used in the sed expression. As cleaninput() already modifies the global $input variable, another $inputSep global variable is used to pass back this information.

In addition, backslashes must be escaped in $input, or replacements like \1 wreak havoc.
2011-07-07 23:13:47 -07:00
Ingo Karkat
ab705cd670 Configure cleaninput() sed-escaping via argument instead of magic words.
Encoding the actions that require the additional sed-escaping inside cleaninput() is cumbersome and error-prone. Instead, let the calling action tell cleaninput() that it wants this.
2011-07-07 23:13:47 -07:00
Ingo Karkat
e0ad2292a2 Remove no-op passing of $input to cleaninput().
The function actually uses and modifies the global variable directly.
2011-07-07 23:12:35 -07:00
Ingo Karkat
c4670b6502 Made replace test sessions independent from each other.
When the tests depend on the todo.txt contents from the previous sessions, errors will cascade and make it more difficult to pinpoint the problem.
2011-07-07 23:12:35 -07:00
Tom Scogland
7900ad7e1b Added sed line to allow priorities to be added on the command line with auto add date enabled.
Inserted test for this case in the t1010-add-date.sh test case.
2011-07-07 22:55:08 -07:00
Archimedes Trajano
e24777fa2c Changed backquotes to use $() instead.
$(...) has superceded the `...` notation.  This can be found by
searching in Google "command substitution superseded"

Closes #28
2011-07-07 22:05:11 -07:00
Devon Jones
dae6f2bcaf Environment variables override config, flags override environment variables
* Added more flags to give action developers more control over commands
that are leveraged inside their actions.
* Writing a better message for the help screen
2011-02-14 10:14:17 -08:00
Archimedes Trajano
0c5bdf3b0a Added quotes to dirname call.
This allows the todo.sh to exist in a path with spaces.
2011-02-14 10:11:32 -08:00
Matt Henkel
5afd734dcb Change the default TODO_DIR so that it's the same as the todo.sh dir.
This change makes todo.sh work out-of-the-box, and allows for excellent portable usage within Dropbox or on a flash drive.
2011-02-14 10:11:32 -08:00
Matt Henkel
990bc293ba Todo.sh will now check for the config in the same directory as the script--if it's not specified or found in HOME.
This is really nice if todo.sh is kept in dropbox and accessed from multiple computers.
2011-02-14 10:11:32 -08:00
Nick Wilson
8e4364f5e1 Fix erroneously removing pipe chars from input
cleaninput() unintentionally deletes the '|' character from input.  This
commit fixes it and adds test for adding tasks with a bunch of symbols.
2011-01-31 21:07:35 -08:00
Nick Wilson
f1d339a537 Fix substitution for hiding contexts/projects
When using the -+ or -@ option to hide project or context names in list
output, the color reset sequence was being deleted if the project/context
was at the end of the line.

For example, with the following tasks:

    (B) with priority, ending in a +project
    task that shouldn't be highlighted

Running 'todo.sh -+ list' would hide the "+project" from the first task,
but would also remove the color reset sequence ^[[0m at the end.  The
color from the prioritized task would continue to the next lines.

This commit fixes the problem and adds a test to verify the fix.
2011-01-23 16:09:09 -08:00
Gina Trapani
82c8349499 Merge branch 'inkarkat/master'
* inkarkat/master:
  Cosmetics: Corrected inconsistent indentation.
  Skipping 'nonexecutable action' test on Cygwin.
  Factored out generation of custom action scripts.
  Fixed test environment for escaped test output.
  MINOR: Removed unnecessary empty & reference in sed substitution.
  Avoiding todo.sh help error when .todo.actions.d contains subdirs.
  BUG: interpretation of \033 escape sequences in task
  BUG: task listing aborted on embedded \c escape sequence
  BUG: tr: extra operand `d' error caused by missing quoting
2011-01-20 10:24:20 -08:00
Ingo Karkat
9a5668a51c Cosmetics: Corrected inconsistent indentation. 2011-01-20 16:08:20 +01:00
Ingo Karkat
a82fd58363 Skipping 'nonexecutable action' test on Cygwin.
On Cygwin, clearing the executable flag may have no effect, as the Windows ACL may still grant execution rights. In this case, we skip the test instead of failing.
2011-01-20 15:34:46 +01:00
Ingo Karkat
819a8285cc Factored out generation of custom action scripts.
- Reduced duplication via common make_action() function.
- ENH: Adding proper shebang line to the custom action scripts.
- Changed output of custom action to better differentiate from todo.sh output.
2011-01-20 15:07:47 +01:00
Ingo Karkat
2df5f9fee9 Fixed test environment for escaped test output.
- test-lib uses 'read -r' to parse the test session input literally, without interpretation of backslashes.
- FIX: Use quoting to maintain original whitespace (tabs and multiple spaces) from the test session input (instead of condensing into a single space).
- Using Bash instead of POSIX shell for t1340-listescapes.sh, so that the interpretation of escape sequences is not dependent on the POSIX shell being used.
- Changed Makefile so that the shell selected by the shebang line is actually used when invoking tests, not the POSIX shell.
- Above changes obsolete the multiple escaping of the test session data; now, the test session can actually be pasted as-is into a test script, even when it contains backslashes. (I.e. works as expected now.)
2011-01-20 13:23:06 +01:00
Gina Trapani
07baa2c1bd Added GPL license 2011-01-18 20:32:23 -08:00
Ingo Karkat
a117b7cb3c MINOR: Removed unnecessary empty & reference in sed substitution. 2010-12-30 23:19:57 +01:00
Ingo Karkat
9760ee23c7 Avoiding todo.sh help error when .todo.actions.d contains subdirs.
I have placed tests for my custom todo actions in ~/.todo.actions.d/tests/; this causes a ".../.todo.actions.d/tests: is a directory" error on todo.sh help.
Added condition for regular files to the executable check in order to exclude subdirectories.
2010-10-21 12:27:30 +02:00
Ingo Karkat
ce501c5362 BUG: interpretation of \033 escape sequences in task
The global substitution in the AWK highlighting of prioritized and done tasks also affected the task text itself, not just the inserted color definitions.
Factored out the evaluation of the color variables and interpretation of \033 into a highlight() AWK function.
Added test cases which check that \a, \t, \n, \x.. and \0.. escape characters in the task text are listed as-is, without interpretation.
2010-10-21 11:30:31 +02:00
Ingo Karkat
824101defd BUG: task listing aborted on embedded \c escape sequence
Fixed by removing the -e option that causes the echo command to interpret escape characters. Coloring of done tasks (the only step in the _list pipeline that required this interpretation) has been moved into the AWK pipeline step which is responsible for the priority coloring, and which does the escape character interpretation internally.
As a nice side effect, this shortening of the _list pipeline should also speed up the listing a wee bit.
2010-10-21 10:26:45 +02:00
Ingo Karkat
194a062c2d BUG: tr: extra operand `d' error caused by missing quoting
Reported by Bill Goffe on the todotxt mailing list.
2010-08-09 08:06:09 +02:00
Ingo Karkat
94325f57cd Improved color map instructions.
Clarified the use of ANSI escape codes.
Added motivation why to change, e.g. when using Conky.
Added requirement to uncomment color defaults when changing the color map, based on a support request on the mailing list.
v2.7.0 v2.7
2010-07-17 21:29:55 +02:00
Ingo Karkat
938bbc1ec2 Aligned PRI_X comment with updated one in config.
As an addendum to commit 9b7f85bea1.
2010-07-17 09:47:39 +02:00
Ingo Karkat
99f8911c8f Added fallback for $TODO_DIR/${FILE}.txt.
This allows to leave off the .txt file extension in commands like "todo.sh listfile done".
Plus: Minor coding style alignment, replaced $1 argument with existing $FILE variable.
2010-07-16 16:15:45 +02:00
Ingo Karkat
f5d4249078 ENH: Added highlighting of done (but not yet archived) tasks.
This makes done tasks more stand out (like prioritized tasks) in the task list. Default highlighting is LIGHT_GREY, which seems to be modest and go well with the assumed dark terminal background.
Reintroduced the OSX-compatible sed filter that was introduced by commit 8b7e2e6aad and superseded by the PRI_X coloring generalization.
2010-07-15 16:14:46 +02:00
Ingo Karkat
9b7f85bea1 Config file addendum to generalization of PRI_X color support.
Adapts the config file comments to the generalization of PRI_X color support to all priorities (commit e7b5841721).
2010-07-15 15:19:38 +02:00
Ingo Karkat
a7afc7917d Minor: aligned capitalization in fatal error message. 2010-07-15 15:19:24 +02:00
Ingo Karkat
4d29e68e89 Aligned "no such task" error message with verbose messages.
The message now also starts with "TODO:", like all other messages (except for the usage messages).
Before: 42: No such task.
After:  TODO: No task 42.
2010-07-15 13:48:24 +02:00
Ingo Karkat
b383b1f0c5 Aligned verbose message output of tasks with normal task output.
I.e. removed the colon after the ITEM#. Updated tasks are now listed like the 'todo.sh ls' command does, e.g.
    42 smell the roses
This is in preparation to eventually use a function factored out from _list() for the verbose task output, which would enable coloring in the verbose message and thus align the verbose message output even more with the normal task output.
2010-07-14 18:01:39 +02:00
Ingo Karkat
8a95a66749 Using die() for some more error messages. 2010-07-14 17:31:11 +02:00
Ingo Karkat
83053fd0c1 Better verbose messages for 'replace' and 'del TERM'.
Added "TODO:" prefix and simplified messages.
2010-07-14 17:18:57 +02:00
Ingo Karkat
74fa07d26a Aligned implementations of verbose output.
Replaced multi-line [ ] && { ... } with if-then.
2010-07-14 16:47:03 +02:00
Ingo Karkat
3e597ce20e Merge commit 'upstream/master' 2010-07-13 18:15:54 +02:00
Ingo Karkat
da466c9361 Improved 'move' command.
- Removed (accidental) printing of the task (without leading ITEM#) when checking for existence of the task; using empty check of task text as done elsewhere.
- Simplified error handling and using die() for proper exit code.
- Aligned verbose move message with the verbose output of other commands.
2010-07-13 18:11:05 +02:00
Ingo Karkat
72caab8bbd Added test for del preserving line numbers. 2010-07-13 17:49:40 +02:00
Ingo Karkat
7501b225c2 ENH: Improved 'del ITEM# TERM' command.
- Condensing whitespace around TERM into a single space and removing leading/trailing spaces if at the beginning/end of the task.
- Proper error message if TERM not found.
- Aligned verbose removal message with the verbose output of the 'replace' command.
In addition, removed (accidental) printing of the task (without leading ITEM#) when checking for existence of the task; using empty check of task text as done elsewhere.
2010-07-13 17:48:54 +02:00
Ingo Karkat
bcbf93ebe4 Fixed todo.sh del usage and exit code. 2010-07-13 16:18:02 +02:00
Gina Trapani
cea6d07735 Merge branch 'inkarkat/master' 2010-07-13 01:07:24 -07:00
Ingo Karkat
2f4ba26994 ENH: Sentence delimiters for append action.
This fixes a personal annoyance.
If the text to be appended to the task begins with one of the delimiter characters, no whitespace is inserted in between. This makes appending to an enumeration (todo.sh add 42 ", foo") syntactically correct.
The list of delimiters is configurable (for personal preferences / non-English languages) via SENTENCE_DELIMITERS in the config file.
2010-07-05 13:49:58 +02:00
Ingo Karkat
5e44868261 ENH: 'prepend' and 'replace' actions keep prepended date.
Generalized and simplified the logic that already kept an existing priority to also keep a date added via todo.sh -t / TODOTXT_DATE_ON_ADD (unless the replaced text also starts with a date).
2010-07-05 11:24:19 +02:00