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 { |
| 471 | 471 | func note(_ reason: String) { unsupported.append(Note(id: id(), name: name, reason: reason, source: source)) } |
| 472 | 472 | let truthy = value.symbol != "nil" && value.elements?.isEmpty != true |
| 473 | 473 | 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": |
| 475 | 475 | guard let n = value.integer else { return note("not a number") } |
| 476 | 476 | add(name, .integer(n)) |
| 477 | 477 | 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 { |
| 13 | 13 | var settings = OrgSettings.default.withTodoKeywords(line) ?? .default |
| 14 | 14 | settings.listAllowAlphabetical = bool("alphabeticalLists", defaults) |
| 15 | 15 | settings.propertyInheritance = .init(string("propertyInheritance", defaults)) |
| 16 | settings.deadlineWarningDays = integer("deadlineWarningDays", defaults) |
| 16 | 17 | return settings |
| 17 | 18 | } |
| 18 | 19 | |
| @@ -59,9 +60,10 @@ public enum OrgPreferences { |
| 59 | 60 | public static func agendaSkipDeadlineIfDone(_ defaults: UserDefaults = .standard) -> Bool { bool("agendaSkipDeadlineIfDone", defaults) } |
| 60 | 61 | public static func agendaSearchAlwaysBoolean(_ defaults: UserDefaults = .standard) -> Bool { bool("agendaSearchAlwaysBoolean", defaults) } |
| 61 | 62 | 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. |
| 63 | 64 | public static func agendaOptions(_ options: AgendaOptions, _ defaults: UserDefaults = .standard) -> AgendaOptions { |
| 64 | 65 | var options = options |
| 66 | options.deadlineWarningDays = integer("deadlineWarningDays", defaults) |
| 65 | 67 | options.skipScheduledIfDone = agendaSkipScheduledIfDone(defaults) |
| 66 | 68 | options.skipDeadlineIfDone = agendaSkipDeadlineIfDone(defaults) |
| 67 | 69 | options.searchAlwaysBoolean = agendaSearchAlwaysBoolean(defaults) |
Sources/OrgApp/UserConfig.swift
+2
| @@ -147,6 +147,8 @@ public enum UserConfig { |
| 147 | 147 | comment: "days the agenda shows", legacy: "agenda.span"), |
| 148 | 148 | Setting(section: "", key: "org-agenda-start-day", defaultsKey: "agendaStartOffset", kind: .dayOffset, fallback: .string("+0d"), |
| 149 | 149 | 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: ""), |
| 150 | 152 | Setting(section: "", key: "org-agenda-show-all-dates", defaultsKey: "agendaShowAllDates", kind: .bool, fallback: .bool(false), |
| 151 | 153 | comment: "show days with no entries (Emacs's default is t; orgstar hides them); today always shows", legacy: ""), |
| 152 | 154 | 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 { |
| 242 | 242 | matches = SparseTree.match(name.replacingOccurrences(of: "-", with: "\\-") + "=" + value, in: text, now: context.now, calendar: context.calendar) |
| 243 | 243 | message = nil |
| 244 | 244 | 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" |
| 247 | 247 | case "b", "a": |
| 248 | 248 | if let step = ask("date", "Date:", date: true) { return step } |
| 249 | 249 | let date = dateString(context.answers["date"]!) |
Sources/OrgCore/Parser/Settings.swift
+3
| @@ -49,6 +49,8 @@ public struct OrgSettings: Sendable, Equatable { |
| 49 | 49 | public var listAllowAlphabetical = false |
| 50 | 50 | /// `org-use-property-inheritance`. |
| 51 | 51 | public var propertyInheritance: SemanticSettings.PropertyInheritance = .none |
| 52 | /// `org-deadline-warning-days`. |
| 53 | public var deadlineWarningDays = 14 |
| 52 | 54 | /// Keyword lines from the file's `#+SETUPFILE`s, as `#+KEY: value` lines: they count as |
| 53 | 55 | /// the file's own, before them. |
| 54 | 56 | public var setupKeywords = "" |
| @@ -136,6 +138,7 @@ enum SettingsScanner { |
| 136 | 138 | radioTargets: radio.sorted { $0.count > $1.count }) |
| 137 | 139 | settings.listAllowAlphabetical = defaults.listAllowAlphabetical |
| 138 | 140 | settings.propertyInheritance = defaults.propertyInheritance |
| 141 | settings.deadlineWarningDays = defaults.deadlineWarningDays |
| 139 | 142 | settings.setupKeywords = defaults.setupKeywords |
| 140 | 143 | settings.startup = startup |
| 141 | 144 | return settings |
Tests/OrgAppTests/EmacsImportTests.swift
+3 −1
| @@ -39,6 +39,7 @@ struct EmacsImportTests { |
| 39 | 39 | (defun +org-init-appearance-h () |
| 40 | 40 | (setq org-tags-column 0 |
| 41 | 41 | org-agenda-span 10 |
| 42 | org-deadline-warning-days 7 |
| 42 | 43 | org-agenda-start-day "-3d" |
| 43 | 44 | org-clock-idle-time 15 |
| 44 | 45 | org-clock-history-length 10 |
| @@ -80,6 +81,7 @@ struct EmacsImportTests { |
| 80 | 81 | // after! org runs after the top-level setq. |
| 81 | 82 | #expect(s["org-tags-column"] == .integer(-80)) |
| 82 | 83 | #expect(s["org-agenda-span"] == .integer(10)) |
| 84 | #expect(s["org-deadline-warning-days"] == .integer(7)) |
| 83 | 85 | #expect(s["org-agenda-start-day"] == .string("-3d")) |
| 84 | 86 | #expect(s["org-clock-idle-time"] == .integer(15)) |
| 85 | 87 | #expect(s["org-clock-history-length"] == .integer(10)) |
| @@ -171,7 +173,7 @@ struct EmacsImportTests { |
| 171 | 173 | let keymap = folder.appendingPathComponent("keymap.toml") |
| 172 | 174 | #expect(KeymapLoader.load(.doom, userFile: keymap).problems.isEmpty) |
| 173 | 175 | #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)") |
| 175 | 177 | #expect(defaults.string(forKey: "themeFont") == "JetBrains Mono") |
| 176 | 178 | #expect(defaults.integer(forKey: "themeFontSize") == 14) |
| 177 | 179 | |
Tests/OrgAppTests/OrgPreferencesTests.swift
+5
| @@ -11,6 +11,8 @@ struct OrgPreferencesTests { |
| 11 | 11 | #expect(OrgPreferences.orgSettings(defaults).todoSequences.first?.active.map(\.name) == ["TODO", "PROJ", "LOOP", "STRT", "WAIT", "HOLD", "IDEA"]) |
| 12 | 12 | #expect(OrgPreferences.options(defaults).logDone == nil && OrgPreferences.options(defaults).tagsColumn == -77) |
| 13 | 13 | #expect(OrgPreferences.agendaSpan(defaults) == 10 && OrgPreferences.agendaStartOffset(defaults) == 0) |
| 14 | #expect(OrgPreferences.orgSettings(defaults).deadlineWarningDays == 14) |
| 15 | #expect(OrgPreferences.agendaOptions(AgendaOptions(), defaults).deadlineWarningDays == 14) |
| 14 | 16 | #expect(OrgPreferences.reminders(defaults) && OrgPreferences.reminderLead(defaults) == 12) |
| 15 | 17 | let fallbacks = OrgPreferences.options(defaults) |
| 16 | 18 | #expect(!fallbacks.metaReturnMaySplitLine && fallbacks.hideEmphasisMarkers && fallbacks.prettyEntities && fallbacks.subSuperscriptsNeedBraces) |
| @@ -23,6 +25,7 @@ struct OrgPreferencesTests { |
| 23 | 25 | org-agenda-span = 7 |
| 24 | 26 | org-agenda-start-day = "-1d" |
| 25 | 27 | appt-message-warning-time = 30 |
| 28 | org-deadline-warning-days = 5 |
| 26 | 29 | org-M-RET-may-split-line = true |
| 27 | 30 | org-hide-emphasis-markers = false |
| 28 | 31 | org-pretty-entities = false |
| @@ -35,6 +38,8 @@ struct OrgPreferencesTests { |
| 35 | 38 | #expect(options.logDone == .time && options.logIntoDrawer == "LOGBOOK") |
| 36 | 39 | #expect(options.metaReturnMaySplitLine && !options.hideEmphasisMarkers && !options.prettyEntities) |
| 37 | 40 | #expect(OrgPreferences.agendaSpan(defaults) == 7 && OrgPreferences.agendaStartOffset(defaults) == -1) |
| 41 | #expect(OrgPreferences.orgSettings(defaults).deadlineWarningDays == 5) |
| 42 | #expect(OrgPreferences.agendaOptions(AgendaOptions(), defaults).deadlineWarningDays == 5) |
| 38 | 43 | #expect(!OrgPreferences.reminders(defaults) && OrgPreferences.reminderLead(defaults) == 30) |
| 39 | 44 | } |
| 40 | 45 | |
Tests/OrgCoreTests/SparseTreeTests.swift
+1
| @@ -45,6 +45,7 @@ struct SparseTreeTests { |
| 45 | 45 | ("(org-match-sparse-tree nil \"home|work\")", SparseTree.match("home|work", in: Self.text, now: now, calendar: utc)), |
| 46 | 46 | ("(org-match-sparse-tree nil \"LEVEL>2\")", SparseTree.match("LEVEL>2", in: Self.text, now: now, calendar: utc)), |
| 47 | 47 | ("(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)), |
| 48 | 49 | ("(org-check-before-date \"2026-09-20\")", SparseTree.planning(from: nil, to: "2026-09-20", in: Self.text, calendar: utc)), |
| 49 | 50 | ("(org-check-after-date \"2026-09-20\")", SparseTree.planning(from: "2026-09-20", to: nil, in: Self.text, calendar: utc)), |
| 50 | 51 | ("(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: |
| 288 | 288 | | =T= | headings with the keywords you give (several separated by a vertical bar) | =org-show-todo-tree= | |
| 289 | 289 | | =m= | headings matching a tags and properties match | =org-match-sparse-tree= | |
| 290 | 290 | | =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= | |
| 292 | 292 | | =b= | entries with a =SCHEDULED= or =DEADLINE= before a date | =org-check-before-date= | |
| 293 | 293 | | =a= | entries with a =SCHEDULED= or =DEADLINE= on or after a date | =org-check-after-date= | |
| 294 | 294 | | =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> |
| 133 | 133 | #+END_SRC |
| 134 | 134 | |
| 135 | 135 | - =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. |
| 137 | 137 | |
| 138 | 138 | | Command | Org command | Emacs, Doom | Mac | Doom leader | |
| 139 | 139 | |------------------+------------------+-------------+------+-------------| |
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 |
| 95 | 95 | |
| 96 | 96 | Details: |
| 97 | 97 | |
| 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. |
| 99 | 99 | - A =-Nd= cookie on a =SCHEDULED= timestamp delays it: the entry first shows N days after the scheduled date. |
| 100 | 100 | - Repeaters on =SCHEDULED= and =DEADLINE= timestamps (=+1w=, =++1w=, =.+1d=) make the entry show on the next occurrence on future days, as in Org. |
| 101 | 101 | - 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 |
| 155 | 155 | | =tab-bar= | View ▸ Show Tab Bar | |
| 156 | 156 | | =show-markup= | View ▸ Show Markup (=⇧⌘M=) | |
| 157 | 157 | | =ignored-folders= | | |
| 158 | | =org-deadline-warning-days= | | |
| 158 | 159 | | =org-agenda-skip-scheduled-if-done= | | |
| 159 | 160 | | =org-agenda-skip-deadline-if-done= | | |
| 160 | 161 | | =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 |
| 199 | 200 | | =display-line-numbers-type= | boolean | =true= | Line numbers in the editor's gutter. orgstar numbers lines absolutely; there is no relative or visual mode. | |
| 200 | 201 | | =org-agenda-span= | integer | =10= | Days the agenda shows. Mirrors =org-agenda-span=. | |
| 201 | 202 | | =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=. | |
| 202 | 204 | | =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=. | |
| 203 | 205 | | =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=. | |
| 204 | 206 | | =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: |
| 350 | 350 | - =org-enforce-todo-dependencies=, =org-enforce-todo-checkbox-dependencies=, =org-agenda-dim-blocked-tasks= |
| 351 | 351 | - =org-use-speed-commands=, with a hardware keyboard |
| 352 | 352 | - =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= |
| 354 | 354 | - =calendar-events=, =calendar-event-calendars= |
| 355 | 355 | - =reminders=, =appt-message-warning-time= |
| 356 | 356 | - =org-clock-history-length= |