vonshednob / pter

Manage your todo.txt in a commandline user interface (TUI)
https://vonshednob.cc/pter/
MIT License
102 stars 6 forks source link

Not change the priority when done #29

Closed BuonOmo closed 11 months ago

BuonOmo commented 11 months ago

Hi,

First, thanks for this beautiful UI!

Then, well, this is the only todo.txt interface I am using that is changing priority when a task is done. I'm not really sure I see the point, as priority is by todo.txt standard written upfront, and that's how it is interpreted by other tools I'm using.

Could we consider not doing that ?

I'd be up to doing the PR, but the codeberg team is overwhelmed with inscriptions, and I cannot connect.

Here's a patch though:

diff --git a/pter/utils.py b/pter/utils.py
index f5119a6..7e084e3 100644
--- a/pter/utils.py
+++ b/pter/utils.py
@@ -25,7 +25,7 @@ def duration_as_str(duration):
     seconds = int(duration.total_seconds())
     hours = seconds // 3600
     minutes = (seconds % 3600) // 60
-    
+
     result = ''
     if hours > 0:
         result += f'{hours}h'
@@ -70,7 +70,7 @@ def parse_duration(text):

     if len(value) > 0:
         duration += datetime.timedelta(minutes=int(value))
-    
+
     duration *= sign

     return duration
@@ -195,9 +195,6 @@ def toggle_done(task, clear_contexts, reuse_recurring, safe_save):
     task.is_completed = not task.is_completed
     if task.is_completed:
         task.completion_date = datetime.datetime.now().date()
-        if task.priority is not None:
-            task.add_attribute('pri', task.priority)
-            task.priority = None
         if len(clear_contexts) > 0 and task.description is not None:
             for context in clear_contexts:
                 while f'@{context}' in task.description:
@@ -205,9 +202,6 @@ def toggle_done(task, clear_contexts, reuse_recurring, safe_save):
     else:
         task.completion_date = None
         attrs = task.attributes
-        if 'pri' in attrs:
-            task.priority = attrs['pri'][0]
-            task.remove_attribute('pri')
     task.parse(str(task))

@@ -277,7 +271,7 @@ def build_sort_order(order):
         elif part == 'due_in':
             sort_order.append(lambda t: task_due_in_days(t, sys.maxsize))
         elif part == 'priority':
-            sort_order.append(lambda t: t.priority or 'ZZZ')
+            sort_order.append(lambda t: t.priority if t.priority and not t.is_completed else 'ZZZ')
         elif part == 'linenr':
             sort_order.append(lambda t: t.linenr)
         elif part == 'file':
@@ -316,7 +310,7 @@ def update_spent(task):
             return False
     else:
         spent = datetime.timedelta(0)
-    
+
     diff = now - then
     if diff <= datetime.timedelta(minutes=1):
         diff = datetime.timedelta(0)
@@ -393,7 +387,7 @@ def parse_task_format(text):
     rawtokens = []
     token = ''
     in_block = False
-    
+
     for char in text:
         if in_block:
             if char == '}':
vonshednob commented 11 months ago

First of all thanks for the interest and your efford of putting the stuff into homebrew! It’s really appreciated!

I’m not quite sure what you mean with "is changing the priority when a task is done". In the todo.txt spec on completed tasks the priority is just not a thing anymore.

However, do I understand you correctly that you ultimately want to have completed tasks still sorted by what used to be their priority? So, have pter consider prio:A to be semantically equivalent to (A) and use both equally in sorting?

BuonOmo commented 11 months ago

No I don't want pri:A to be a thing at all. For instance when using the todo.sh cli, when a task is done the priority stays written the same way.

It doesn't make sense to me that priority which has an official place end up being written like additional metadata.

So basically, not altering the priority when marking a task done and that's it. The other change I made in the patch was just to not alter the sorting behaviour as it was before the patch (eg priority doesn't count on a done task as you said).

I'm honestly unsure I understand where this pri: metadata mechanic idea comes from 😅

vonshednob commented 11 months ago

Now it’s getting really interesting! I’ve tested the behaviour of todo.txt cli and marked a task with (A) priority as done -- it removed the priority entirely. Didn't even store it.

Do you have some specific configuration option in your ~/.config/todo/config that changes that behaviour?

Wrt where the pri: comes from: it comes from the specs. Specifically rule 2 of completed tasks, in the end of the first paragraph.

BuonOmo commented 11 months ago

Ah good catch! Okay I'll just keep my fork without this pri: then ^^, feels like too much for me.

vonshednob commented 11 months ago

Would it makes sense to you to have that behaviour as a (non-default) option for pter? Because I wouldn’t mind adding that.

BuonOmo commented 10 months ago

Could be a nice to add yeah for sure. Although, I personally prefer opinionated softwares rather than ones having loads of options. Hence I'm unsure. Maybe it will resurface later and you'll have more reasons to do it!

vonshednob commented 10 months ago

hehe, alright, I’ll keep the request in mind and if it pops up again I know whom to ask :)