diff --git a/ChangeLog b/ChangeLog index bfdcfd9d5..da21de7be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,9 @@ represents a feature release, and the Z represents a patch. (thanks to Vincent Fleuranceau) + Task now allows mixed case attribute names (pri:, PRI:, Pri: ...) and commands (add, ADD, Add ...) (thanks to Vincent Fleuranceau) + + Task now supports a default project and priority for new tasks, via + the new "default.project" and "default.priority" configuration variables + (thanks to Vincent Fleuranceau) ------ old releases ------------------------------ diff --git a/html/config.html b/html/config.html index 609e36d75..c579838f5 100644 --- a/html/config.html +++ b/html/config.html @@ -248,6 +248,16 @@
Colors any task where the description contains X.
+ +
default.project
+
+ Provides a default project name for the "task add ..." command. +
+ +
default.priority
+
+ Provides a default priority for the "task add ..." command. +

diff --git a/html/task.html b/html/task.html index 12882c036..b991cb6ed 100644 --- a/html/task.html +++ b/html/task.html @@ -100,6 +100,9 @@ color is disabled (thanks to Vincent Fleuranceau).
  • Task now allows mixed case attribute names (pri:, PRI:, Pri: ...) and commands (add, ADD, Add ...) (thanks to Vincent Fleuranceau). +
  • Task now supports a default project and priority for new tasks, via + the new "default.project" and "default.priority" configuration variables + (thanks to Vincent Fleuranceau).

    diff --git a/src/command.cpp b/src/command.cpp index 91a3053f2..a9117964d 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -66,6 +66,20 @@ void handleAdd (const TDB& tdb, T& task, Config& conf) task.setAttribute ("mask", ""); } +/**/ + // Override with default.project, if not specified. + if (task.getAttribute ("project") == "") + task.setAttribute ("project", conf.get ("default.project", "")); + + // Override with default.priority, if not specified. + if (task.getAttribute ("priority") == "") + { + std::string defaultPriority = conf.get ("default.priority", ""); + if (validPriority (defaultPriority)) + task.setAttribute ("priority", defaultPriority); + } +/**/ + if (task.getDescription () == "") throw std::string ("Cannot add a blank task."); diff --git a/src/parse.cpp b/src/parse.cpp index 4dcd3bdbd..98c376fe2 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -208,7 +208,7 @@ bool validDate (std::string& date, Config& conf) } //////////////////////////////////////////////////////////////////////////////// -static bool validPriority (const std::string& input) +bool validPriority (const std::string& input) { if (input != "H" && input != "M" && diff --git a/src/task.h b/src/task.h index ced6b3c18..7b732f423 100644 --- a/src/task.h +++ b/src/task.h @@ -55,6 +55,7 @@ for (typeof (c) *foreach_p = & (c); \ // parse.cpp void parse (std::vector &, std::string&, T&, Config&); +bool validPriority (const std::string&); bool validDate (std::string&, Config&); // task.cpp