Skip to content

Commit

Permalink
feat(api): Add todo_ignore opts for tags and tags_todo views
Browse files Browse the repository at this point in the history
  • Loading branch information
kristijanhusak committed Jan 18, 2025
1 parent 5f45d47 commit 91f5a9e
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions lua/orgmode/api/agenda.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ local function get_date(date, name)
error(('Invalid format for "%s" date in Org Agenda'):format(name))
end

local function get_opts(options)
local function get_shared_opts(options)
options = options or {}
local opts = {}
if options.filters and options.filters ~= '' then
Expand All @@ -35,6 +35,14 @@ local function get_opts(options)
return opts
end

local function get_tags_opts(options)
local opts = get_shared_opts(options)
opts.match_query = options.match_query
opts.todo_ignore_scheduled = options.org_agenda_todo_ignore_scheduled
opts.todo_ignore_deadlines = options.org_agenda_todo_ignore_deadlines
return opts
end

---@class OrgApiAgendaOpts
---@field filters? OrgApiAgendaFilter
---@field header? string
Expand All @@ -51,7 +59,7 @@ end
---@param options? OrgApiAgendaOptions
function OrgAgenda.agenda(options)
options = options or {}
local opts = get_opts(options)
local opts = get_shared_opts(options)
opts.from = get_date(options.from, 'from')
opts.span = options.span
orgmode.agenda:agenda(opts)
Expand All @@ -62,32 +70,31 @@ end
---@param options? OrgApiAgendaTodosOptions
function OrgAgenda.todos(options)
options = options or {}
local opts = get_opts(options)
local opts = get_shared_opts(options)
orgmode.agenda:todos(opts)
end

---@class OrgApiAgendaTagsOptions:OrgApiAgendaOpts
---@class OrgApiAgendaTagsTodoOptions:OrgApiAgendaOpts
---@field match_query? string Match query to find the todos
---@field todo_only? boolean
---@field org_agenda_todo_ignore_scheduled? OrgAgendaTodoIgnoreScheduledTypes
---@field org_agenda_todo_ignore_deadlines? OrgAgendaTodoIgnoreDeadlinesTypes

---@param options? OrgApiAgendaTagsOptions
function OrgAgenda.tags(options)
function OrgAgenda.tags_todo(options)
options = options or {}
local opts = get_opts(options)
opts.todo_only = options.todo_only
opts.match_query = options.match_query
orgmode.agenda:tags(opts)
local opts = get_tags_opts(options)
orgmode.agenda:tags_todo(opts)
end

---@class OrgApiAgendaTagsTodoOptions:OrgApiAgendaOpts
---@field match_query? string Match query to find the todos
---@class OrgApiAgendaTagsOptions:OrgApiAgendaTagsTodoOptions
---@field todo_only? boolean

---@param options? OrgApiAgendaTagsOptions
function OrgAgenda.tags_todo(options)
function OrgAgenda.tags(options)
options = options or {}
local opts = get_opts(options)
opts.match_query = options.match_query
orgmode.agenda:tags_todo(opts)
local opts = get_tags_opts(options)
opts.todo_only = options.todo_only
orgmode.agenda:tags(opts)
end

return OrgAgenda

0 comments on commit 91f5a9e

Please sign in to comment.