From 4008a64fdd10c7f0d2b3d5b2ffdf83bf9b47a99c Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 31 Aug 2015 16:54:18 -0400 Subject: [PATCH] Virtual Tags: New 'PROJECT', 'PRIORITY' and 'LATEST' virtual tags - Added documentation. --- ChangeLog | 2 +- NEWS | 2 +- doc/man/task.1.in | 4 +++ src/Task.cpp | 60 ++++++++++++++++++++++------------------ src/commands/CmdInfo.cpp | 2 ++ src/feedback.cpp | 41 +++++++++++++++------------ 6 files changed, 64 insertions(+), 47 deletions(-) diff --git a/ChangeLog b/ChangeLog index eb7a5f6d4..450c389c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -153,7 +153,7 @@ Shahaf). - When multiple tasks are 'edit'ed, a failure causes the editing to stop (thanks to Daniel Shahaf). -- New 'UDA' and 'ORPHAN' virtual tags. +- New 'UDA', 'ORPHAN', 'PROJECT', 'PRIORITY' and 'LATEST' virtual tags. - Commands that do not accept filters or modifications now generate an error when extra arguments are specified. - Improved zsh support (thanks to Daniel Shahaf). diff --git a/NEWS b/NEWS index 17d205b01..eba7e0021 100644 --- a/NEWS +++ b/NEWS @@ -3,7 +3,7 @@ New Features in Taskwarrior 2.4.5 - The active context, if one is set, is now identified in "task context list" - It is an error to attempt adding or removing a virtual tag. - - New 'UDA' and 'ORPHAN' virtual tags. + - New 'UDA', 'ORPHAN', 'PROJECT', 'PRIORITY' and 'LATEST' virtual tags. New commands in Taskwarrior 2.4.5 diff --git a/doc/man/task.1.in b/doc/man/task.1.in index 11d33e5b1..7dc99a625 100644 --- a/doc/man/task.1.in +++ b/doc/man/task.1.in @@ -665,11 +665,14 @@ are: DELETED Matches if the task has deleted status DUE Matches if the task is due DUETODAY Matches if the task is due today + LATEST Matches if the task is the newest added task MONTH Matches if the task is due this month ORPHAN Matches if the task has any orphaned UDA values OVERDUE Matches if the task is overdue PARENT Matches if the task is a parent PENDING Matches if the task has pending status + PRIORITY Matches if the task has a priority + PROJECT Matches if the task has a project READY Matches if the task is actionable SCHEDULED Matches if the task is scheduled TAGGED Matches if the task has tags @@ -682,6 +685,7 @@ are: WEEK Matches if the task is due this week YEAR Matches if the task is due this year YESTERDAY Matches if the task was due sometime yesterday + .\" If you update the above list, update src/commands/CmdInfo.cpp and src/commands/CmdTags.cpp as well. You can use +BLOCKED to filter blocked tasks, or -BLOCKED for unblocked tasks. diff --git a/src/Task.cpp b/src/Task.cpp index a28034180..ff3725a8b 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -32,6 +32,7 @@ #include #ifdef PRODUCT_TASKWARRIOR #include +#include #include #endif #include @@ -1170,35 +1171,40 @@ bool Task::hasTag (const std::string& tag) const // Synthetic tags - dynamically generated, but do not occupy storage space. // Note: This list must match that in CmdInfo::execute. // Note: This list must match that in ::feedback_reserved_tags. - if (tag == "BLOCKED") return is_blocked; - if (tag == "UNBLOCKED") return !is_blocked; - if (tag == "BLOCKING") return is_blocking; + if (isupper (tag[0])) + { + if (tag == "BLOCKED") return is_blocked; + if (tag == "UNBLOCKED") return !is_blocked; + if (tag == "BLOCKING") return is_blocking; #ifdef PRODUCT_TASKWARRIOR - if (tag == "READY") return is_ready (); - if (tag == "DUE") return is_due (); - if (tag == "DUETODAY") return is_duetoday (); - if (tag == "TODAY") return is_duetoday (); - if (tag == "YESTERDAY") return is_dueyesterday (); - if (tag == "TOMORROW") return is_duetomorrow (); - if (tag == "OVERDUE") return is_overdue (); - if (tag == "WEEK") return is_dueweek (); - if (tag == "MONTH") return is_duemonth (); - if (tag == "YEAR") return is_dueyear (); + if (tag == "READY") return is_ready (); + if (tag == "DUE") return is_due (); + if (tag == "DUETODAY") return is_duetoday (); + if (tag == "TODAY") return is_duetoday (); + if (tag == "YESTERDAY") return is_dueyesterday (); + if (tag == "TOMORROW") return is_duetomorrow (); + if (tag == "OVERDUE") return is_overdue (); + if (tag == "WEEK") return is_dueweek (); + if (tag == "MONTH") return is_duemonth (); + if (tag == "YEAR") return is_dueyear (); #endif - if (tag == "ACTIVE") return has ("start"); - if (tag == "SCHEDULED") return has ("scheduled"); - if (tag == "CHILD") return has ("parent"); - if (tag == "UNTIL") return has ("until"); - if (tag == "ANNOTATED") return hasAnnotations (); - if (tag == "TAGGED") return has ("tags"); - if (tag == "PARENT") return has ("mask"); - if (tag == "WAITING") return get ("status") == "waiting"; - if (tag == "PENDING") return get ("status") == "pending"; - if (tag == "COMPLETED") return get ("status") == "completed"; - if (tag == "DELETED") return get ("status") == "deleted"; - if (tag == "UDA") return is_udaPresent (); - if (tag == "ORPHAN") return is_orphanPresent (); - if (tag == "LATEST") return id == context.tdb2.latest_id (); + if (tag == "ACTIVE") return has ("start"); + if (tag == "SCHEDULED") return has ("scheduled"); + if (tag == "CHILD") return has ("parent"); + if (tag == "UNTIL") return has ("until"); + if (tag == "ANNOTATED") return hasAnnotations (); + if (tag == "TAGGED") return has ("tags"); + if (tag == "PARENT") return has ("mask"); + if (tag == "WAITING") return get ("status") == "waiting"; + if (tag == "PENDING") return get ("status") == "pending"; + if (tag == "COMPLETED") return get ("status") == "completed"; + if (tag == "DELETED") return get ("status") == "deleted"; + if (tag == "UDA") return is_udaPresent (); + if (tag == "ORPHAN") return is_orphanPresent (); + if (tag == "LATEST") return id == context.tdb2.latest_id (); + if (tag == "PROJECT") return has ("project"); + if (tag == "PRIORITY") return has ("priority"); + } // Concrete tags. std::vector tags; diff --git a/src/commands/CmdInfo.cpp b/src/commands/CmdInfo.cpp index 3870b1147..537a63810 100644 --- a/src/commands/CmdInfo.cpp +++ b/src/commands/CmdInfo.cpp @@ -338,6 +338,8 @@ int CmdInfo::execute (std::string& output) if (task.hasTag ("YEAR")) virtualTags += "YEAR "; if (task.hasTag ("YESTERDAY")) virtualTags += "YESTERDAY "; if (task.hasTag ("LATEST")) virtualTags += "LATEST "; + if (task.hasTag ("PROJECT")) virtualTags += "PROJECT "; + if (task.hasTag ("PRIORITY")) virtualTags += "PRIORITY "; // If you update the above list, update src/commands/CmdInfo.cpp and src/commands/CmdTags.cpp as well. row = view.addRow (); diff --git a/src/feedback.cpp b/src/feedback.cpp index e7419c68b..cc55fb474 100644 --- a/src/feedback.cpp +++ b/src/feedback.cpp @@ -357,30 +357,35 @@ void feedback_reserved_tags (const std::string& tag) { // Note: This list must match that in Task::hasTag. // Note: This list must match that in CmdInfo::execute. - if (tag == "BLOCKED" || - tag == "UNBLOCKED" || + if (tag == "ACTIVE" || + tag == "ANNOTATED" || + tag == "BLOCKED" || tag == "BLOCKING" || - tag == "READY" || + tag == "CHILD" || + tag == "COMPLETED" || + tag == "DELETED" || tag == "DUE" || tag == "DUETODAY" || - tag == "TODAY" || - tag == "YESTERDAY" || - tag == "TOMORROW" || - tag == "OVERDUE" || - tag == "WEEK" || + tag == "LATEST" || tag == "MONTH" || - tag == "YEAR" || - tag == "ACTIVE" || - tag == "SCHEDULED" || - tag == "CHILD" || - tag == "UNTIL" || - tag == "ANNOTATED" || - tag == "TAGGED" || + tag == "ORPHAN" || + tag == "OVERDUE" || tag == "PARENT" || - tag == "WAITING" || tag == "PENDING" || - tag == "COMPLETED" || - tag == "DELETED") + tag == "PRIORITY" || + tag == "PROJECT" || + tag == "READY" || + tag == "SCHEDULED" || + tag == "TAGGED" || + tag == "TODAY" || + tag == "TOMORROW" || + tag == "UDA" || + tag == "UNBLOCKED" || + tag == "UNTIL" || + tag == "WAITING" || + tag == "WEEK" || + tag == "YEAR" || + tag == "YESTERDAY") { throw format (STRING_FEEDBACK_TAG_VIRTUAL, tag); }