stitch

Note taking for messy minimalists

git clone git://mccd.space/stitch
commit 67c32112317ec80d0a45da245dc54dda59da5de5
parent 41e598d5c92ac4687de4c3d700972ecf2096eb60
Author: Marc Coquand <marc@mccd.space>
Date:   Wed, 29 May 2024 10:10:45 -0500

Bugfix: done and todo should not reset tag when moving something to done

Diffstat:
Mlib/done.ml | 12++++++------
Mlib/todos.ml | 8+++++++-
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/lib/done.ml b/lib/done.ml
@@ -38,8 +38,8 @@ let init ~goto_todo ~goto_headlines =
   }
 
 
-let load_done ?(hide_file_name = false) () =
-  let done_content = Grep.get_done () |> Grep.parse_todo_string in
+let load_done ?(hide_file_name = false) tag =
+  let done_content = Grep.get_tagged_done tag () |> Grep.parse_todo_string in
   let done_pretty = Grep.pretty_format_todo ~hide_file_name done_content in
   done_content, done_pretty
 
@@ -138,7 +138,7 @@ let rec render
     in
     render t { state with hide_file_name; content_pretty }
   | `Key (`ASCII 'g', []) ->
-    let content, content_pretty = load_done ~hide_file_name () in
+    let content, content_pretty = load_done ~hide_file_name tag in
     let y = min (List.length content_pretty + content_start) y in
     render
       t
@@ -167,7 +167,7 @@ let rec render
                 ~content
                 ~selected_file
                 ~on_return:(fun result ->
-                  let content, content_pretty = load_done ~hide_file_name () in
+                  let content, content_pretty = load_done ~hide_file_name tag in
                   let y = min (List.length content_pretty + content_start) y in
                   Common.Term.cursor t None;
                   render
@@ -191,7 +191,7 @@ let rec render
   | `Key (`ASCII 'T', [ `Ctrl ]) ->
     let selected_file, _ = Array.get content (y - content_start) in
     let _ = Grep.toggle_todo selected_file in
-    let content, content_pretty = load_done ~hide_file_name () in
+    let content, content_pretty = load_done ~hide_file_name tag in
     let y = min (List.length content_pretty + content_start) y in
     render
       t
@@ -227,7 +227,7 @@ let rec render
       match Unix.wait () with
       | _, _ ->
         Common.Term.cursor t None;
-        let content, content_pretty = load_done ~hide_file_name () in
+        let content, content_pretty = load_done ~hide_file_name tag in
         render
           t
           { state with
diff --git a/lib/todos.ml b/lib/todos.ml
@@ -44,6 +44,12 @@ let load_todos ?(hide_file_name = false) () =
   todo_content, todo_pretty
 
 
+let refresh ?(hide_file_name = false) tag =
+  let content = Grep.get_tagged_todo tag () |> Grep.parse_todo_string in
+  let content_pretty = Grep.pretty_format_todo ~hide_file_name content in
+  content, content_pretty
+
+
 let rec render
   t
   ({ pos
@@ -192,7 +198,7 @@ let rec render
   | `Key (`ASCII 'T', [ `Ctrl ]) ->
     let selected_file, _ = Array.get content (y - content_start) in
     let _ = Grep.toggle_done selected_file in
-    let content, content_pretty = load_todos ~hide_file_name () in
+    let content, content_pretty = refresh ~hide_file_name tag in
     let y = min (List.length content_pretty + content_start) y in
     render
       t