Skip to content

Commit bad7aaa

Browse files
fix(agenda): respect start on weekday from custom agenda command
Closes #919
1 parent f6d2f93 commit bad7aaa

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

Diff for: lua/orgmode/agenda/types/agenda.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ function OrgAgendaType:new(opts)
6969
to = nil,
7070
clock_report = nil,
7171
show_clock_report = opts.show_clock_report or false,
72-
start_on_weekday = opts.start_on_weekday or config.org_agenda_start_on_weekday,
73-
start_day = opts.start_day or config.org_agenda_start_day,
72+
start_on_weekday = utils.if_nil(opts.start_on_weekday, config.org_agenda_start_on_weekday),
73+
start_day = utils.if_nil(opts.start_day, config.org_agenda_start_day),
7474
agenda_files = opts.agenda_files,
7575
header = opts.header,
7676
sorting_strategy = opts.sorting_strategy or vim.tbl_get(config.org_agenda_sorting_strategy, 'agenda') or {},
7777
id = opts.id,
78-
remove_tags = type(opts.remove_tags) == 'boolean' and opts.remove_tags or config.org_agenda_remove_tags,
78+
remove_tags = utils.if_nil(opts.remove_tags, config.org_agenda_remove_tags),
7979
}
8080
data.valid_filters = vim.tbl_filter(function(filter)
8181
return filter and true or false

Diff for: lua/orgmode/config/_meta.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
---@class OrgAgendaCustomCommandAgenda:OrgAgendaCustomCommandTypeInterface
1414
---@field org_agenda_span? OrgAgendaSpan Default: 'week'
1515
---@field org_agenda_start_day? string Modifier from today, example '+1d'
16-
---@field org_agenda_start_on_weekday? number
16+
---@field org_agenda_start_on_weekday? number | false
1717

1818
---@class OrgAgendaCustomCommandTags:OrgAgendaCustomCommandTypeInterface
1919
---@field match? string

Diff for: lua/orgmode/utils/init.lua

+15
Original file line numberDiff line numberDiff line change
@@ -635,4 +635,19 @@ function utils.notify(msg, opts)
635635
vim.notify(message, vim.log.levels[opts.level:upper()], opts)
636636
end
637637

638+
---Return first non-nil value
639+
---@generic T
640+
---@param ... T
641+
---@return T
642+
function utils.if_nil(...)
643+
local nargs = select('#', ...)
644+
for i = 1, nargs do
645+
local v = select(i, ...)
646+
if v ~= nil then
647+
return v
648+
end
649+
end
650+
return nil
651+
end
652+
638653
return utils

0 commit comments

Comments
 (0)