Commit 19e897579c

19e897579c16e1aaae584cd93ed3ee1c0deba83d

parent: e518d4306e

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-11 08:41 UTC

Agenda: org-agenda-todo-ignore-* options

org-agenda-todo-ignore-with-date, -scheduled, -deadlines and -timestamp leave entries out of the TODO list as org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item does, searches sharing one position as in Org; org-agenda-tags-todo-honor-ignore-options applies them to TODO-only matches. Read from config.toml and imported. Oracle-tested for every value.

Closes #15

Layout: unified · split

Sources/OrgApp/AgendaModel.swift +1 −1
@@ -91,7 +91,7 @@ public final class AgendaModel {
91 events = provider.events(from: from, to: Self.date(first + span, calendar: calendar), chosen: names) 91 events = provider.events(from: from, to: Self.date(first + span, calendar: calendar), chosen: names)
92 } 92 }
93 case .todo(let keywords): 93 case .todo(let keywords):
94 list = Agenda.todoList(all, keywords: keywords, options: options) 94 list = Agenda.todoList(all, keywords: keywords, options: options, today: today)
95 case .match(let match, let todoOnly): 95 case .match(let match, let todoOnly):
96 list = Agenda.tagsMatch(all, match: match, todoOnly: todoOnly, now: now, calendar: calendar, options: options) 96 list = Agenda.tagsMatch(all, match: match, todoOnly: todoOnly, now: now, calendar: calendar, options: options)
97 case .search(let string, let todoOnly): 97 case .search(let string, let todoOnly):
Sources/OrgApp/EmacsImport.swift +4 −1
@@ -486,13 +486,16 @@ public struct EmacsImport: Sendable {
486 case "org-insert-heading-respect-content", "org-list-allow-alphabetical", "org-hide-emphasis-markers", "org-pretty-entities", 486 case "org-insert-heading-respect-content", "org-list-allow-alphabetical", "org-hide-emphasis-markers", "org-pretty-entities",
487 "org-cycle-hide-drawer-startup", "org-cycle-hide-block-startup", "org-use-speed-commands", "org-startup-with-inline-images", 487 "org-cycle-hide-drawer-startup", "org-cycle-hide-block-startup", "org-use-speed-commands", "org-startup-with-inline-images",
488 "org-startup-indented", "org-hide-leading-stars", "org-startup-align-all-tables", "org-startup-truncated", 488 "org-startup-indented", "org-hide-leading-stars", "org-startup-align-all-tables", "org-startup-truncated",
489 "org-enforce-todo-dependencies", "org-enforce-todo-checkbox-dependencies": 489 "org-enforce-todo-dependencies", "org-enforce-todo-checkbox-dependencies",
490 "org-agenda-todo-ignore-with-date", "org-agenda-tags-todo-honor-ignore-options":
490 add(name, .bool(truthy)) 491 add(name, .bool(truthy))
491 case "org-archive-location": 492 case "org-archive-location":
492 guard let location = value.string, location.contains("::") else { return note("not a file::heading location") } 493 guard let location = value.string, location.contains("::") else { return note("not a file::heading location") }
493 add(name, .string(location)) 494 add(name, .string(location))
494 case "org-track-ordered-property-with-tag": 495 case "org-track-ordered-property-with-tag":
495 if let tag = value.string { add(name, .string(tag)) } else { add(name, .string(truthy ? "t" : "nil")) } 496 if let tag = value.string { add(name, .string(tag)) } else { add(name, .string(truthy ? "t" : "nil")) }
497 case "org-agenda-todo-ignore-scheduled", "org-agenda-todo-ignore-deadlines", "org-agenda-todo-ignore-timestamp":
498 if let days = value.integer { add(name, .string("\(days)")) } else if let symbol = value.symbol, AgendaOptions.TodoIgnore(symbol) != nil { add(name, .string(symbol)) } else { note("unexpected value \(value.description)") }
496 case "org-structure-template-alist": 499 case "org-structure-template-alist":
497 structureTemplates(value.elements ?? [], source: source, id: id) 500 structureTemplates(value.elements ?? [], source: source, id: id)
498 case "org-agenda-dim-blocked-tasks": 501 case "org-agenda-dim-blocked-tasks":
Sources/OrgApp/OrgPreferences.swift +5
@@ -81,6 +81,11 @@ public enum OrgPreferences {
81 options.enforceTodoDependencies = bool("enforceTodoDependencies", defaults) 81 options.enforceTodoDependencies = bool("enforceTodoDependencies", defaults)
82 options.enforceTodoCheckboxDependencies = bool("enforceTodoCheckboxDependencies", defaults) 82 options.enforceTodoCheckboxDependencies = bool("enforceTodoCheckboxDependencies", defaults)
83 options.dimBlockedTasks = AgendaOptions.DimBlocked(rawValue: string("agendaDimBlockedTasks", defaults)) ?? .dim 83 options.dimBlockedTasks = AgendaOptions.DimBlocked(rawValue: string("agendaDimBlockedTasks", defaults)) ?? .dim
84 options.todoIgnoreWithDate = bool("agendaTodoIgnoreWithDate", defaults)
85 options.todoIgnoreScheduled = AgendaOptions.TodoIgnore(string("agendaTodoIgnoreScheduled", defaults)) ?? .off
86 options.todoIgnoreDeadlines = AgendaOptions.TodoIgnore(string("agendaTodoIgnoreDeadlines", defaults), deadlines: true) ?? .off
87 options.todoIgnoreTimestamp = AgendaOptions.TodoIgnore(string("agendaTodoIgnoreTimestamp", defaults)) ?? .off
88 options.tagsTodoHonorIgnoreOptions = bool("agendaTagsTodoHonorIgnore", defaults)
84 return options 89 return options
85 } 90 }
86 /// `calendar-events`: Calendar's events show in the agenda. 91 /// `calendar-events`: Calendar's events show in the agenda.
Sources/OrgApp/UserConfig.swift +10
@@ -162,6 +162,16 @@ public enum UserConfig {
162 comment: "leave done entries out of the agenda even on the day they are scheduled", legacy: ""), 162 comment: "leave done entries out of the agenda even on the day they are scheduled", legacy: ""),
163 Setting(section: "", key: "org-agenda-skip-deadline-if-done", defaultsKey: "agendaSkipDeadlineIfDone", kind: .bool, fallback: .bool(false), 163 Setting(section: "", key: "org-agenda-skip-deadline-if-done", defaultsKey: "agendaSkipDeadlineIfDone", kind: .bool, fallback: .bool(false),
164 comment: "leave done entries out of the agenda even on the day they are due", legacy: ""), 164 comment: "leave done entries out of the agenda even on the day they are due", legacy: ""),
165 Setting(section: "", key: "org-agenda-todo-ignore-with-date", defaultsKey: "agendaTodoIgnoreWithDate", kind: .bool, fallback: .bool(false),
166 comment: "the TODO list leaves out entries with any active timestamp", legacy: ""),
167 Setting(section: "", key: "org-agenda-todo-ignore-scheduled", defaultsKey: "agendaTodoIgnoreScheduled", kind: .string, fallback: .string("nil"),
168 comment: "the TODO list leaves out scheduled entries: nil, all, future, past, or days ahead (negative: days ago)", legacy: ""),
169 Setting(section: "", key: "org-agenda-todo-ignore-deadlines", defaultsKey: "agendaTodoIgnoreDeadlines", kind: .string, fallback: .string("nil"),
170 comment: "the TODO list leaves out entries with deadlines: nil, near, far, all, future, past, or days", legacy: ""),
171 Setting(section: "", key: "org-agenda-todo-ignore-timestamp", defaultsKey: "agendaTodoIgnoreTimestamp", kind: .string, fallback: .string("nil"),
172 comment: "the TODO list leaves out entries with other active timestamps: nil, all, future, past, or days", legacy: ""),
173 Setting(section: "", key: "org-agenda-tags-todo-honor-ignore-options", defaultsKey: "agendaTagsTodoHonorIgnore", kind: .bool, fallback: .bool(false),
174 comment: "the org-agenda-todo-ignore settings apply to TODO-only matches too", legacy: ""),
165 Setting(section: "", key: "org-agenda-search-view-always-boolean", defaultsKey: "agendaSearchAlwaysBoolean", kind: .bool, fallback: .bool(false), 175 Setting(section: "", key: "org-agenda-search-view-always-boolean", defaultsKey: "agendaSearchAlwaysBoolean", kind: .bool, fallback: .bool(false),
166 comment: "search strings are always +word -word {regexp} snippets, never a phrase", legacy: ""), 176 comment: "search strings are always +word -word {regexp} snippets, never a phrase", legacy: ""),
167 Setting(section: "", key: "org-agenda-search-view-force-full-words", defaultsKey: "agendaSearchForceFullWords", kind: .bool, fallback: .bool(false), 177 Setting(section: "", key: "org-agenda-search-view-force-full-words", defaultsKey: "agendaSearchForceFullWords", kind: .bool, fallback: .bool(false),
Sources/OrgCore/Agenda/Agenda.swift +37
@@ -96,6 +96,43 @@ public struct AgendaOptions: Sendable, Equatable {
96 public var enforceTodoCheckboxDependencies = false 96 public var enforceTodoCheckboxDependencies = false
97 /// `org-agenda-dim-blocked-tasks`. 97 /// `org-agenda-dim-blocked-tasks`.
98 public var dimBlockedTasks = DimBlocked.dim 98 public var dimBlockedTasks = DimBlocked.dim
99 /// `org-agenda-todo-ignore-with-date`, `-scheduled`, `-deadlines` and `-timestamp`: TODO
100 /// entries the TODO list leaves out for their timestamps.
101 public var todoIgnoreWithDate = false
102 public var todoIgnoreScheduled = TodoIgnore.off
103 public var todoIgnoreDeadlines = TodoIgnore.off
104 public var todoIgnoreTimestamp = TodoIgnore.off
105 /// `org-agenda-tags-todo-honor-ignore-options`: the TODO-only match views leave them out too.
106 public var tagsTodoHonorIgnoreOptions = false
107
108 /// A value of the `org-agenda-todo-ignore-*` options.
109 public enum TodoIgnore: Sendable, Equatable {
110 case off
111 /// `t` or `all`; for deadlines `all` alone, as `t` means `near`.
112 case all
113 case future, past
114 /// Deadlines: within their warning period (`t`, `near`), or beyond it (`far`).
115 case near, far
116 /// More than n days ahead, or for a negative n, at least -n days ago.
117 case days(Int)
118
119 /// As `config.toml` writes it: `nil`, `t`, `all`, `future`, `past`, `near`, `far` or a
120 /// number of days. `t` is `near` for `deadlines`.
121 public init?(_ text: String, deadlines: Bool = false) {
122 switch text {
123 case "nil", "": self = .off
124 case "t": self = deadlines ? .near : .all
125 case "all": self = .all
126 case "future": self = .future
127 case "past": self = .past
128 case "near": self = .near
129 case "far": self = .far
130 default:
131 guard let n = Int(text) else { return nil }
132 self = .days(n)
133 }
134 }
135 }
99 136
100 public enum DimBlocked: String, Sendable { 137 public enum DimBlocked: String, Sendable {
101 case off = "nil", dim = "t", invisible 138 case off = "nil", dim = "t", invisible
Sources/OrgCore/Agenda/AgendaSearch.swift +66 −4
@@ -2,18 +2,20 @@ import Foundation
2 2
3extension Agenda { 3extension Agenda {
4 /// `org-todo-list`: unfinished entries, or with `keywords` (`WAIT|HOLD`) those with any of 4 /// `org-todo-list`: unfinished entries, or with `keywords` (`WAIT|HOLD`) those with any of
5 /// the keywords. 5 /// the keywords, without those the `todoIgnore` options leave out on `today`.
6 public static func todoList(_ sources: [AgendaSource], keywords: String? = nil, options: AgendaOptions = AgendaOptions()) -> [AgendaItem] { 6 public static func todoList(_ sources: [AgendaSource], keywords: String? = nil, options: AgendaOptions = AgendaOptions(),
7 today: Int = Days.absolute(Date(), calendar: .current)) -> [AgendaItem] {
7 let selected = keywords.map { $0.split(separator: "|").map(String.init) } 8 let selected = keywords.map { $0.split(separator: "|").map(String.init) }
8 var items: [AgendaItem] = [] 9 var items: [AgendaItem] = []
9 for source in sources { 10 for source in sources {
10 for heading in source.headings where !heading.skipped { 11 for (index, heading) in source.headings.enumerated() where !heading.skipped {
11 guard let todo = heading.todo else { continue } 12 guard let todo = heading.todo else { continue }
12 if let selected { 13 if let selected {
13 guard selected.contains(todo) else { continue } 14 guard selected.contains(todo) else { continue }
14 } else if heading.isDone { 15 } else if heading.isDone {
15 continue 16 continue
16 } 17 }
18 if ignoresTodo(source, index, options: options, today: today) { continue }
17 items.append(format( 19 items.append(format(
18 source, heading, kind: .todo, marker: heading.start, extra: "", dotime: .headline, removing: nil, 20 source, heading, kind: .todo, marker: heading.start, extra: "", dotime: .headline, removing: nil,
19 trailing: "", prefix: options.prefix("todo"), urgency: { 1 + $0 } 21 trailing: "", prefix: options.prefix("todo"), urgency: { 1 + $0 }
@@ -30,11 +32,13 @@ extension Agenda {
30 options: AgendaOptions = AgendaOptions() 32 options: AgendaOptions = AgendaOptions()
31 ) -> [AgendaItem] { 33 ) -> [AgendaItem] {
32 let matcher = TagsMatcher(match, todoOnly: todoOnly) 34 let matcher = TagsMatcher(match, todoOnly: todoOnly)
35 let today = Days.absolute(now, calendar: calendar)
33 var items: [AgendaItem] = [] 36 var items: [AgendaItem] = []
34 for source in sources { 37 for source in sources {
35 for heading in source.headings { 38 for (index, heading) in source.headings.enumerated() {
36 if matcher.todoOnly, heading.todo == nil { continue } 39 if matcher.todoOnly, heading.todo == nil { continue }
37 guard matcher.matches(heading, in: source, now: now, calendar: calendar), !heading.skipped else { continue } 40 guard matcher.matches(heading, in: source, now: now, calendar: calendar), !heading.skipped else { continue }
41 if matcher.todoOnly, options.tagsTodoHonorIgnoreOptions, ignoresTodo(source, index, options: options, today: today) { continue }
38 items.append(format( 42 items.append(format(
39 source, heading, kind: .tagsMatch, marker: heading.start, extra: "", dotime: nil, removing: nil, 43 source, heading, kind: .tagsMatch, marker: heading.start, extra: "", dotime: nil, removing: nil,
40 trailing: "", prefix: options.prefix("tags"), urgency: { $0 } 44 trailing: "", prefix: options.prefix("tags"), urgency: { $0 }
@@ -44,6 +48,64 @@ extension Agenda {
44 return sortByUrgency(markBlocked(items, options: options)) 48 return sortByUrgency(markBlocked(items, options: options))
45 } 49 }
46 50
51 /// `org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item` for the entry of heading
52 /// `index`, from its heading line to the next heading. The searches go on from where the
53 /// last one matched, as Org's do.
54 static func ignoresTodo(_ source: AgendaSource, _ index: Int, options: AgendaOptions, today: Int) -> Bool {
55 guard options.todoIgnoreWithDate || options.todoIgnoreScheduled != .off || options.todoIgnoreDeadlines != .off
56 || options.todoIgnoreTimestamp != .off else { return false }
57 let ns = source.text as NSString
58 let start = source.headings[index].start
59 let end = index + 1 < source.headings.count ? source.headings[index + 1].start : ns.length
60 var point = start
61 func search(_ regex: NSRegularExpression) -> String? {
62 guard let m = regex.firstMatch(in: source.text, range: NSRange(location: point, length: end - point)) else { return nil }
63 point = NSMaxRange(m.range)
64 return ns.substring(with: m.range(at: 1))
65 }
66 func days(_ stamp: String) -> Int { (Days.absolute(of: stamp) ?? today) - today }
67 func custom(_ stamp: String, _ n: Int) -> Bool { n >= 0 ? days(stamp) >= n : days(stamp) <= n }
68 if options.todoIgnoreWithDate, search(Self.activeStampRegex) != nil { return true }
69 if options.todoIgnoreScheduled != .off, let stamp = search(Self.scheduledRegex) {
70 switch options.todoIgnoreScheduled {
71 case .future: if days(stamp) > 0 { return true }
72 case .past: if days(stamp) <= 0 { return true }
73 case .days(let n): if custom(stamp, n) { return true }
74 default: return true
75 }
76 }
77 if options.todoIgnoreDeadlines != .off, let stamp = search(Self.deadlineRegex) {
78 let close = days(stamp) <= Days.warningDays(stamp, delay: false, defaultDays: options.deadlineWarningDays) && !source.headings[index].isDone
79 switch options.todoIgnoreDeadlines {
80 case .all: return true
81 case .far: if !close { return true }
82 case .future: if days(stamp) > 0 { return true }
83 case .past: if days(stamp) <= 0 { return true }
84 case .days(let n): if custom(stamp, n) { return true }
85 default: if close { return true }
86 }
87 }
88 if options.todoIgnoreTimestamp != .off {
89 // The other timestamps, without SCHEDULED and DEADLINE ones.
90 let rest = Self.planningStampRegex.stringByReplacingMatches(in: ns.substring(with: NSRange(location: point, length: end - point)), range: NSRange(location: 0, length: end - point), withTemplate: "")
91 guard let m = Self.activeStampRegex.firstMatch(in: rest, range: NSRange(location: 0, length: (rest as NSString).length)) else { return false }
92 let stamp = (rest as NSString).substring(with: m.range(at: 1))
93 switch options.todoIgnoreTimestamp {
94 case .future: return days(stamp) > 0
95 case .past: return days(stamp) <= 0
96 case .days(let n): return custom(stamp, n)
97 default: return true
98 }
99 }
100 return false
101 }
102
103 /// `org-ts-regexp`, `org-scheduled-time-regexp` and `org-deadline-time-regexp`.
104 static let activeStampRegex = try! NSRegularExpression(pattern: "<([0-9]{4}-[0-9]{2}-[0-9]{2}(?: .*?)?)>")
105 static let scheduledRegex = try! NSRegularExpression(pattern: "\\bSCHEDULED: *<([^>]+)>")
106 static let deadlineRegex = try! NSRegularExpression(pattern: "\\bDEADLINE: *<([^>]+)>")
107 static let planningStampRegex = try! NSRegularExpression(pattern: "\\bSCHEDULED: *<[^>]+>|\\bDEADLINE: *<[^>]+>")
108
47 /// `org-search-view`: entries, heading and body, containing `string` as a phrase, or with 109 /// `org-search-view`: entries, heading and body, containing `string` as a phrase, or with
48 /// a leading `+`, `-` or `{` (or `searchAlwaysBoolean`) matching each of its snippets. A 110 /// a leading `+`, `-` or `{` (or `searchAlwaysBoolean`) matching each of its snippets. A
49 /// leading `*` searches headlines only, `!` keeps unfinished TODO entries as `todoOnly` 111 /// leading `*` searches headlines only, `!` keeps unfinished TODO entries as `todoOnly`
Tests/OrgAppTests/EmacsImportTests.swift +4 −1
@@ -45,6 +45,8 @@ struct EmacsImportTests {
45 org-agenda-start-on-weekday 0 45 org-agenda-start-on-weekday 0
46 org-track-ordered-property-with-tag t 46 org-track-ordered-property-with-tag t
47 org-archive-location "archive/%s::" 47 org-archive-location "archive/%s::"
48 org-agenda-todo-ignore-scheduled 'future
49 org-agenda-todo-ignore-deadlines 7
48 org-agenda-start-day "-3d" 50 org-agenda-start-day "-3d"
49 org-clock-idle-time 15 51 org-clock-idle-time 15
50 org-clock-history-length 10 52 org-clock-history-length 10
@@ -90,6 +92,7 @@ struct EmacsImportTests {
90 #expect(s["org-agenda-start-on-weekday"] == .string("0")) 92 #expect(s["org-agenda-start-on-weekday"] == .string("0"))
91 #expect(s["org-track-ordered-property-with-tag"] == .string("t")) 93 #expect(s["org-track-ordered-property-with-tag"] == .string("t"))
92 #expect(s["org-archive-location"] == .string("archive/%s::")) 94 #expect(s["org-archive-location"] == .string("archive/%s::"))
95 #expect(s["org-agenda-todo-ignore-scheduled"] == .string("future") && s["org-agenda-todo-ignore-deadlines"] == .string("7"))
93 #expect(s["org-agenda-start-day"] == .string("-3d")) 96 #expect(s["org-agenda-start-day"] == .string("-3d"))
94 #expect(s["org-clock-idle-time"] == .integer(15)) 97 #expect(s["org-clock-idle-time"] == .integer(15))
95 #expect(s["org-clock-history-length"] == .integer(10)) 98 #expect(s["org-clock-history-length"] == .integer(10))
@@ -181,7 +184,7 @@ struct EmacsImportTests {
181 let keymap = folder.appendingPathComponent("keymap.toml") 184 let keymap = folder.appendingPathComponent("keymap.toml")
182 #expect(KeymapLoader.load(.doom, userFile: keymap).problems.isEmpty) 185 #expect(KeymapLoader.load(.doom, userFile: keymap).problems.isEmpty)
183 #expect(KeymapLoader.load(.doom, userFile: keymap).keymap.keyLabels(for: "app.agenda", modes: ["normal"]).contains("C-c a")) 186 #expect(KeymapLoader.load(.doom, userFile: keymap).keymap.keyLabels(for: "app.agenda", modes: ["normal"]).contains("C-c a"))
184 #expect(summary.hasPrefix("Imported 23 settings, 3 capture templates, 3 key bindings, 2 structure templates."), "\(summary)") 187 #expect(summary.hasPrefix("Imported 25 settings, 3 capture templates, 3 key bindings, 2 structure templates."), "\(summary)")
185 #expect(UserConfig.structureTemplates(defaults) == [.init(key: "el", type: "src emacs-lisp"), .init(key: "q", type: "QUOTE")]) 188 #expect(UserConfig.structureTemplates(defaults) == [.init(key: "el", type: "src emacs-lisp"), .init(key: "q", type: "QUOTE")])
186 #expect(OrgPreferences.options(defaults).structureTemplates?.first { $0.key == "q" }?.type == "QUOTE") 189 #expect(OrgPreferences.options(defaults).structureTemplates?.first { $0.key == "q" }?.type == "QUOTE")
187 #expect(defaults.string(forKey: "themeFont") == "JetBrains Mono") 190 #expect(defaults.string(forKey: "themeFont") == "JetBrains Mono")
Tests/OrgAppTests/OrgPreferencesTests.swift +4
@@ -32,6 +32,8 @@ struct OrgPreferencesTests {
32 org-agenda-start-on-weekday = "nil" 32 org-agenda-start-on-weekday = "nil"
33 org-track-ordered-property-with-tag = "t" 33 org-track-ordered-property-with-tag = "t"
34 org-archive-location = "~/org/archive.org::* %s" 34 org-archive-location = "~/org/archive.org::* %s"
35 org-agenda-todo-ignore-deadlines = "t"
36 org-agenda-todo-ignore-scheduled = "-2"
35 org-M-RET-may-split-line = true 37 org-M-RET-may-split-line = true
36 org-hide-emphasis-markers = false 38 org-hide-emphasis-markers = false
37 org-pretty-entities = false 39 org-pretty-entities = false
@@ -48,6 +50,8 @@ struct OrgPreferencesTests {
48 #expect(OrgPreferences.agendaStartOnWeekday(defaults) == nil) 50 #expect(OrgPreferences.agendaStartOnWeekday(defaults) == nil)
49 #expect(OrgPreferences.options(defaults).trackOrderedPropertyWithTag == "ORDERED") 51 #expect(OrgPreferences.options(defaults).trackOrderedPropertyWithTag == "ORDERED")
50 #expect(OrgPreferences.options(defaults).archiveLocation == "~/org/archive.org::* %s") 52 #expect(OrgPreferences.options(defaults).archiveLocation == "~/org/archive.org::* %s")
53 let ignoring = OrgPreferences.agendaOptions(AgendaOptions(), defaults)
54 #expect(ignoring.todoIgnoreDeadlines == .near && ignoring.todoIgnoreScheduled == .days(-2) && ignoring.todoIgnoreTimestamp == .off)
51 #expect(OrgPreferences.agendaOptions(AgendaOptions(), defaults).deadlineWarningDays == 5) 55 #expect(OrgPreferences.agendaOptions(AgendaOptions(), defaults).deadlineWarningDays == 5)
52 #expect(!OrgPreferences.reminders(defaults) && OrgPreferences.reminderLead(defaults) == 30) 56 #expect(!OrgPreferences.reminders(defaults) && OrgPreferences.reminderLead(defaults) == 30)
53 #expect(UserConfig.apply("org-agenda-start-on-weekday = \"0\"", to: defaults).isEmpty) 57 #expect(UserConfig.apply("org-agenda-start-on-weekday = \"0\"", to: defaults).isEmpty)
Tests/OrgCoreTests/AgendaTests.swift +66
@@ -598,3 +598,69 @@ struct AgendaFilterTests {
598 #expect(negative.description == "-/call/") 598 #expect(negative.description == "-/call/")
599 } 599 }
600} 600}
601
602/// `org-agenda-todo-ignore-*` and `org-agenda-tags-todo-honor-ignore-options`.
603struct TodoIgnoreTests {
604 static let file = """
605 * TODO Sched past
606 SCHEDULED: <2026-10-01 Thu>
607 * TODO Sched today
608 SCHEDULED: <2026-10-05 Mon>
609 * TODO Sched future
610 SCHEDULED: <2026-10-20 Tue>
611 * TODO Deadline near
612 DEADLINE: <2026-10-10 Sat>
613 * TODO Deadline far
614 DEADLINE: <2026-12-01 Tue>
615 * TODO Deadline past
616 DEADLINE: <2026-09-01 Tue>
617 * TODO Deadline then scheduled
618 DEADLINE: <2026-10-06 Tue> SCHEDULED: <2026-10-04 Sun>
619 * TODO Scheduled then deadline
620 SCHEDULED: <2026-10-04 Sun> DEADLINE: <2026-10-06 Tue>
621 * TODO Stamp in heading <2026-11-01 Sun>
622 * TODO Stamp in body
623 Meeting <2026-09-20 Sun>
624 * TODO Inactive only [2026-10-01 Thu]
625 * TODO None :work:
626 * TODO Long warning :work:
627 DEADLINE: <2026-10-30 Fri -30d>
628
629 """
630
631 @Test(.enabled(if: ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil))
632 func ignoresLikeOrg() throws {
633 let today = Days.absolute(year: 2026, month: 10, day: 5)
634 let files = [("i.org", Self.file)]
635 let settings: [(String, String, (inout AgendaOptions) -> Void)] = [
636 ("org-agenda-todo-ignore-with-date", "t", { $0.todoIgnoreWithDate = true }),
637 ] + ["t", "all", "future", "past", "3", "-3"].map { v in
638 ("org-agenda-todo-ignore-scheduled", v.first!.isNumber || v.first == "-" ? v : "'" + v, { $0.todoIgnoreScheduled = AgendaOptions.TodoIgnore(v)! })
639 } + ["t", "near", "far", "all", "future", "past", "10", "-10"].map { v in
640 ("org-agenda-todo-ignore-deadlines", v.first!.isNumber || v.first == "-" ? v : "'" + v, { $0.todoIgnoreDeadlines = AgendaOptions.TodoIgnore(v, deadlines: true)! })
641 } + ["t", "future", "past", "20"].map { v in
642 ("org-agenda-todo-ignore-timestamp", v.first!.isNumber ? v : "'" + v, { $0.todoIgnoreTimestamp = AgendaOptions.TodoIgnore(v)! })
643 }
644 for (name, value, set) in settings {
645 var options = AgendaOptions()
646 set(&options)
647 try AgendaOracle.compareList(files: files, form: "(let ((\(name) \(value))) (org-todo-list nil))", today: today) {
648 Agenda.todoList($0, options: options, today: today)
649 }
650 }
651 // TODO-only matches honor them only when asked.
652 var utc = Calendar(identifier: .gregorian)
653 utc.timeZone = TimeZone(identifier: "UTC")!
654 let now = Date(timeIntervalSince1970: Double((today - 719163) * 86400 + 9 * 3600 + 30 * 60))
655 for honor in [false, true] {
656 var options = AgendaOptions()
657 options.todoIgnoreDeadlines = .all
658 options.tagsTodoHonorIgnoreOptions = honor
659 try AgendaOracle.compareList(
660 files: files,
661 form: "(let ((org-agenda-todo-ignore-deadlines 'all) (org-agenda-tags-todo-honor-ignore-options \(honor ? "t" : "nil"))) (org-tags-view t \"work\"))",
662 today: today
663 ) { Agenda.tagsMatch($0, match: "work", todoOnly: true, now: now, calendar: utc, options: options) }
664 }
665 }
666}
docs/manual/guide/07-agenda.org +1 −1
@@ -263,7 +263,7 @@ Future days use lighter shades. On the Mac, hover a cell to see its date. Habits
263 263
264* The TODO list 264* The TODO list
265 265
266The built-in view TODO List is =org-todo-list=: every heading with a TODO keyword that is not a done keyword, sorted by urgency (priority first). The time-based skipping options (=org-agenda-todo-ignore-scheduled= and its relatives) are not supported; every open TODO appears, as with Org's defaults. 266The built-in view TODO List is =org-todo-list=: every heading with a TODO keyword that is not a done keyword, sorted by urgency (priority first). By default every open TODO appears, as in Org. =org-agenda-todo-ignore-scheduled=, =org-agenda-todo-ignore-deadlines=, =org-agenda-todo-ignore-timestamp= and =org-agenda-todo-ignore-with-date= in =config.toml= leave out entries for their timestamps, so that the TODO list shows only what isn't already on the calendar; see [[file:13-configuration.org][Configuration]]. As in Org, the searches look through the entry's text in order, so with both set, a =SCHEDULED= that doesn't leave the entry out hides a =DEADLINE= before it on the same line. With =org-agenda-tags-todo-honor-ignore-options=, TODO-only matches leave the same entries out.
267 267
268A saved view can list specific keywords instead, done ones included, with =keywords = "WAIT|HOLD"= (see [[*Views][Views]]). This mirrors =C-u M-x org-todo-list= with a keyword argument. 268A saved view can list specific keywords instead, done ones included, with =keywords = "WAIT|HOLD"= (see [[*Views][Views]]). This mirrors =C-u M-x org-todo-list= with a keyword argument.
269 269
docs/manual/guide/13-configuration.org +7
@@ -161,6 +161,7 @@ These settings have no control in the Settings window. Some are in the View menu
161| =org-deadline-warning-days= | | 161| =org-deadline-warning-days= | |
162| =org-agenda-skip-scheduled-if-done= | | 162| =org-agenda-skip-scheduled-if-done= | |
163| =org-agenda-skip-deadline-if-done= | | 163| =org-agenda-skip-deadline-if-done= | |
164| =org-agenda-todo-ignore-with-date=, =org-agenda-todo-ignore-scheduled=, =org-agenda-todo-ignore-deadlines=, =org-agenda-todo-ignore-timestamp=, =org-agenda-tags-todo-honor-ignore-options= | |
164| =org-agenda-search-view-always-boolean= | | 165| =org-agenda-search-view-always-boolean= | |
165| =org-agenda-search-view-force-full-words= | | 166| =org-agenda-search-view-force-full-words= | |
166| =[org-agenda-prefix-format]= | | 167| =[org-agenda-prefix-format]= | |
@@ -210,6 +211,11 @@ A key you remove from the file goes back to its default. A key that isn't in the
210| =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=. | 211| =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=. |
211| =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=. | 212| =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=. |
212| =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=. | 213| =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=. |
214| =org-agenda-todo-ignore-with-date= | boolean | =false= | The TODO list leaves out entries with an active timestamp anywhere in their text. Mirrors =org-agenda-todo-ignore-with-date=. |
215| =org-agenda-todo-ignore-scheduled= | string | ="nil"= | The TODO list leaves out scheduled entries: ="all"= (or ="t"=) all of them, ="future"= those scheduled after today, ="past"= today or before, ="N"= N or more days ahead, ="-N"= N or more days ago. Mirrors =org-agenda-todo-ignore-scheduled=. |
216| =org-agenda-todo-ignore-deadlines= | string | ="nil"= | As the last, for deadlines: ="near"= (or ="t"=) those within their warning period, ="far"= those beyond it, ="all"=, ="future"=, ="past"=, ="N"=, ="-N"=. Mirrors =org-agenda-todo-ignore-deadlines=. |
217| =org-agenda-todo-ignore-timestamp= | string | ="nil"= | As the last, for other active timestamps in the entry: ="all"= (or ="t"=), ="future"=, ="past"=, ="N"=, ="-N"=. Mirrors =org-agenda-todo-ignore-timestamp=. |
218| =org-agenda-tags-todo-honor-ignore-options= | boolean | =false= | The four settings above apply to TODO-only matches (=M=) too. Mirrors =org-agenda-tags-todo-honor-ignore-options=. |
213| =org-agenda-search-view-always-boolean= | boolean | =false= | The agenda's text search reads every string as =+word -word {regexp}= snippets, never as a phrase. Mirrors =org-agenda-search-view-always-boolean=. | 219| =org-agenda-search-view-always-boolean= | boolean | =false= | The agenda's text search reads every string as =+word -word {regexp}= snippets, never as a phrase. Mirrors =org-agenda-search-view-always-boolean=. |
214| =org-agenda-search-view-force-full-words= | boolean | =false= | Text search snippets match whole words only, as a leading =:= does. Mirrors =org-agenda-search-view-force-full-words=. | 220| =org-agenda-search-view-force-full-words= | boolean | =false= | Text search snippets match whole words only, as a leading =:= does. Mirrors =org-agenda-search-view-force-full-words=. |
215| =org-agenda-dim-blocked-tasks= | string | ="t"= | =t= dims entries the two enforce settings block, =invisible= hides them (entries blocked only by checkboxes are still dimmed), =nil= shows them as usual. Mirrors =org-agenda-dim-blocked-tasks=. | 221| =org-agenda-dim-blocked-tasks= | string | ="t"= | =t= dims entries the two enforce settings block, =invisible= hides them (entries blocked only by checkboxes are still dimmed), =nil= shows them as usual. Mirrors =org-agenda-dim-blocked-tasks=. |
@@ -465,6 +471,7 @@ Only variables whose names start with =org-=, =appt-=, =display-line-numbers=, =
465| =org-clock-history-length= | The same key, when the value is a positive number | 471| =org-clock-history-length= | The same key, when the value is a positive number |
466| =org-agenda-start-day= | A day offset such as ="-3d"=; =nil= becomes ="+0d"=. Other forms aren't supported. | 472| =org-agenda-start-day= | A day offset such as ="-3d"=; =nil= becomes ="+0d"=. Other forms aren't supported. |
467| =org-agenda-start-on-weekday= | ="0"= to ="6"=, or ="nil"= | 473| =org-agenda-start-on-weekday= | ="0"= to ="6"=, or ="nil"= |
474| =org-agenda-todo-ignore-scheduled=, =-deadlines=, =-timestamp= | The symbol or number as a string; =org-agenda-todo-ignore-with-date= and =org-agenda-tags-todo-honor-ignore-options= as booleans |
468| =org-track-ordered-property-with-tag= | A tag name as given; =t= becomes ="t"=, =nil= ="nil"= | 475| =org-track-ordered-property-with-tag= | A tag name as given; =t= becomes ="t"=, =nil= ="nil"= |
469| =org-archive-location= | The same key, when the value is a =file::heading= string | 476| =org-archive-location= | The same key, when the value is a =file::heading= string |
470| =org-structure-template-alist= | =[org-structure-template-alist]=: each =("key" . "type")= entry that isn't one of Org's, from =setq= or =(add-to-list 'org-structure-template-alist …)= | 477| =org-structure-template-alist= | =[org-structure-template-alist]=: each =("key" . "type")= entry that isn't one of Org's, from =setq= or =(add-to-list 'org-structure-template-alist …)= |
docs/manual/guide/14-ios.org +1 −1
@@ -351,7 +351,7 @@ These settings from =config.toml= apply on iOS:
351- =org-archive-location=, =[org-structure-template-alist]= 351- =org-archive-location=, =[org-structure-template-alist]=
352- =org-use-speed-commands=, with a hardware keyboard 352- =org-use-speed-commands=, with a hardware keyboard
353- =electric-pair-mode=, =spell-check= 353- =electric-pair-mode=, =spell-check=
354- =org-agenda-span=, =org-agenda-start-day=, =org-agenda-start-on-weekday=, =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- =org-agenda-span=, =org-agenda-start-day=, =org-agenda-start-on-weekday=, =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=, the =org-agenda-todo-ignore-= settings, =org-agenda-tags-todo-honor-ignore-options=
355- =calendar-events=, =calendar-event-calendars= 355- =calendar-events=, =calendar-event-calendars=
356- =reminders=, =appt-message-warning-time= 356- =reminders=, =appt-message-warning-time=
357- =org-clock-history-length= 357- =org-clock-history-length=