File tree 2 files changed +20
-16
lines changed
2 files changed +20
-16
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ local SortingStrategy = require('orgmode.agenda.sorting_strategy')
55
55
--- @field clock_report_view ? OrgAgendaView
56
56
--- @field sorting_strategy ? OrgAgendaSortingStrategy[]
57
57
--- @field remove_tags ? boolean
58
+ --- @field valid_filters ? OrgAgendaFilter[]
58
59
--- @field id ? string
59
60
local OrgAgendaType = {}
60
61
OrgAgendaType .__index = OrgAgendaType
@@ -82,6 +83,14 @@ function OrgAgendaType:new(opts)
82
83
id = opts .id ,
83
84
remove_tags = type (opts .remove_tags ) == ' boolean' and opts .remove_tags or config .org_agenda_remove_tags ,
84
85
}
86
+ data .valid_filters = vim .tbl_filter (function (filter )
87
+ return filter and true or false
88
+ end , {
89
+ data .filter ,
90
+ data .tag_filter ,
91
+ data .category_filter ,
92
+ data .agenda_filter ,
93
+ })
85
94
local this = setmetatable (data , OrgAgendaType )
86
95
this :_set_date_range ()
87
96
this :_setup_agenda_files ()
@@ -412,14 +421,7 @@ function OrgAgendaType:toggle_clock_report()
412
421
end
413
422
414
423
function OrgAgendaType :_matches_filters (headline )
415
- local valid_filters = {
416
- self .filter ,
417
- self .tag_filter ,
418
- self .category_filter ,
419
- self .agenda_filter ,
420
- }
421
-
422
- for _ , filter in ipairs (valid_filters ) do
424
+ for _ , filter in ipairs (self .valid_filters ) do
423
425
if filter and not filter :matches (headline ) then
424
426
return false
425
427
end
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ local SortingStrategy = require('orgmode.agenda.sorting_strategy')
38
38
--- @field todo_only ? boolean
39
39
--- @field sorting_strategy ? OrgAgendaSortingStrategy[]
40
40
--- @field remove_tags ? boolean
41
+ --- @field valid_filters OrgAgendaFilter[]
41
42
--- @field id ? string
42
43
local OrgAgendaTodosType = {}
43
44
OrgAgendaTodosType .__index = OrgAgendaTodosType
@@ -60,6 +61,14 @@ function OrgAgendaTodosType:new(opts)
60
61
id = opts .id ,
61
62
remove_tags = type (opts .remove_tags ) == ' boolean' and opts .remove_tags or config .org_agenda_remove_tags ,
62
63
}, OrgAgendaTodosType )
64
+ this .valid_filters = vim .tbl_filter (function (filter )
65
+ return filter and true or false
66
+ end , {
67
+ this .filter ,
68
+ this .tag_filter ,
69
+ this .category_filter ,
70
+ this .agenda_filter ,
71
+ })
63
72
64
73
this :_setup_agenda_files ()
65
74
return this
@@ -202,14 +211,7 @@ function OrgAgendaTodosType:_get_headlines()
202
211
end
203
212
204
213
function OrgAgendaTodosType :_matches_filters (headline )
205
- local valid_filters = {
206
- self .agenda_filter ,
207
- self .filter ,
208
- self .tag_filter ,
209
- self .category_filter ,
210
- }
211
-
212
- for _ , filter in ipairs (valid_filters ) do
214
+ for _ , filter in ipairs (self .valid_filters ) do
213
215
if filter and not filter :matches (headline ) then
214
216
return false
215
217
end
You can’t perform that action at this time.
0 commit comments