Commit ac8dfd22fd

ac8dfd22fd3c7a6dbb719b8c46ec0a8c19608444

parent: 5405fbe38f

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-11 07:51 UTC

org-deadline-warning-days

config.toml's org-deadline-warning-days sets the agenda's default deadline warning and the deadline sparse tree's range. Emacs import carries it over.

Closes #17

Layout: unified · split

Sources/OrgApp/EmacsImport.swift +1 −1
@@ -471,7 +471,7 @@ public struct EmacsImport: Sendable {
471471 func note(_ reason: String) { unsupported.append(Note(id: id(), name: name, reason: reason, source: source)) }
472472 let truthy = value.symbol != "nil" && value.elements?.isEmpty != true
473473 switch name {
474 case "fill-column", "org-tags-column", "appt-message-warning-time":
474 case "fill-column", "org-tags-column", "appt-message-warning-time", "org-deadline-warning-days":
475475 guard let n = value.integer else { return note("not a number") }
476476 add(name, .integer(n))
477477 case "org-insert-heading-respect-content", "org-list-allow-alphabetical", "org-hide-emphasis-markers", "org-pretty-entities",
Sources/OrgApp/OrgPreferences.swift +3 −1
@@ -13,6 +13,7 @@ public enum OrgPreferences {
1313 var settings = OrgSettings.default.withTodoKeywords(line) ?? .default
1414 settings.listAllowAlphabetical = bool("alphabeticalLists", defaults)
1515 settings.propertyInheritance = .init(string("propertyInheritance", defaults))
16 settings.deadlineWarningDays = integer("deadlineWarningDays", defaults)
1617 return settings
1718 }
1819
@@ -59,9 +60,10 @@ public enum OrgPreferences {
5960 public static func agendaSkipDeadlineIfDone(_ defaults: UserDefaults = .standard) -> Bool { bool("agendaSkipDeadlineIfDone", defaults) }
6061 public static func agendaSearchAlwaysBoolean(_ defaults: UserDefaults = .standard) -> Bool { bool("agendaSearchAlwaysBoolean", defaults) }
6162 public static func agendaSearchForceFullWords(_ defaults: UserDefaults = .standard) -> Bool { bool("agendaSearchForceFullWords", defaults) }
62 /// `options` with the skip-if-done, search and blocked-entry settings.
63 /// `options` with the deadline warning, skip-if-done, search and blocked-entry settings.
6364 public static func agendaOptions(_ options: AgendaOptions, _ defaults: UserDefaults = .standard) -> AgendaOptions {
6465 var options = options
66 options.deadlineWarningDays = integer("deadlineWarningDays", defaults)
6567 options.skipScheduledIfDone = agendaSkipScheduledIfDone(defaults)
6668 options.skipDeadlineIfDone = agendaSkipDeadlineIfDone(defaults)
6769 options.searchAlwaysBoolean = agendaSearchAlwaysBoolean(defaults)
Sources/OrgApp/UserConfig.swift +2
@@ -147,6 +147,8 @@ public enum UserConfig {
147147 comment: "days the agenda shows", legacy: "agenda.span"),
148148 Setting(section: "", key: "org-agenda-start-day", defaultsKey: "agendaStartOffset", kind: .dayOffset, fallback: .string("+0d"),
149149 comment: "the agenda's first day: \"-3d\", \"+0d\"", legacy: "agenda.start-offset"),
150 Setting(section: "", key: "org-deadline-warning-days", defaultsKey: "deadlineWarningDays", kind: .integer, fallback: .integer(14),
151 comment: "days ahead the agenda warns about a deadline; a -Nd cookie overrides", legacy: ""),
150152 Setting(section: "", key: "org-agenda-show-all-dates", defaultsKey: "agendaShowAllDates", kind: .bool, fallback: .bool(false),
151153 comment: "show days with no entries (Emacs's default is t; orgstar hides them); today always shows", legacy: ""),
152154 Setting(section: "", key: "org-agenda-skip-scheduled-if-done", defaultsKey: "agendaSkipScheduledIfDone", kind: .bool, fallback: .bool(false),
Sources/OrgCore/Commands/SparseTree.swift +2 −2
@@ -242,8 +242,8 @@ public struct SparseTreeCommand: OrgCommand {
242242 matches = SparseTree.match(name.replacingOccurrences(of: "-", with: "\\-") + "=" + value, in: text, now: context.now, calendar: context.calendar)
243243 message = nil
244244 case "d":
245 matches = SparseTree.deadlines(within: 14, in: text, settings: settings, now: context.now, calendar: context.calendar)
246 message = "\(matches.points.count) deadlines past-due or due within 14 days"
245 matches = SparseTree.deadlines(within: settings.deadlineWarningDays, in: text, settings: settings, now: context.now, calendar: context.calendar)
246 message = "\(matches.points.count) deadlines past-due or due within \(settings.deadlineWarningDays) days"
247247 case "b", "a":
248248 if let step = ask("date", "Date:", date: true) { return step }
249249 let date = dateString(context.answers["date"]!)
Sources/OrgCore/Parser/Settings.swift +3
@@ -49,6 +49,8 @@ public struct OrgSettings: Sendable, Equatable {
4949 public var listAllowAlphabetical = false
5050 /// `org-use-property-inheritance`.
5151 public var propertyInheritance: SemanticSettings.PropertyInheritance = .none
52 /// `org-deadline-warning-days`.
53 public var deadlineWarningDays = 14
5254 /// Keyword lines from the file's `#+SETUPFILE`s, as `#+KEY: value` lines: they count as
5355 /// the file's own, before them.
5456 public var setupKeywords = ""
@@ -136,6 +138,7 @@ enum SettingsScanner {
136138 radioTargets: radio.sorted { $0.count > $1.count })
137139 settings.listAllowAlphabetical = defaults.listAllowAlphabetical
138140 settings.propertyInheritance = defaults.propertyInheritance
141 settings.deadlineWarningDays = defaults.deadlineWarningDays
139142 settings.setupKeywords = defaults.setupKeywords
140143 settings.startup = startup
141144 return settings
Tests/OrgAppTests/EmacsImportTests.swift +3 −1
@@ -39,6 +39,7 @@ struct EmacsImportTests {
3939 (defun +org-init-appearance-h ()
4040 (setq org-tags-column 0
4141 org-agenda-span 10
42 org-deadline-warning-days 7
4243 org-agenda-start-day "-3d"
4344 org-clock-idle-time 15
4445 org-clock-history-length 10
@@ -80,6 +81,7 @@ struct EmacsImportTests {
8081 // after! org runs after the top-level setq.
8182 #expect(s["org-tags-column"] == .integer(-80))
8283 #expect(s["org-agenda-span"] == .integer(10))
84 #expect(s["org-deadline-warning-days"] == .integer(7))
8385 #expect(s["org-agenda-start-day"] == .string("-3d"))
8486 #expect(s["org-clock-idle-time"] == .integer(15))
8587 #expect(s["org-clock-history-length"] == .integer(10))
@@ -171,7 +173,7 @@ struct EmacsImportTests {
171173 let keymap = folder.appendingPathComponent("keymap.toml")
172174 #expect(KeymapLoader.load(.doom, userFile: keymap).problems.isEmpty)
173175 #expect(KeymapLoader.load(.doom, userFile: keymap).keymap.keyLabels(for: "app.agenda", modes: ["normal"]).contains("C-c a"))
174 #expect(summary.hasPrefix("Imported 19 settings, 3 capture templates, 3 key bindings."), "\(summary)")
176 #expect(summary.hasPrefix("Imported 20 settings, 3 capture templates, 3 key bindings."), "\(summary)")
175177 #expect(defaults.string(forKey: "themeFont") == "JetBrains Mono")
176178 #expect(defaults.integer(forKey: "themeFontSize") == 14)
177179
Tests/OrgAppTests/OrgPreferencesTests.swift +5
@@ -11,6 +11,8 @@ struct OrgPreferencesTests {
1111 #expect(OrgPreferences.orgSettings(defaults).todoSequences.first?.active.map(\.name) == ["TODO", "PROJ", "LOOP", "STRT", "WAIT", "HOLD", "IDEA"])
1212 #expect(OrgPreferences.options(defaults).logDone == nil && OrgPreferences.options(defaults).tagsColumn == -77)
1313 #expect(OrgPreferences.agendaSpan(defaults) == 10 && OrgPreferences.agendaStartOffset(defaults) == 0)
14 #expect(OrgPreferences.orgSettings(defaults).deadlineWarningDays == 14)
15 #expect(OrgPreferences.agendaOptions(AgendaOptions(), defaults).deadlineWarningDays == 14)
1416 #expect(OrgPreferences.reminders(defaults) && OrgPreferences.reminderLead(defaults) == 12)
1517 let fallbacks = OrgPreferences.options(defaults)
1618 #expect(!fallbacks.metaReturnMaySplitLine && fallbacks.hideEmphasisMarkers && fallbacks.prettyEntities && fallbacks.subSuperscriptsNeedBraces)
@@ -23,6 +25,7 @@ struct OrgPreferencesTests {
2325 org-agenda-span = 7
2426 org-agenda-start-day = "-1d"
2527 appt-message-warning-time = 30
28 org-deadline-warning-days = 5
2629 org-M-RET-may-split-line = true
2730 org-hide-emphasis-markers = false
2831 org-pretty-entities = false
@@ -35,6 +38,8 @@ struct OrgPreferencesTests {
3538 #expect(options.logDone == .time && options.logIntoDrawer == "LOGBOOK")
3639 #expect(options.metaReturnMaySplitLine && !options.hideEmphasisMarkers && !options.prettyEntities)
3740 #expect(OrgPreferences.agendaSpan(defaults) == 7 && OrgPreferences.agendaStartOffset(defaults) == -1)
41 #expect(OrgPreferences.orgSettings(defaults).deadlineWarningDays == 5)
42 #expect(OrgPreferences.agendaOptions(AgendaOptions(), defaults).deadlineWarningDays == 5)
3843 #expect(!OrgPreferences.reminders(defaults) && OrgPreferences.reminderLead(defaults) == 30)
3944 }
4045
Tests/OrgCoreTests/SparseTreeTests.swift +1
@@ -45,6 +45,7 @@ struct SparseTreeTests {
4545 ("(org-match-sparse-tree nil \"home|work\")", SparseTree.match("home|work", in: Self.text, now: now, calendar: utc)),
4646 ("(org-match-sparse-tree nil \"LEVEL>2\")", SparseTree.match("LEVEL>2", in: Self.text, now: now, calendar: utc)),
4747 ("(org-check-deadlines nil)", SparseTree.deadlines(within: 14, in: Self.text, settings: tree.settings, now: now, calendar: utc)),
48 ("(let ((org-deadline-warning-days 90)) (org-check-deadlines nil))", SparseTree.deadlines(within: 90, in: Self.text, settings: tree.settings, now: now, calendar: utc)),
4849 ("(org-check-before-date \"2026-09-20\")", SparseTree.planning(from: nil, to: "2026-09-20", in: Self.text, calendar: utc)),
4950 ("(org-check-after-date \"2026-09-20\")", SparseTree.planning(from: "2026-09-20", to: nil, in: Self.text, calendar: utc)),
5051 ("(org-check-dates-range \"2026-09-01\" \"2026-10-01 10:00\")", SparseTree.planning(from: "2026-09-01", to: "2026-10-01 10:00", in: Self.text, calendar: utc)),
docs/manual/guide/04-outlines.org +1 −1
@@ -288,7 +288,7 @@ match, one keystroke:
288288| =T= | headings with the keywords you give (several separated by a vertical bar) | =org-show-todo-tree= |
289289| =m= | headings matching a tags and properties match | =org-match-sparse-tree= |
290290| =p= | headings where a property has a value (asks for both, with completion) | =org-match-sparse-tree= |
291| =d= | deadlines past due or due within 14 days (fixed), in entries not done | =org-check-deadlines= |
291| =d= | deadlines past due or due within =org-deadline-warning-days= (14), in entries not done | =org-check-deadlines= |
292292| =b= | entries with a =SCHEDULED= or =DEADLINE= before a date | =org-check-before-date= |
293293| =a= | entries with a =SCHEDULED= or =DEADLINE= on or after a date | =org-check-after-date= |
294294| =D= | entries with a =SCHEDULED= or =DEADLINE= in a date range | =org-check-dates-range= |
docs/manual/guide/06-dates-and-clocking.org +1 −1
@@ -133,7 +133,7 @@ DEADLINE: <2026-10-31 Sat -7d> SCHEDULED: <2026-10-20 Tue>
133133#+END_SRC
134134
135135- =SCHEDULED= is the day you plan to start. The agenda shows the entry from that day until it is done.
136- =DEADLINE= is the day it is due. The agenda warns about it 14 days ahead (=org-deadline-warning-days=), or as the timestamp's own =-Nd= says.
136- =DEADLINE= is the day it is due. The agenda warns about it 14 days ahead (=org-deadline-warning-days= in =config.toml=), or as the timestamp's own =-Nd= says.
137137
138138| Command | Org command | Emacs, Doom | Mac | Doom leader |
139139|------------------+------------------+-------------+------+-------------|
docs/manual/guide/07-agenda.org +1 −1
@@ -95,7 +95,7 @@ An entry with a time of day shows the time instead of the status: =08:00=, or =1
9595
9696Details:
9797
98- Deadline warnings use =org-deadline-warning-days=, fixed at 14 days. A =-Nd= cookie in the timestamp (=<2026-10-20 Tue -3d>=) changes the warning for that deadline; =w=, =m= and =y= units work too.
98- Deadline warnings start =org-deadline-warning-days= days ahead, 14 by default, set in =config.toml=. A =-Nd= cookie in the timestamp (=<2026-10-20 Tue -3d>=) changes the warning for that deadline; =w=, =m= and =y= units work too.
9999- A =-Nd= cookie on a =SCHEDULED= timestamp delays it: the entry first shows N days after the scheduled date.
100100- Repeaters on =SCHEDULED= and =DEADLINE= timestamps (=+1w=, =++1w=, =.+1d=) make the entry show on the next occurrence on future days, as in Org.
101101- A done entry shows only on the day of its deadline or scheduled date, not as overdue. With =org-agenda-skip-scheduled-if-done= or =org-agenda-skip-deadline-if-done= set to =true= in =config.toml=, a done entry's scheduled date or deadline doesn't show on that day either. Both are =false= by default, as in Org.
docs/manual/guide/13-configuration.org +2
@@ -155,6 +155,7 @@ These settings have no control in the Settings window. Some are in the View menu
155155| =tab-bar= | View ▸ Show Tab Bar |
156156| =show-markup= | View ▸ Show Markup (=⇧⌘M=) |
157157| =ignored-folders= | |
158| =org-deadline-warning-days= | |
158159| =org-agenda-skip-scheduled-if-done= | |
159160| =org-agenda-skip-deadline-if-done= | |
160161| =org-agenda-search-view-always-boolean= | |
@@ -199,6 +200,7 @@ A key you remove from the file goes back to its default. A key that isn't in the
199200| =display-line-numbers-type= | boolean | =true= | Line numbers in the editor's gutter. orgstar numbers lines absolutely; there is no relative or visual mode. |
200201| =org-agenda-span= | integer | =10= | Days the agenda shows. Mirrors =org-agenda-span=. |
201202| =org-agenda-start-day= | string | ="+0d"= | The agenda's first day relative to today, as ="-3d"= or ="+0d"=. Only day offsets are accepted. Mirrors =org-agenda-start-day=. |
203| =org-deadline-warning-days= | integer | =14= | Days ahead the agenda and the deadline sparse tree warn about a deadline. A =-Nd= cookie in the timestamp overrides it. Mirrors =org-deadline-warning-days=. |
202204| =org-agenda-show-all-dates= | boolean | =false= | Show days without entries in the agenda; today always shows. Emacs's default is =t=. Mirrors =org-agenda-show-all-dates=. |
203205| =org-agenda-skip-scheduled-if-done= | boolean | =false= | Leave a done entry's scheduled date out of the agenda, even on its own day. Mirrors =org-agenda-skip-scheduled-if-done=. |
204206| =org-agenda-skip-deadline-if-done= | boolean | =false= | Leave a done entry's deadline out of the agenda, even on its own day. Mirrors =org-agenda-skip-deadline-if-done=. |
docs/manual/guide/14-ios.org +1 −1
@@ -350,7 +350,7 @@ These settings from =config.toml= apply on iOS:
350350- =org-enforce-todo-dependencies=, =org-enforce-todo-checkbox-dependencies=, =org-agenda-dim-blocked-tasks=
351351- =org-use-speed-commands=, with a hardware keyboard
352352- =electric-pair-mode=, =spell-check=
353- =org-agenda-span=, =org-agenda-start-day=, =agenda-include-subfolders=, =org-agenda-show-all-dates=, =org-agenda-skip-scheduled-if-done=, =org-agenda-skip-deadline-if-done=, =org-agenda-search-view-always-boolean=, =org-agenda-search-view-force-full-words=
353- =org-agenda-span=, =org-agenda-start-day=, =org-deadline-warning-days=, =agenda-include-subfolders=, =org-agenda-show-all-dates=, =org-agenda-skip-scheduled-if-done=, =org-agenda-skip-deadline-if-done=, =org-agenda-search-view-always-boolean=, =org-agenda-search-view-force-full-words=
354354- =calendar-events=, =calendar-event-calendars=
355355- =reminders=, =appt-message-warning-time=
356356- =org-clock-history-length=