From 86eef4c1849cc70c99bbef09bca9db19a919fa99 Mon Sep 17 00:00:00 2001 From: Steve Rader Date: Wed, 5 Jan 2011 08:56:28 -0500 Subject: [PATCH] Bug #618 - Applied patch to fix bug #618, so that the configuration setting 'edit.verbose' can be set to 'no' and eliminate the help text when using the 'task edit' command (thanks to Steve Rader). Signed-off-by: Paul Beckingham --- ChangeLog | 3 +++ NEWS | 2 ++ doc/man/task.1 | 3 ++- doc/man/taskrc.5 | 7 +++++ src/Config.cpp | 1 + src/command.cpp | 2 +- src/edit.cpp | 66 ++++++++++++++++++++++++++++++------------------ 7 files changed, 57 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 44d5fb9b1..7f9896a75 100644 --- a/ChangeLog +++ b/ChangeLog @@ -69,6 +69,9 @@ + Applied patch to fix bug #613, so that the summary report and the projects command now consistently show a missing project as "(none)" (thanks to Steve Rader). + + Applied patch to fix bug #618, so that the configuration setting + 'edit.verbose' can be set to 'no' and eliminate the help text when using + the 'task edit' command (thanks to Steve Rader). ------ old releases ------------------------------ diff --git a/NEWS b/NEWS index ea0fdd903..998b27790 100644 --- a/NEWS +++ b/NEWS @@ -44,6 +44,8 @@ New configuration options in taskwarrior 1.9.4 to change the effective first month in the calendar report. - default.due can be specified, and adds a default due date to all added and imported tasks that don't otherwise have a due date. + - edit.verbose can be set to 'off' to eliminated the help text when using + the 'task edit' command. Newly deprecated features in taskwarrior 1.9.4 diff --git a/doc/man/task.1 b/doc/man/task.1 index f1c063595..a1ad950e1 100644 --- a/doc/man/task.1 +++ b/doc/man/task.1 @@ -247,7 +247,8 @@ mistakes. .TP .B edit ID Launches an editor to let you modify all aspects of a task directly. -Use carefully. +In general, this is not the recommended method of modifying tasks, but is +provided for exceptional circumstances. Use carefully. .TP .B append [tags] [attrs] description diff --git a/doc/man/taskrc.5 b/doc/man/taskrc.5 index 96e3558ac..8f8357e9e 100644 --- a/doc/man/taskrc.5 +++ b/doc/man/taskrc.5 @@ -173,6 +173,13 @@ command is used. Taskwarrior will first look for this configuration variable. If found, it is used. Otherwise it will look for the $VISUAL or $EDITOR environment variables, before it defaults to using "vi". +.TP +.B edit.verbose=on +When set to on (the default), helpful explanatory comments are added to the +edited file when using the "task edit ..." command. Setting this to off means +that you would see a smaller, more compact representation of the task, with no +help text. + .SS MISCELLANEOUS .TP diff --git a/src/Config.cpp b/src/Config.cpp index 8440e64a2..51562fcb9 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -66,6 +66,7 @@ std::string Config::defaults = "curses=on # Detects terminal width\n" "defaultwidth=80 # Without detection, assumed width\n" "#editor=vi # Preferred text editor\n" + "edit.verbose=yes # Include comments in files created during task edit\n" "\n" "# Miscellaneous\n" "verbose=yes # Provide extra feedback\n" diff --git a/src/command.cpp b/src/command.cpp index 1a21d8fef..31c00bc8c 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -1153,7 +1153,7 @@ int handleShow (std::string& outs) "export.ical.class echo.command fontunderline gc locking monthsperline " "nag next journal.time journal.time.start.annotation journal.info " "journal.time.stop.annotation project shadow.command shadow.file " - "shadow.notify weekstart editor import.synonym.id import.synonym.uuid " + "shadow.notify weekstart editor edit.verbose import.synonym.id import.synonym.uuid " "complete.all.projects complete.all.tags search.case.sensitive hooks " "active.indicator tag.indicator recurrence.indicator recurrence.limit " "list.all.projects list.all.tags undo.style verbose rule.precedence.color " diff --git a/src/edit.cpp b/src/edit.cpp index e6ee480f0..19a4df070 100644 --- a/src/edit.cpp +++ b/src/edit.cpp @@ -110,22 +110,26 @@ static std::string formatDate ( static std::string formatTask (Task task) { std::stringstream before; - before << "# The 'task edit ' command allows you to modify all aspects of a task\n" - << "# using a text editor. What is shown below is a representation of the\n" - << "# task in all it's detail. Modify what you wish, and if you save and\n" - << "# quit your editor, taskwarrior will read this file and try to make sense\n" - << "# of what changed, and apply those changes. If you quit your editor\n" - << "# without saving or making any modifications, taskwarrior will do nothing.\n" - << "#\n" - << "# Lines that begin with # represent data you cannot change, like ID.\n" - << "# If you get too 'creative' with your editing, taskwarrior will dump you\n" - << "# back into the editor to try again.\n" - << "#\n" - << "# Should you find yourself in an endless Groundhog Day loop, editing and\n" - << "# editing the same file, just quit the editor without making any changes.\n" - << "# Taskwarrior will notice this and stop the editing.\n" - << "#\n" - << "# Name Editable details\n" + bool verbose = context.config.getBoolean ("edit.verbose"); + + if (verbose) + before << "# The 'task edit ' command allows you to modify all aspects of a task\n" + << "# using a text editor. What is shown below is a representation of the\n" + << "# task in all it's detail. Modify what you wish, and if you save and\n" + << "# quit your editor, taskwarrior will read this file and try to make sense\n" + << "# of what changed, and apply those changes. If you quit your editor\n" + << "# without saving or making any modifications, taskwarrior will do nothing.\n" + << "#\n" + << "# Lines that begin with # represent data you cannot change, like ID.\n" + << "# If you get too 'creative' with your editing, taskwarrior will dump you\n" + << "# back into the editor to try again.\n" + << "#\n" + << "# Should you find yourself in an endless Groundhog Day loop, editing and\n" + << "# editing the same file, just quit the editor without making any changes.\n" + << "# Taskwarrior will notice this and stop the editing.\n" + << "#\n"; + + before << "# Name Editable details\n" << "# ----------------- ----------------------------------------------------\n" << "# ID: " << task.id << "\n" << "# UUID: " << task.get ("uuid") << "\n" @@ -139,10 +143,14 @@ static std::string formatTask (Task task) task.getTags (tags); std::string allTags; join (allTags, " ", tags); - before << "# Separate the tags with spaces, like this: tag1 tag2\n" - << " Tags: " << allTags << "\n" - << "# The description field is allowed to wrap and use multiple lines. Task\n" - << "# will combine them.\n" + + if (verbose) + before << "# Separate the tags with spaces, like this: tag1 tag2\n" + << " Tags: " << allTags << "\n" + << "# The description field is allowed to wrap and use multiple lines. Task\n" + << "# will combine them.\n"; + + before << " Tags: " << allTags << "\n" << " Description: " << task.get ("description") << "\n" << " Created: " << formatDate (task, "entry") << "\n" << " Started: " << formatDate (task, "start") << "\n" @@ -153,9 +161,14 @@ static std::string formatTask (Task task) << " Wait until: " << formatDate (task, "wait") << "\n" << " Parent: " << task.get ("parent") << "\n" << " Foreground color: " << task.get ("fg") << "\n" - << " Background color: " << task.get ("bg") << "\n" - << "# Annotations look like this: -- and there can be any number of them\n" - << "# ' -- ' is the separator between the date and text field. It should not be removed\n"; + << " Background color: " << task.get ("bg") << "\n"; + + if (verbose) + before << "# Annotations look like this: -- and there can be any number of them.\n" + << "# The ' -- ' separator between the date and text field should not be removed.\n" + << "# A \"blank slot\" for adding an annotation follows for your convenience.\n"; + + before << " Background color: " << task.get ("bg") << "\n"; std::vector annotations; task.getAnnotations (annotations); @@ -175,8 +188,11 @@ static std::string formatTask (Task task) task.getDependencies (dependencies); std::string allDeps; join (allDeps, ",", dependencies); - before << "# Dependencies should be a comma-separated list of task IDs, with no spaces.\n" - << " Dependencies: " << allDeps << "\n"; + + if (verbose) + before << "# Dependencies should be a comma-separated list of task IDs, with no spaces.\n"; + + before << " Dependencies: " << allDeps << "\n"; before << "# End\n"; return before.str ();