due icon indicating copy to clipboard operation
due copied to clipboard

Skip completed tasks from listing?

Open severoraz opened this issue 5 years ago • 3 comments

This seems like a good idea to me, but is it? I have applied it on my clone, so I leave a patch here in case anyone wants to try it out. Its trivial though.

diff --git a/due.py b/due.py
index c0fc26a..e04b5c0 100644
--- a/due.py
+++ b/due.py
@@ -52,6 +52,10 @@ def main(todo_file, future_days=0):
         key = os.getenv("TODO_TXT_DUE_KEY", "due")
 
         for i, task in enumerate(content):
+
+            # skip completed tasks
+            if task[0] == "x": continue
+            
             match = re.findall(
                 r"(\([A-Z]\))?[A-Za-z0-9+@\s]+%s:(\d{4}-\d{2}-\d{2})" % key, task
             )
@@ -61,7 +65,7 @@ def main(todo_file, future_days=0):
                 tasks_with_date.append((i, task, date, match[0][0]))
 
         # Sort tasks that match due: regex by date, then priority
-        sorted_tasks = sorted(tasks_with_date, key=lambda tup: (tup[2], tup[3]))
+        sorted_tasks = sorted(tasks_with_date, key=lambda tup: (tup[2], tup[1]))
         zero_pad = int(math.log10(len(content))) + 1
 
         # Append to relevant lists for output

severoraz avatar May 25 '19 12:05 severoraz

Nice idea - perhaps this could be added as an optional flag? I'm not routinely using this format at the moment so not sure if this would be desirable.

rebecca-owen avatar May 25 '19 20:05 rebecca-owen

Yeah I think an optional flag would be a good idea! I made a proposed solution, please ignore the first commit!

severoraz avatar May 26 '19 13:05 severoraz

Also, feel free to change the name of the flag, or whatever.

severoraz avatar May 26 '19 13:05 severoraz