diff options
author | Lukas Fleischer <lfleischer@calcurse.org> | 2016-01-11 22:26:46 +0100 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2016-01-13 17:39:44 +0100 |
commit | 7f8c62bf57b85234c248316505a503602792839a (patch) | |
tree | ef8ff6e778840192ee7cfb6c06579602ed6942cb /src/io.c | |
parent | dd85a7374675c3f91e215c2e318b2c5045a01f53 (diff) | |
download | calcurse-7f8c62bf57b85234c248316505a503602792839a.zip |
Add an option to filter by object hash
Implement a new --filter-hash option to filter by object identifiers.
Each object having an identifier that has the specified pattern as a
prefix is matched. Patterns starting with an exclamation mark (!) are
interpreted as negative patterns.
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/io.c')
-rw-r--r-- | src/io.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -684,8 +684,20 @@ void io_load_todo(struct item_filter *filter) continue; } - todo_add(e_todo, id, note); - ++nb_tod; + struct todo *todo = todo_add(e_todo, id, note); + + /* Filter by hash. */ + if (filter && filter->hash) { + char *hash = todo_hash(todo); + if (!hash_matches(filter->hash, hash)) { + todo_delete(todo); + todo = NULL; + } + mem_free(hash); + } + + if (todo) + ++nb_tod; } file_close(data_file, __FILE_POS__); } |