feat: add source file tracking to rem type

Add a `source` field to `Remind.rem` to track the originating iCalendar
filename (basename without extension). Thread the basename through
`remind_of_event` so each reminder records which file it came from.
This commit is contained in:
2026-05-16 22:14:27 +02:00
parent 9445eb81e8
commit 4e6ba30f2d
3 changed files with 6 additions and 3 deletions

View File

@@ -326,7 +326,7 @@ let all_collectors : collector list =
simple_recurrence; simple_recurrence;
] ]
let remind_of_event (ev : Icalendar.event list) : (Remind.rem, error) result = let remind_of_event (source : string) (ev : Icalendar.event list) : (Remind.rem, error) result =
let () = if List.length ev = 0 then failwith "No events provided" in let () = if List.length ev = 0 then failwith "No events provided" in
let master, recurrence = let master, recurrence =
@@ -339,7 +339,7 @@ let remind_of_event (ev : Icalendar.event list) : (Remind.rem, error) result =
end end
in in
let rem = { Remind.empty with Remind.recurring = recurrence } in let rem = { Remind.empty with Remind.source; Remind.recurring = recurrence } in
ListLabels.fold_left ~init:(Ok rem) all_collectors ~f:(fun rem_or_error pred -> ListLabels.fold_left ~init:(Ok rem) all_collectors ~f:(fun rem_or_error pred ->
match rem_or_error with match rem_or_error with

View File

@@ -20,6 +20,7 @@ let ical2rem ical_files =
try try
Printf.eprintf "\nProcessing file: %s\n" filename; Printf.eprintf "\nProcessing file: %s\n" filename;
let file_content = read_file filename in let file_content = read_file filename in
let basename = Filename.remove_extension (Filename.basename filename) in
match Icalendar.parse file_content with match Icalendar.parse file_content with
| Error e -> | Error e ->
if e <> ": not enough input" then prerr_endline ("Error parsing iCalendar file: " ^ e); if e <> ": not enough input" then prerr_endline ("Error parsing iCalendar file: " ^ e);
@@ -39,7 +40,7 @@ let ical2rem ical_files =
let good_rems = let good_rems =
Map.fold ~init:[] events_map ~f:(fun ~key:uid ~data:events good_rems -> Map.fold ~init:[] events_map ~f:(fun ~key:uid ~data:events good_rems ->
let rem_or_error = EventPredicates.remind_of_event events in let rem_or_error = EventPredicates.remind_of_event basename events in
match rem_or_error with match rem_or_error with
| Ok rem -> rem :: good_rems | Ok rem -> rem :: good_rems
| Error (EventPredicates.Invalid_date s) -> | Error (EventPredicates.Invalid_date s) ->

View File

@@ -11,6 +11,7 @@ type simple_weekly = {
(** A simple weekly REM command *) (** A simple weekly REM command *)
type rem = { type rem = {
source : string; (** Source file or identifier for the reminder *)
original_uuid : string; (** Original UID from the iCalendar event *) original_uuid : string; (** Original UID from the iCalendar event *)
summary : string; (** Summary or title of the reminder *) summary : string; (** Summary or title of the reminder *)
date : Timedesc.Date.t; (** Date specification (day, month, year) *) date : Timedesc.Date.t; (** Date specification (day, month, year) *)
@@ -28,6 +29,7 @@ type rem = {
let empty = let empty =
{ {
source = "";
original_uuid = ""; original_uuid = "";
summary = ""; summary = "";
date = Timedesc.Date.Ymd.make_exn ~year:1970 ~month:1 ~day:1; date = Timedesc.Date.Ymd.make_exn ~year:1970 ~month:1 ~day:1;