Commit d4ccb12cca
d4ccb12cca1f5f07b8acf23dc1cac828bb6a1498
parent: b3ba6ca101
Verified · cmc
cmc <hello@cleberg.net> · 2026-10-16 17:10 UTC
Setting to leave archive files out of the agenda
agenda-exclude-archives (Settings ▸ Agenda ▸ Leave out archive files on
iOS) drops the files other agenda files archive to, by #+ARCHIVE:, an
:ARCHIVE: property or org-archive-location, from the agenda, reminders,
widgets and the board.
Layout: unified · split
Sources/OrgApp/AgendaModel.swift
+9 −1
| @@ -36,6 +36,8 @@ public final class AgendaModel { |
| 36 | 36 | public var startOnWeekday: Int? = 1 |
| 37 | 37 | /// Files below the top level of each folder are agenda files too. |
| 38 | 38 | public var includeSubfolders = false |
| 39 | /// Files other agenda files archive to are left out. |
| 40 | public var excludeArchives = OrgPreferences.agendaExcludeArchives() |
| 39 | 41 | /// `org-agenda-files`: when not empty, the agenda reads these instead of the folders' files. |
| 40 | 42 | public var agendaFiles = OrgPreferences.agendaFiles() |
| 41 | 43 | public var options = AgendaOptions() |
| @@ -207,7 +209,13 @@ public final class AgendaModel { |
| 207 | 209 | cache.open[source.path] = (defaults, blocking, source.source) |
| 208 | 210 | } |
| 209 | 211 | } |
| 210 | | return loaded.map(\.source) |
| 212 | var sources = loaded.map(\.source) |
| 213 | if excludeArchives { |
| 214 | let location = OrgPreferences.options().archiveLocation ?? "%s_archive::" |
| 215 | let archives = Set(sources.flatMap { $0.archiveFiles(location: location) }) |
| 216 | sources.removeAll { archives.contains($0.path) } |
| 217 | } |
| 218 | return sources |
| 211 | 219 | } |
| 212 | 220 | |
| 213 | 221 | /// The days as rows with the events, empty days hidden unless `showAllDates`; see |
Sources/OrgApp/OrgPreferences.swift
+2
| @@ -95,6 +95,8 @@ public enum OrgPreferences { |
| 95 | 95 | return words == ["t"] || words.isEmpty ? [] : Set(words) |
| 96 | 96 | } |
| 97 | 97 | public static func agendaSubfolders(_ defaults: UserDefaults = .standard) -> Bool { bool("agendaSubfolders", defaults) } |
| 98 | /// The agenda leaves out the files other agenda files archive to. |
| 99 | public static func agendaExcludeArchives(_ defaults: UserDefaults = .standard) -> Bool { bool("agendaExcludeArchives", defaults) } |
| 98 | 100 | /// `org-agenda-show-all-dates`: days without entries show. |
| 99 | 101 | public static func agendaShowAllDates(_ defaults: UserDefaults = .standard) -> Bool { bool("agendaShowAllDates", defaults) } |
| 100 | 102 | public static func agendaSkipScheduledIfDone(_ defaults: UserDefaults = .standard) -> Bool { bool("agendaSkipScheduledIfDone", defaults) } |
Sources/OrgApp/UserConfig.swift
+2
| @@ -348,6 +348,8 @@ public enum UserConfig { |
| 348 | 348 | comment: "folder names never listed or searched, separated by spaces", legacy: ""), |
| 349 | 349 | Setting(section: "orgstar", key: "agenda-include-subfolders", defaultsKey: "agendaSubfolders", kind: .bool, fallback: .bool(false), |
| 350 | 350 | comment: "the agenda reads org files in subfolders too", legacy: "agenda.include-subfolders"), |
| 351 | Setting(section: "orgstar", key: "agenda-exclude-archives", defaultsKey: "agendaExcludeArchives", kind: .bool, fallback: .bool(false), |
| 352 | comment: "the agenda leaves out files that other agenda files archive to (#+ARCHIVE:, org-archive-location)", legacy: ""), |
| 351 | 353 | Setting(section: "orgstar", key: "reminders", defaultsKey: "reminders", kind: .bool, fallback: .bool(true), |
| 352 | 354 | comment: "notify before timed entries", legacy: "agenda.reminders"), |
| 353 | 355 | Setting(section: "orgstar", key: "calendar-events", defaultsKey: "calendarEvents", kind: .bool, fallback: .bool(false), |
Sources/OrgCore/Agenda/AgendaSource.swift
+15
| @@ -101,6 +101,12 @@ public struct AgendaSource: Sendable { |
| 101 | 101 | |
| 102 | 102 | let headings: [Heading] |
| 103 | 103 | |
| 104 | /// The other files this one archives to, as `org-all-archive-files` names them, with |
| 105 | /// `location` (`org-archive-location`) when the file sets none. |
| 106 | public func archiveFiles(location: String) -> [String] { |
| 107 | ([archiveKeyword ?? location] + archiveProperties).compactMap { Archive.archiveFile($0, sourcePath: path) }.filter { $0 != path } |
| 108 | } |
| 109 | |
| 104 | 110 | /// The file's habits not done and not in skipped trees: their titles, heading offsets and |
| 105 | 111 | /// what their consistency graphs are drawn from. |
| 106 | 112 | public var habits: [(title: String, offset: Int, habit: Habit)] { |
| @@ -121,6 +127,9 @@ public struct AgendaSource: Sendable { |
| 121 | 127 | let firstDone: [String: String] |
| 122 | 128 | /// The file's text, for the search view. |
| 123 | 129 | public let text: String |
| 130 | /// The archive locations the file names: its `#+ARCHIVE:`, then each `:ARCHIVE:` property's. |
| 131 | let archiveKeyword: String? |
| 132 | let archiveProperties: [String] |
| 124 | 133 | let priorities: Priorities |
| 125 | 134 | |
| 126 | 135 | /// `checksBlocking` false leaves every heading unblocked, for when neither enforce |
| @@ -159,6 +168,7 @@ public struct AgendaSource: Sendable { |
| 159 | 168 | func sectionStamps(_ index: Int) -> [String] { stampsByHeading[index] ?? [] } |
| 160 | 169 | |
| 161 | 170 | var keywordCategory = SetupFile.keywords(tree.settings.setupKeywords).last { $0.key == "CATEGORY" }?.value.trimmingCharacters(in: .whitespaces) |
| 171 | var archiveKeyword: String? |
| 162 | 172 | var srcBodies: [Range<Int>] = [] |
| 163 | 173 | var planningLines: [Range<Int>] = [] |
| 164 | 174 | var timestampNodes: [Int] = [] |
| @@ -170,6 +180,8 @@ public struct AgendaSource: Sendable { |
| 170 | 180 | let line = child.text.trimmingCharacters(in: .whitespacesAndNewlines) |
| 171 | 181 | if line.uppercased().hasPrefix("#+CATEGORY:") { |
| 172 | 182 | keywordCategory = line.dropFirst("#+CATEGORY:".count).trimmingCharacters(in: .whitespaces) |
| 183 | } else if archiveKeyword == nil, line.uppercased().hasPrefix("#+ARCHIVE:") { |
| 184 | archiveKeyword = line.dropFirst("#+ARCHIVE:".count).trimmingCharacters(in: .whitespaces) |
| 173 | 185 | } |
| 174 | 186 | case .block: |
| 175 | 187 | if DocumentModel.isSrcBlock(child) { |
| @@ -289,6 +301,9 @@ public struct AgendaSource: Sendable { |
| 289 | 301 | )) |
| 290 | 302 | } |
| 291 | 303 | self.headings = headings |
| 304 | self.archiveKeyword = archiveKeyword |
| 305 | ?? SetupFile.keywords(tree.settings.setupKeywords).last { $0.key == "ARCHIVE" }?.value.trimmingCharacters(in: .whitespaces) |
| 306 | archiveProperties = (model.property("ARCHIVE", of: nil).map { [$0.value] } ?? []) + headings.compactMap { $0.properties["ARCHIVE"] } |
| 292 | 307 | |
| 293 | 308 | let starts = model.headings.map(\.headingRange.lowerBound) |
| 294 | 309 | func heading(at offset: Int) -> Int? { |
Sources/Orgstar/AgendaView.swift
+1
| @@ -168,6 +168,7 @@ struct AgendaView: View { |
| 168 | 168 | agenda.startOffset = startOffset |
| 169 | 169 | agenda.startOnWeekday = Int(startOnWeekday) |
| 170 | 170 | agenda.includeSubfolders = includeSubfolders |
| 171 | agenda.excludeArchives = OrgPreferences.agendaExcludeArchives() |
| 171 | 172 | agenda.agendaFiles = OrgPreferences.agendaFiles() |
| 172 | 173 | agenda.options.prefixFormat = ["agenda": prefixAgenda, "todo": prefixTodo, "tags": prefixTags] |
| 173 | 174 | agenda.options.logMode = logMode |
Sources/Orgstar/BoardView.swift
+1
| @@ -79,6 +79,7 @@ struct BoardView: View { |
| 79 | 79 | .navigationTitle(kanban ? "Kanban" : "Entries") |
| 80 | 80 | .task(id: RefreshKey(match: match, subfolders: includeSubfolders, files: workspace.files.count, changed: workspace.changedFile?.version, edits: session.editVersion, path: session.path, tick: tick)) { |
| 81 | 81 | agenda.includeSubfolders = includeSubfolders |
| 82 | agenda.excludeArchives = OrgPreferences.agendaExcludeArchives() |
| 82 | 83 | agenda.agendaFiles = OrgPreferences.agendaFiles() |
| 83 | 84 | let open = session.openTexts |
| 84 | 85 | let result = await agenda.board(open: open, match: match) |
Sources/Orgstar/ContentView.swift
+2
| @@ -929,6 +929,7 @@ struct ContentView: View { |
| 929 | 929 | let agenda = reminderAgenda ?? AgendaModel(workspace: workspace) |
| 930 | 930 | reminderAgenda = agenda |
| 931 | 931 | agenda.includeSubfolders = agendaSubfolders |
| 932 | agenda.excludeArchives = OrgPreferences.agendaExcludeArchives() |
| 932 | 933 | let open = session.openTexts |
| 933 | 934 | let reminders = await agenda.reminders(open: open, lead: reminderLead) |
| 934 | 935 | guard !Task.isCancelled else { return } |
| @@ -944,6 +945,7 @@ struct ContentView: View { |
| 944 | 945 | days.mode = .agenda(span: AgendaSnapshot.dayCount, startOffset: 0) |
| 945 | 946 | days.startOnWeekday = nil |
| 946 | 947 | days.includeSubfolders = agendaSubfolders |
| 948 | days.excludeArchives = OrgPreferences.agendaExcludeArchives() |
| 947 | 949 | days.agendaFiles = OrgPreferences.agendaFiles() |
| 948 | 950 | days.options = OrgPreferences.agendaOptions(days.options) |
| 949 | 951 | days.options.logMode = false |
Sources/OrgstarMobile/BoardScreen.swift
+1
| @@ -94,6 +94,7 @@ struct BoardScreen: View { |
| 94 | 94 | .task(id: RefreshKey(match: match, files: workspace.files.count, changed: workspace.changedFile?.version, edits: session.editVersion, |
| 95 | 95 | tick: tick, settings: model.settingsVersion)) { |
| 96 | 96 | agenda.includeSubfolders = OrgPreferences.agendaSubfolders() |
| 97 | agenda.excludeArchives = OrgPreferences.agendaExcludeArchives() |
| 97 | 98 | agenda.agendaFiles = OrgPreferences.agendaFiles() |
| 98 | 99 | let result = await agenda.board(open: session.openTexts, match: match) |
| 99 | 100 | entries = result.entries |
Sources/OrgstarMobile/MobileModel.swift
+2
| @@ -153,6 +153,7 @@ final class MobileModel { |
| 153 | 153 | agenda.startOffset = OrgPreferences.agendaStartOffset() |
| 154 | 154 | agenda.startOnWeekday = OrgPreferences.agendaStartOnWeekday() |
| 155 | 155 | agenda.includeSubfolders = OrgPreferences.agendaSubfolders() |
| 156 | agenda.excludeArchives = OrgPreferences.agendaExcludeArchives() |
| 156 | 157 | agenda.agendaFiles = OrgPreferences.agendaFiles() |
| 157 | 158 | agenda.options = OrgPreferences.agendaOptions(agenda.options) |
| 158 | 159 | agenda.calendarEvents = OrgPreferences.calendarEvents() ? calendarEvents : nil |
| @@ -296,6 +297,7 @@ final class MobileModel { |
| 296 | 297 | days.startOnWeekday = nil |
| 297 | 298 | if let agenda { |
| 298 | 299 | days.includeSubfolders = agenda.includeSubfolders |
| 300 | days.excludeArchives = agenda.excludeArchives |
| 299 | 301 | days.options = agenda.options |
| 300 | 302 | days.options.logMode = false |
| 301 | 303 | days.calendarEvents = agenda.calendarEvents |
Sources/OrgstarMobile/SettingsScreen.swift
+8 −1
| @@ -41,7 +41,7 @@ struct SettingsScreen: View { |
| 41 | 41 | } footer: { |
| 42 | 42 | Text("A folder with config.toml and capture.toml, such as a synced copy of ~/.config/orgstar from your Mac. Changes to them apply as they sync.") |
| 43 | 43 | } |
| 44 | | Section("Agenda") { |
| 44 | Section { |
| 45 | 45 | let _ = model.settingsVersion |
| 46 | 46 | Toggle("Show days without entries", isOn: Binding { |
| 47 | 47 | OrgPreferences.agendaShowAllDates() |
| @@ -49,6 +49,9 @@ struct SettingsScreen: View { |
| 49 | 49 | Toggle("Habits only today", isOn: Binding { |
| 50 | 50 | OrgPreferences.habitsOnlyForToday() |
| 51 | 51 | } set: { model.set("habitsOnlyForToday", to: .bool($0)) }) |
| 52 | Toggle("Leave out archive files", isOn: Binding { |
| 53 | OrgPreferences.agendaExcludeArchives() |
| 54 | } set: { model.set("agendaExcludeArchives", to: .bool($0)) }) |
| 52 | 55 | Picker("Blocked entries", selection: Binding { |
| 53 | 56 | UserDefaults.standard.string(forKey: "agendaDimBlockedTasks") ?? "t" |
| 54 | 57 | } set: { model.set("agendaDimBlockedTasks", to: .string($0)) }) { |
| @@ -56,6 +59,10 @@ struct SettingsScreen: View { |
| 56 | 59 | Text("Hidden").tag("invisible") |
| 57 | 60 | Text("Shown as usual").tag("nil") |
| 58 | 61 | } |
| 62 | } header: { |
| 63 | Text("Agenda") |
| 64 | } footer: { |
| 65 | Text("Archive files are the ones your agenda files archive to, named by #+ARCHIVE:, an :ARCHIVE: property or org-archive-location.") |
| 59 | 66 | } |
| 60 | 67 | Section { |
| 61 | 68 | let _ = model.settingsVersion |
Tests/OrgAppTests/AppTests.swift
+24
| @@ -630,6 +630,30 @@ struct AgendaModelTests { |
| 630 | 630 | await agenda.refresh(open: [:], now: wednesday, calendar: utc) |
| 631 | 631 | #expect(agenda.days.first?.day == Days.absolute(year: 2026, month: 10, day: 7)) |
| 632 | 632 | } |
| 633 | |
| 634 | @Test func leavesOutArchiveFiles() async throws { |
| 635 | let notes = try Folder() |
| 636 | try notes.write("todo.org", "#+ARCHIVE: todo_archive.org::* %s\n* TODO Live\nSCHEDULED: <2026-10-05 Mon>\n") |
| 637 | try notes.write("todo_archive.org", "* DONE Old\nSCHEDULED: <2026-10-05 Mon>\n") |
| 638 | try notes.write("work.org", "* Project\n:PROPERTIES:\n:ARCHIVE: done/work.org::\n:END:\n** TODO Task\nSCHEDULED: <2026-10-05 Mon>\n") |
| 639 | try notes.write("self.org", "#+ARCHIVE: ::* Archived\n* TODO Mine\nSCHEDULED: <2026-10-05 Mon>\n") |
| 640 | try notes.write("done/work.org", "* DONE Older\nSCHEDULED: <2026-10-05 Mon>\n") |
| 641 | let model = try WorkspaceModel(directory: nil) |
| 642 | try await model.addRoot(notes.url) |
| 643 | let agenda = AgendaModel(workspace: model) |
| 644 | agenda.includeSubfolders = true |
| 645 | agenda.span = 1 |
| 646 | var utc = Calendar(identifier: .gregorian) |
| 647 | utc.timeZone = TimeZone(identifier: "UTC")! |
| 648 | let now = try #require(utc.date(from: DateComponents(year: 2026, month: 10, day: 5, hour: 9))) |
| 649 | |
| 650 | agenda.excludeArchives = false |
| 651 | await agenda.refresh(open: [:], now: now, calendar: utc) |
| 652 | #expect(Set(agenda.days[0].items.map(\.text)) == ["TODO Live", "DONE Old", "TODO Task", "TODO Mine", "DONE Older"]) |
| 653 | agenda.excludeArchives = true |
| 654 | await agenda.refresh(open: [:], now: now, calendar: utc) |
| 655 | #expect(Set(agenda.days[0].items.map(\.text)) == ["TODO Live", "TODO Task", "TODO Mine"]) |
| 656 | } |
| 633 | 657 | } |
| 634 | 658 | |
| 635 | 659 | @MainActor |
docs/manual/guide/07-agenda.org
+7
| @@ -31,6 +31,13 @@ To include files in subfolders as well, turn on Settings ▸ Agenda ▸ Include |
| 31 | 31 | agenda-include-subfolders = true |
| 32 | 32 | #+END_SRC |
| 33 | 33 | |
| 34 | To leave out archive files, the files your agenda files archive to by their =#+ARCHIVE:= keyword, an =:ARCHIVE:= property or =org-archive-location=, turn on Settings ▸ Agenda ▸ Leave out archive files on iOS, or set this in =config.toml=: |
| 35 | |
| 36 | #+BEGIN_SRC toml |
| 37 | [orgstar] |
| 38 | agenda-exclude-archives = true |
| 39 | #+END_SRC |
| 40 | |
| 34 | 41 | To read a list of files instead, as =org-agenda-files= does, set =org-agenda-files= in =config.toml=, entries separated by =\n=: |
| 35 | 42 | |
| 36 | 43 | #+BEGIN_SRC toml |
docs/manual/guide/13-configuration.org
+1
| @@ -392,6 +392,7 @@ Any other key in =[theme]= is a color; see Themes below. |
| 392 | 392 | | =show-hidden-files= | boolean | =true= | List dotfiles and dot folders in your folders. | |
| 393 | 393 | | =ignored-folders= | string | see below | Folder names never listed or searched, separated by spaces. | |
| 394 | 394 | | =agenda-include-subfolders= | boolean | =false= | The agenda reads org files in subfolders too. | |
| 395 | | =agenda-exclude-archives= | boolean | =false= | The agenda leaves out files that other agenda files archive to. | |
| 395 | 396 | | =reminders= | boolean | =true= | Notify before timed entries. | |
| 396 | 397 | | =calendar-events= | boolean | =false= | Show events from Calendar in the agenda. | |
| 397 | 398 | | =calendar-event-calendars= | string | =""= | The calendars whose events show, by title or identifier, separated by commas; =""= for all. | |
docs/manual/guide/14-ios.org
+2 −1
| @@ -389,6 +389,7 @@ The Agenda, TODO Dependencies, Calendar and Reminders sections are the only plac |
| 389 | 389 | |
| 390 | 390 | - Show days without entries :: turns =org-agenda-show-all-dates= on or off. |
| 391 | 391 | - Habits only today :: turns =org-habit-show-habits-only-for-today= on or off. |
| 392 | - Leave out archive files :: turns =agenda-exclude-archives= on or off: the agenda leaves out the files your agenda files archive to. |
| 392 | 393 | - Blocked entries :: Dimmed, Hidden or Shown as usual (=org-agenda-dim-blocked-tasks=). |
| 393 | 394 | - TODO Dependencies :: Not done before TODO children (=org-enforce-todo-dependencies=) and Not done with unchecked boxes (=org-enforce-todo-checkbox-dependencies=). |
| 394 | 395 | - Show Calendar Events :: turns on =calendar-events=, and asks for access to your calendars. iOS asks for full access, as Calendar has no read-only level; orgstar changes a calendar only when you edit an event or add an entry. While access is missing the section shows Allow Access to Calendars…; if you declined, allow it in the Settings app under Privacy & Security ▸ Calendars. |
| @@ -415,7 +416,7 @@ These settings from =config.toml= apply on iOS: |
| 415 | 416 | - =org-use-tag-inheritance=, =org-tags-exclude-from-inheritance=, =org-tag-alist= |
| 416 | 417 | - =org-use-speed-commands=, with a hardware keyboard |
| 417 | 418 | - =electric-pair-mode=, =spell-check=, =auto-fill-mode= |
| 418 | | - =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-habit-show-habits-only-for-today=, =org-agenda-search-view-always-boolean=, =org-agenda-search-view-force-full-words=, =org-agenda-log-mode-items=, the =org-agenda-todo-ignore-= settings, =org-agenda-tags-todo-honor-ignore-options= |
| 419 | - =org-agenda-span=, =org-agenda-start-day=, =org-agenda-start-on-weekday=, =org-deadline-warning-days=, =agenda-include-subfolders=, =agenda-exclude-archives=, =org-agenda-show-all-dates=, =org-agenda-skip-scheduled-if-done=, =org-agenda-skip-deadline-if-done=, =org-habit-show-habits-only-for-today=, =org-agenda-search-view-always-boolean=, =org-agenda-search-view-force-full-words=, =org-agenda-log-mode-items=, the =org-agenda-todo-ignore-= settings, =org-agenda-tags-todo-honor-ignore-options= |
| 419 | 420 | - =calendar-events=, =calendar-event-calendars=, =agenda-reminders=, =agenda-reminder-lists= |
| 420 | 421 | - =reminders=, =appt-message-warning-time= |
| 421 | 422 | - =org-clock-history-length=, =org-clock-into-drawer=, =org-clock-rounding-minutes=, =org-clock-out-remove-zero-time-clocks=, =org-clock-in-switch-to-state=, =org-clock-out-when-done= |