@@ -438,17 +438,25 @@ function Agenda:agenda()
438
438
local dates = self .from :get_range_until (self .to )
439
439
local agenda_days = {}
440
440
441
+ local headline_dates = {}
442
+ for _ , orgfile in ipairs (Files .all ()) do
443
+ for _ , headline in ipairs (orgfile :get_opened_headlines ()) do
444
+ for _ , headline_date in ipairs (headline :get_valid_dates_for_agenda ()) do
445
+ table.insert (headline_dates , {
446
+ headline_date = headline_date ,
447
+ headline = headline ,
448
+ })
449
+ end
450
+ end
451
+ end
452
+
441
453
for _ , day in ipairs (dates ) do
442
454
local date = { day = day , agenda_items = {} }
443
455
444
- for _ , orgfile in ipairs (Files .all ()) do
445
- for _ , headline in ipairs (orgfile :get_opened_headlines ()) do
446
- for _ , headline_date in ipairs (headline :get_valid_dates_for_agenda ()) do
447
- local item = AgendaItem :new (headline_date , headline , day )
448
- if item .is_valid then
449
- table.insert (date .agenda_items , item )
450
- end
451
- end
456
+ for _ , item in ipairs (headline_dates ) do
457
+ local item = AgendaItem :new (item .headline_date , item .headline , day )
458
+ if item .is_valid then
459
+ table.insert (date .agenda_items , item )
452
460
end
453
461
end
454
462
0 commit comments