Skip to content

Commit

Permalink
fix: allow the user to set the default todo state
Browse files Browse the repository at this point in the history
As the order of the org_todo_keywords define the order of the todo in
the agenda, a user may want to have a default TODO state different than
the first one in the org_todo_keywords list
  • Loading branch information
lyz-code committed Dec 24, 2024
1 parent 6bb6fec commit 47ba087
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions lua/orgmode/config/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local DefaultConfig = {
org_agenda_files = '',
org_default_notes_file = '',
org_todo_keywords = { 'TODO', '|', 'DONE' },
org_todo_default_state = nil,
org_todo_repeat_to_state = nil,
org_todo_keyword_faces = {},
org_deadline_warning_days = 14,
Expand Down
6 changes: 5 additions & 1 deletion lua/orgmode/org/mappings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,11 @@ function OrgMappings:insert_heading_respect_content(suffix)
end

function OrgMappings:insert_todo_heading_respect_content()
return self:insert_heading_respect_content(config:get_todo_keywords():first_by_type('TODO').value .. ' ')
local first_todo_keyword = config.org_todo_default_state or config:get_todo_keywords():first_by_type('TODO').value
if not first_todo_keyword then
error('No default TODO keyword found')
end
return self:insert_heading_respect_content(first_todo_keyword .. ' ')
end

function OrgMappings:insert_todo_heading()
Expand Down

0 comments on commit 47ba087

Please sign in to comment.