Commit 193155dbb2

193155dbb22e3eff765a4ab8ea491811d4b51858

parent: 3cf0c16fe4

Verified · cmc

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

Stuck projects view

Adds org-agenda-list-stuck-projects with org-stuck-projects (match, keywords, tags, regexp) from [org-stuck-projects] in config.toml, a built-in Stuck Projects view, and type = "stuck" in views.toml with per-view overrides. Imported from Emacs.

Closes #11

Layout: unified · split

Sources/OrgApp/AgendaModel.swift +2
@@ -98,6 +98,8 @@ public final class AgendaModel {
9898 list = Agenda.tagsMatch(all, match: match, todoOnly: todoOnly, now: now, calendar: calendar, options: options)
9999 case .search(let string, let todoOnly):
100100 list = Agenda.textSearch(all, string: string, todoOnly: todoOnly, options: options)
101 case .stuck(let definition):
102 list = Agenda.stuckProjects(all, definition ?? options.stuckProjects, now: now, calendar: calendar, options: options)
101103 }
102104 return (days, list, events)
103105 }.value
Sources/OrgApp/AgendaViews.swift +18 −2
@@ -11,6 +11,8 @@ public enum AgendaMode: Hashable, Sendable {
1111 case match(String, todoOnly: Bool)
1212 /// `org-search-view`.
1313 case search(String, todoOnly: Bool)
14 /// `org-agenda-list-stuck-projects`; nil uses the `org-stuck-projects` setting.
15 case stuck(StuckProjects?)
1416
1517 /// The key `org-agenda-prefix-format` and `org-agenda-sorting-strategy` use for this kind
1618 /// of view.
@@ -18,7 +20,7 @@ public enum AgendaMode: Hashable, Sendable {
1820 switch self {
1921 case .agenda: "agenda"
2022 case .todo: "todo"
21 case .match: "tags"
23 case .match, .stuck: "tags"
2224 case .search: "search"
2325 }
2426 }
@@ -67,7 +69,9 @@ public struct AgendaViewDefinition: Hashable, Sendable, Identifiable {
6769/// ```
6870///
6971/// `agenda` views take `span` and `start` (days from today), `todo` views `keywords`
70/// (`WAIT|HOLD`); a `search` view's `match` is its search string. Any view can set
72/// (`WAIT|HOLD`); a `search` view's `match` is its search string. `stuck` views take
73/// `match`, `keywords`, `tags` and `regexp` as `[org-stuck-projects]` does, each defaulting
74/// to that setting. Any view can set
7175/// `prefix-format` and `sorting-strategy` (keys separated by spaces) for itself.
7276@MainActor
7377public enum AgendaViewLoader {
@@ -76,6 +80,7 @@ public enum AgendaViewLoader {
7680 public static let builtIn = [
7781 AgendaViewDefinition(name: "Agenda", mode: .agenda(span: nil, startOffset: nil)),
7882 AgendaViewDefinition(name: "TODO List", mode: .todo(keywords: nil)),
83 AgendaViewDefinition(name: "Stuck Projects", mode: .stuck(nil)),
7984 ]
8085
8186 /// The views' settings by mode; the first view with a mode wins.
@@ -126,6 +131,17 @@ public enum AgendaViewLoader {
126131 continue
127132 }
128133 mode = .search(match, todoOnly: table.values["type"]?.string == "todo-search")
134 case "stuck":
135 if ["match", "keywords", "tags", "regexp"].allSatisfy({ table.values[$0] == nil }) {
136 mode = .stuck(nil)
137 } else {
138 var definition = OrgPreferences.stuckProjects()
139 if let match { definition.match = match }
140 if let keywords = table.values["keywords"]?.string { definition.todo = OrgPreferences.words(keywords) }
141 if let tags = table.values["tags"]?.string { definition.tags = OrgPreferences.words(tags) }
142 if let regexp = table.values["regexp"]?.string { definition.regexp = regexp }
143 mode = .stuck(definition)
144 }
129145 case let other:
130146 problems.append("views.toml line \(table.line): unknown type \(other)")
131147 continue
Sources/OrgApp/EmacsImport.swift +7
@@ -524,6 +524,13 @@ public struct EmacsImport: Sendable {
524524 } else {
525525 add(name, .bool(truthy))
526526 }
527 case "org-stuck-projects":
528 // `("+LEVEL=2/-DONE" ("TODO" "NEXT") nil "")`.
529 guard let parts = value.elements, parts.count == 4, let match = parts[0].string else { return note("not a stuck-projects definition") }
530 add("org-stuck-projects.match", .string(match))
531 add("org-stuck-projects.todo", .string((parts[1].elements ?? []).compactMap(\.string).joined(separator: " ")))
532 add("org-stuck-projects.tags", .string((parts[2].elements ?? []).compactMap(\.string).joined(separator: " ")))
533 add("org-stuck-projects.regexp", .string(parts[3].string ?? ""))
527534 case "org-agenda-time-grid":
528535 // `((daily today require-timed) (800 1000 …) "......" "----------------")`: the
529536 // strings are how Emacs draws the lines.
Sources/OrgApp/OrgPreferences.swift +8
@@ -111,10 +111,18 @@ public enum OrgPreferences {
111111 options.showCurrentTimeInGrid = bool("agendaShowCurrentTime", defaults)
112112 options.gridWhen = Set(string("agendaTimeGridWhen", defaults).split(whereSeparator: \.isWhitespace).map(String.init))
113113 options.gridTimes = string("agendaTimeGridTimes", defaults).split(whereSeparator: \.isWhitespace).compactMap { Int($0) }
114 options.stuckProjects = stuckProjects(defaults)
114115 options.sortNotimeIsLate = bool("agendaSortNotimeIsLate", defaults)
115116 options.sortNoeffortIsHigh = bool("agendaSortNoeffortIsHigh", defaults)
116117 return options
117118 }
119 /// `org-stuck-projects`.
120 public static func stuckProjects(_ defaults: UserDefaults = .standard) -> StuckProjects {
121 StuckProjects(match: string("stuckProjectsMatch", defaults), todo: words(string("stuckProjectsTodo", defaults)),
122 tags: words(string("stuckProjectsTags", defaults)), regexp: string("stuckProjectsRegexp", defaults))
123 }
124 /// Words separated by spaces.
125 public static func words(_ text: String) -> [String] { text.split(whereSeparator: \.isWhitespace).map(String.init) }
118126 /// An `org-agenda-sorting-strategy` entry, keys separated by spaces; unknown keys are left out.
119127 public static func sortingStrategy(_ text: String) -> [String] {
120128 text.split(whereSeparator: \.isWhitespace).map(String.init).filter(AgendaSort.keys.contains)
Sources/OrgApp/UserConfig.swift +8
@@ -225,6 +225,14 @@ public enum UserConfig {
225225 comment: "tag and property matches", legacy: ""),
226226 Setting(section: "org-agenda-sorting-strategy", key: "search", defaultsKey: "agendaSortSearch", kind: .string, fallback: .string(AgendaSort.defaults["search"]!.joined(separator: " ")),
227227 comment: "text search", legacy: ""),
228 Setting(section: "org-stuck-projects", key: "match", defaultsKey: "stuckProjectsMatch", kind: .string, fallback: .string("+LEVEL=2/-DONE"),
229 comment: "the entries that are projects, as a tag and property match", legacy: ""),
230 Setting(section: "org-stuck-projects", key: "todo", defaultsKey: "stuckProjectsTodo", kind: .string, fallback: .string("TODO NEXT NEXTACTION"),
231 comment: "a heading in the project with one of these keywords unsticks it; * for any open keyword", legacy: ""),
232 Setting(section: "org-stuck-projects", key: "tags", defaultsKey: "stuckProjectsTags", kind: .string, fallback: .string(""),
233 comment: "a heading in the project with one of these tags unsticks it; * for any tag", legacy: ""),
234 Setting(section: "org-stuck-projects", key: "regexp", defaultsKey: "stuckProjectsRegexp", kind: .string, fallback: .string(""),
235 comment: "text in the project matching this Emacs regexp unsticks it", legacy: ""),
228236 Setting(section: "org-agenda-time-grid", key: "when", defaultsKey: "agendaTimeGridWhen", kind: .string, fallback: .string("daily today require-timed"),
229237 comment: "daily (one-day views), today, weekly (every day), require-timed (only with timed entries), remove-match (no line at an entry's time)", legacy: ""),
230238 Setting(section: "org-agenda-time-grid", key: "times", defaultsKey: "agendaTimeGridTimes", kind: .string, fallback: .string("800 1000 1200 1400 1600 1800 2000"),
Sources/OrgCore/Agenda/Agenda.swift +2
@@ -91,6 +91,8 @@ public struct AgendaOptions: Sendable, Equatable {
9191 public var gridTimes = [800, 1000, 1200, 1400, 1600, 1800, 2000]
9292 /// `org-agenda-show-current-time-in-grid`.
9393 public var showCurrentTimeInGrid = true
94 /// `org-stuck-projects`, for views that don't give their own.
95 public var stuckProjects = StuckProjects()
9496 public var gridTrailing = " ┄┄┄┄┄ "
9597 public var gridLine = "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄"
9698 public var currentTimeLine = "← now ───────────────────────────────────────────────"
Sources/OrgCore/Agenda/AgendaSearch.swift +2 −1
@@ -32,7 +32,7 @@ extension Agenda {
3232 /// unfinished TODO entries, as `M` does.
3333 public static func tagsMatch(
3434 _ sources: [AgendaSource], match: String, todoOnly: Bool = false, now: Date = Date(), calendar: Calendar = .current,
35 options: AgendaOptions = AgendaOptions()
35 options: AgendaOptions = AgendaOptions(), skip: ((AgendaSource, Int) -> Bool)? = nil
3636 ) -> [AgendaItem] {
3737 let matcher = TagsMatcher(match, todoOnly: todoOnly)
3838 let today = Days.absolute(now, calendar: calendar)
@@ -41,6 +41,7 @@ extension Agenda {
4141 for (index, heading) in source.headings.enumerated() {
4242 if matcher.todoOnly, heading.todo == nil { continue }
4343 guard matcher.matches(heading, in: source, now: now, calendar: calendar), !heading.skipped else { continue }
44 if let skip, skip(source, index) { continue }
4445 if matcher.todoOnly, options.tagsTodoHonorIgnoreOptions, ignoresTodo(source, index, options: options, today: today) { continue }
4546 var item = format(
4647 source, heading, kind: .tagsMatch, marker: heading.start, extra: "", dotime: nil, removing: nil,
Sources/OrgCore/Agenda/StuckProjects.swift added +65
@@ -0,0 +1,65 @@
1import Foundation
2
3/// `org-stuck-projects` (Org 9.8.7): projects are the entries `match` finds; one is not stuck
4/// when its subtree, its own heading included, has a heading with one of `todo` (`*` for any
5/// open keyword), a heading with one of `tags` set on it (`*` for any tag), or text matching
6/// `regexp`.
7public struct StuckProjects: Sendable, Hashable {
8 public var match: String
9 public var todo: [String]
10 public var tags: [String]
11 /// In Emacs syntax; empty for none.
12 public var regexp: String
13
14 public init(match: String = "+LEVEL=2/-DONE", todo: [String] = ["TODO", "NEXT", "NEXTACTION"], tags: [String] = [], regexp: String = "") {
15 self.match = match
16 self.todo = todo
17 self.tags = tags
18 self.regexp = regexp
19 }
20
21 /// The `skip-re` of `org-agenda-list-stuck-projects`, compiled; nil when the definition
22 /// names nothing that unsticks a project.
23 func unstuck(_ sources: [AgendaSource]) -> NSRegularExpression? {
24 var parts: [String] = []
25 if !todo.isEmpty {
26 var words = todo
27 if words.contains("*") {
28 var open: [String] = []
29 for source in sources { for k in source.notDoneKeywords where !open.contains(k) { open.append(k) } }
30 words = open
31 }
32 parts.append("^\\*+[ \\t]+(" + words.map(NSRegularExpression.escapedPattern(for:)).joined(separator: "|") + ")(?:[ \\t]|$)")
33 }
34 if tags.contains("*") {
35 parts.append(SetTags.tagLine)
36 } else if !tags.isEmpty {
37 let other = "(?:[[:alnum:]_@#%]+:)*"
38 parts.append("^\\*+ .*?[ \\t]:" + other + "(" + tags.map(NSRegularExpression.escapedPattern(for:)).joined(separator: "|") + "):" + other + "[ \\t]*$")
39 }
40 if regexp.contains(where: { !$0.isWhitespace }) { parts.append(EmacsRegex.translate(regexp)) }
41 guard !parts.isEmpty else { return nil }
42 return try? NSRegularExpression(pattern: parts.map { "(?:" + $0 + ")" }.joined(separator: "|"), options: .anchorsMatchLines)
43 }
44}
45
46extension Agenda {
47 /// `org-agenda-list-stuck-projects`: the tags view of `definition.match`, without the
48 /// projects that something in their subtree unsticks. With nothing to unstick them (Org
49 /// signals an error), every match is listed.
50 public static func stuckProjects(
51 _ sources: [AgendaSource], _ definition: StuckProjects, now: Date = Date(), calendar: Calendar = .current, options: AgendaOptions = AgendaOptions()
52 ) -> [AgendaItem] {
53 let unstuck = definition.unstuck(sources)
54 return tagsMatch(sources, match: definition.match, now: now, calendar: calendar, options: options) { source, index in
55 guard let unstuck else { return false }
56 let heading = source.headings[index]
57 let next = source.headings[(index + 1)...].first { $0.level <= heading.level }?.start
58 let ns = source.text as NSString
59 // `org-end-of-subtree`: before the line break ending the subtree's last line.
60 var end = next ?? ns.length
61 if end > heading.start, ns.character(at: end - 1) == 10 { end -= 1 }
62 return unstuck.firstMatch(in: source.text, range: NSRange(location: heading.start, length: end - heading.start)) != nil
63 }
64 }
65}
Sources/Orgstar/AgendaView+Toolbar.swift +1
@@ -183,6 +183,7 @@ extension AgendaView {
183183 case .todo(let keywords): "TODO items: \(keywords ?? "all")"
184184 case .match(let match, let todoOnly): (todoOnly ? "TODO entries" : "Entries") + " matching \(match)"
185185 case .search(let string, let todoOnly): (todoOnly ? "TODO entries" : "Entries") + " containing \(string)"
186 case .stuck: "Stuck projects"
186187 case .agenda: ""
187188 }
188189 }
Sources/Orgstar/AgendaView.swift +7 −2
@@ -85,6 +85,10 @@ struct AgendaView: View {
8585 @AppStorage("agendaShowCurrentTime") private var showCurrentTime = true
8686 @AppStorage("agendaTimeGridWhen") private var gridWhen = ""
8787 @AppStorage("agendaTimeGridTimes") private var gridTimes = ""
88 @AppStorage("stuckProjectsMatch") private var stuckMatch = ""
89 @AppStorage("stuckProjectsTodo") private var stuckTodo = ""
90 @AppStorage("stuckProjectsTags") private var stuckTags = ""
91 @AppStorage("stuckProjectsRegexp") private var stuckRegexp = ""
8892 @Environment(\.openWindow) var openWindow
8993
9094 static let match = "Match…"
@@ -132,7 +136,7 @@ struct AgendaView: View {
132136 var startOnWeekday: String
133137 var includeSubfolders: Bool
134138 var prefix: [String]
135 var sorting: [String]
139 var settings: [String]
136140 var logMode: Bool
137141 var calendars: [String]
138142 var files: Int
@@ -147,7 +151,8 @@ struct AgendaView: View {
147151 private var refreshKey: RefreshKey {
148152 RefreshKey(
149153 mode: agenda.mode, start: agenda.start, span: span, startOffset: startOffset, startOnWeekday: startOnWeekday, includeSubfolders: includeSubfolders, prefix: [prefixAgenda, prefixTodo, prefixTags],
150 sorting: [sortAgenda, sortTodo, sortTags, sortSearch, gridWhen, gridTimes, "\(useTimeGrid) \(showCurrentTime)"], logMode: logMode,
154 settings: [sortAgenda, sortTodo, sortTags, sortSearch, gridWhen, gridTimes, "\(useTimeGrid) \(showCurrentTime)", stuckMatch, stuckTodo, stuckTags, stuckRegexp],
155 logMode: logMode,
151156 calendars: calendarEventsOn ? [calendarNames] : [], files: 0, changed: nil, edits: 0, path: nil, tick: tick
152157 )
153158 }
Tests/OrgAppTests/AppTests.swift +33 −5
@@ -651,10 +651,10 @@ struct AgendaCommandTests {
651651 type = "match"
652652 """)
653653 let loaded = AgendaViewLoader.load(userFile: file)
654 #expect(loaded.views.map(\.name) == ["Agenda", "TODO List", "Work", "Week", "Waiting"])
655 #expect(loaded.views[2].mode == .match("+work", todoOnly: false))
656 #expect(loaded.views[3].mode == .agenda(span: 7, startOffset: -1))
657 #expect(loaded.views[4].mode == .todo(keywords: "WAIT|HOLD"))
654 #expect(loaded.views.map(\.name) == ["Agenda", "TODO List", "Stuck Projects", "Work", "Week", "Waiting"])
655 #expect(loaded.views[3].mode == .match("+work", todoOnly: false))
656 #expect(loaded.views[4].mode == .agenda(span: 7, startOffset: -1))
657 #expect(loaded.views[5].mode == .todo(keywords: "WAIT|HOLD"))
658658 #expect(loaded.problems == ["views.toml line 13: Broken needs a match"])
659659 }
660660
@@ -670,7 +670,7 @@ struct AgendaCommandTests {
670670 """)
671671 let loaded = AgendaViewLoader.load(userFile: file)
672672 #expect(loaded.problems == ["views.toml line 1: unknown sorting key bogus"])
673 #expect(loaded.views[2].settings == AgendaViewSettings(prefixFormat: "%e", sortingStrategy: ["alpha-up"]))
673 #expect(loaded.views[3].settings == AgendaViewSettings(prefixFormat: "%e", sortingStrategy: ["alpha-up"]))
674674 let model = try WorkspaceModel(directory: nil)
675675 try await model.addRoot(notes.url)
676676 let agenda = AgendaModel(workspace: model)
@@ -685,6 +685,34 @@ struct AgendaCommandTests {
685685 #expect(agenda.list.map(\.text) == ["TODO [#A] c", "TODO b", "TODO a"])
686686 }
687687
688 @Test func stuckProjectViews() async throws {
689 let notes = try Folder()
690 try notes.write("a.org", "* Projects\n** Website\n*** TODO Draft\n** Garden\n*** WAIT Seeds\n")
691 let file = try notes.write("views.toml", """
692 [[view]]
693 name = "Stuck"
694 type = "stuck"
695 [[view]]
696 name = "Waiting counts"
697 type = "stuck"
698 keywords = "TODO WAIT"
699 """)
700 let loaded = AgendaViewLoader.load(userFile: file)
701 #expect(loaded.problems.isEmpty)
702 #expect(loaded.views[3].mode == .stuck(nil))
703 guard case .stuck(let definition?) = loaded.views[4].mode else { Issue.record("no definition"); return }
704 #expect(definition.todo == ["TODO", "WAIT"] && definition.match == "+LEVEL=2/-DONE")
705 let model = try WorkspaceModel(directory: nil)
706 try await model.addRoot(notes.url)
707 let agenda = AgendaModel(workspace: model)
708 agenda.mode = loaded.views[3].mode
709 await agenda.refresh(open: [:])
710 #expect(agenda.list.map(\.text) == ["Garden"])
711 agenda.mode = loaded.views[4].mode
712 await agenda.refresh(open: [:])
713 #expect(agenda.list.isEmpty)
714 }
715
688716 @Test func todoListMode() async throws {
689717 let notes = try Folder()
690718 try notes.write("a.org", "* TODO One :work:\n* DONE Two\n* TODO Three\n")
Tests/OrgAppTests/EmacsImportTests.swift +6 −1
@@ -22,6 +22,7 @@ struct EmacsImportTests {
2222 (setq org-agenda-prefix-format '((agenda . " %i %-12:c%?-12t% s%b") (todo . " %-8:c")))
2323 (setq org-agenda-sorting-strategy '((agenda time-up priority-down) (todo . (alpha-up))) org-agenda-sort-notime-is-late nil)
2424 (setq org-agenda-time-grid '((daily today) (800 1300) "......" "----") org-agenda-use-time-grid nil)
25 (setq org-stuck-projects '("+project/-DONE" ("NEXT" "TODO") ("errand") "\\<IGNORE\\>"))
2526 (setq fill-column (+ 70 2))
2627 (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
2728 (with-eval-after-load 'org (add-to-list 'org-structure-template-alist '("q" . "QUOTE")))
@@ -100,6 +101,10 @@ struct EmacsImportTests {
100101 #expect(s["org-agenda-time-grid.when"] == .string("daily today"))
101102 #expect(s["org-agenda-time-grid.times"] == .string("800 1300"))
102103 #expect(s["org-agenda-use-time-grid"] == .bool(false))
104 #expect(s["org-stuck-projects.match"] == .string("+project/-DONE"))
105 #expect(s["org-stuck-projects.todo"] == .string("NEXT TODO"))
106 #expect(s["org-stuck-projects.tags"] == .string("errand"))
107 #expect(s["org-stuck-projects.regexp"] == .string("\\<IGNORE\\>"))
103108 // after! org runs after the top-level setq.
104109 #expect(s["org-tags-column"] == .integer(-80))
105110 #expect(s["org-agenda-span"] == .integer(10))
@@ -203,7 +208,7 @@ struct EmacsImportTests {
203208 let keymap = folder.appendingPathComponent("keymap.toml")
204209 #expect(KeymapLoader.load(.doom, userFile: keymap).problems.isEmpty)
205210 #expect(KeymapLoader.load(.doom, userFile: keymap).keymap.keyLabels(for: "app.agenda", modes: ["normal"]).contains("C-c a"))
206 #expect(summary.hasPrefix("Imported 38 settings, 3 capture templates, 3 key bindings, 2 structure templates."), "\(summary)")
211 #expect(summary.hasPrefix("Imported 42 settings, 3 capture templates, 3 key bindings, 2 structure templates."), "\(summary)")
207212 #expect(UserConfig.structureTemplates(defaults) == [.init(key: "el", type: "src emacs-lisp"), .init(key: "q", type: "QUOTE")])
208213 #expect(OrgPreferences.options(defaults).structureTemplates?.first { $0.key == "q" }?.type == "QUOTE")
209214 #expect(defaults.string(forKey: "themeFont") == "JetBrains Mono")
Tests/OrgCoreTests/StuckProjectsTests.swift added +48
@@ -0,0 +1,48 @@
1import Foundation
2import Testing
3@testable import OrgCore
4
5/// `org-agenda-list-stuck-projects` against Emacs.
6struct StuckProjectsTests {
7 static let file = """
8 * Projects
9 ** Website
10 *** TODO Draft the copy
11 ** Garden :outdoor:
12 *** WAIT Seeds
13 *** Notes
14 ** TODO Taxes
15 ** Kitchen
16 *** Buy tiles :errand:
17 ** DONE Old project
18 ** Reading
19 Waiting for the library. NEXT week.
20 ** IDEA Novel
21 *** HOLD Outline :@home:
22 * Areas
23 ** Health
24 *** STRT Running
25
26 """
27
28 @Test(.enabled(if: ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil))
29 func listsLikeOrg() throws {
30 let today = Days.absolute(year: 2026, month: 10, day: 5)
31 let cases: [(String, StuckProjects)] = [
32 ("'(\"+LEVEL=2/-DONE\" (\"TODO\" \"NEXT\" \"NEXTACTION\") nil \"\")", StuckProjects()),
33 ("'(\"+LEVEL=2/-DONE\" (\"*\") nil \"\")", StuckProjects(todo: ["*"])),
34 ("'(\"+LEVEL=2/-DONE\" nil (\"errand\" \"@home\") \"\")", StuckProjects(todo: [], tags: ["errand", "@home"])),
35 ("'(\"+LEVEL=2/-DONE\" nil (\"*\") \"\")", StuckProjects(todo: [], tags: ["*"])),
36 ("'(\"+LEVEL=2/-DONE\" (\"WAIT\") nil \"\\\\<NEXT\\\\>\")", StuckProjects(todo: ["WAIT"], regexp: "\\<NEXT\\>")),
37 ("'(\"LEVEL=2-outdoor\" (\"TODO\" \"STRT\") nil \"library\")", StuckProjects(match: "LEVEL=2-outdoor", todo: ["TODO", "STRT"], regexp: "library")),
38 ]
39 var utc = Calendar(identifier: .gregorian)
40 utc.timeZone = TimeZone(identifier: "UTC")!
41 let now = Date(timeIntervalSince1970: Double((today - 719163) * 86400 + 9 * 3600 + 30 * 60))
42 for (lisp, definition) in cases {
43 try AgendaOracle.compareList(files: [("p.org", Self.file)], form: "(let ((org-stuck-projects \(lisp))) (org-agenda-list-stuck-projects))", today: today) {
44 Agenda.stuckProjects($0, definition, now: now, calendar: utc)
45 }
46 }
47 }
48}
docs/manual/guide/07-agenda.org +17 −3
@@ -364,6 +364,19 @@ After the last =/= (one not followed by a quote), the match restricts TODO keywo
364364
365365=/TODO|NEXT= matches either keyword, and =/!NEXT|WAIT= either one while open. =/!= has the same effect as choosing TODO Match….
366366
367* Stuck projects
368
369The built-in view Stuck Projects is =org-agenda-list-stuck-projects= (=#=): the projects that have no next action. =[org-stuck-projects]= in =config.toml= says what a project is and what makes one active, as =org-stuck-projects= does:
370
371| Key | Default | Meaning |
372|----------+---------------------------+----------------------------------------------------------------------------------|
373| =match= | ="+LEVEL=2/-DONE"= | A match as in [[*Tag and property matches][Tag and property matches]]: the entries that are projects |
374| =todo= | ="TODO NEXT NEXTACTION"= | A heading with one of these keywords makes its project active; =*= for any open keyword |
375| =tags= | =""= | A heading with one of these tags set on it (not inherited) makes its project active; =*= for any tag |
376| =regexp= | =""= | Text matching this Emacs regular expression makes its project active |
377
378The project's own heading counts: a project whose heading has a =todo= keyword is not stuck. Keywords, tags and the regexp are case-sensitive. A project that isn't stuck can still contain stuck subprojects, which are listed. When =todo=, =tags= and =regexp= are all empty, every project is listed; Org signals an error instead. Lines sort as tag matches do.
379
367380* Text search
368381
369382Choose Search… from the view menu to list entries containing some text, as =org-search-view= (=s=) does, or TODO Search… to list only entries with an open TODO keyword (=S=, or =C-u s=). Type the search string in the toolbar field and press Return. An entry is its heading and the text up to the next heading; text before the first heading of a file is not searched. Entries show in file order, with the rows of the TODO list.
@@ -394,7 +407,7 @@ The search covers the agenda files only, not =org-agenda-text-search-extra-files
394407
395408* Views
396409
397The view menu lists the built-in views, Agenda and TODO List, then the views in =views.toml=, then Match…, TODO Match…, Search… and TODO Search…. Saved views mirror =org-agenda-custom-commands=, with fewer options.
410The view menu lists the built-in views, Agenda, TODO List and Stuck Projects, then the views in =views.toml=, then Match…, TODO Match…, Search… and TODO Search…. Saved views mirror =org-agenda-custom-commands=, with fewer options.
398411
399412=views.toml= lives in the configuration folder beside =config.toml= (=~/.config/orgstar/= by default; see [[file:13-configuration.org][Configuration]]). Each view is a =[[view]]= table:
400413
@@ -429,17 +442,18 @@ match = "+invoice -paid"
429442| Key | Applies to | Meaning |
430443|------------+--------------------+----------------------------------------------------------------------------|
431444| =name= | all, required | The name in the view menu |
432| =type= | all | =agenda= (the default), =todo=, =match=, =todo-match=, =search= or =todo-search= |
445| =type= | all | =agenda= (the default), =todo=, =match=, =todo-match=, =search=, =todo-search= or =stuck= |
433446| =span= | =agenda= | Days shown; the setting when omitted |
434447| =start= | =agenda= | First day as an integer number of days from today (=-3=, =0=); the setting when omitted |
435448| =keywords= | =todo= | Keywords separated by the vertical bar; all open TODOs when omitted |
436449| =match= | =match=, =todo-match=, =search=, =todo-search=, required | A match string as in [[*Tag and property matches][Tag and property matches]], or for =search= a search string as in [[*Text search][Text search]]; the =todo-= types keep only open TODO entries |
450| =keywords=, =tags=, =regexp= | =stuck= | The =todo=, =tags= (separated by spaces) and =regexp= of =[org-stuck-projects]=; with =match= they replace the setting's values for this view, and the ones left out keep them |
437451| =sorting-strategy= | all | The view's =org-agenda-sorting-strategy=, keys separated by spaces, in place of the one in =config.toml= for its kind |
438452| =prefix-format= | all | The view's =org-agenda-prefix-format=, in place of the one in =config.toml= for its kind |
439453
440454Note that =start= is a plain integer here, while =org-agenda-start-day= in =config.toml= is a string such as ="-3d"=.
441455
442Not supported: block agendas (several views in one), =org-agenda-skip-function=, and =stuck= projects. The views load when the window opens and again on =g= or =r=. A problem in the file, such as a missing =name= or an unknown =type=, shows in the status line at the bottom of the window, and the remaining views still load.
456Not supported: block agendas (several views in one) and =org-agenda-skip-function=. The views load when the window opens and again on =g= or =r=. A problem in the file, such as a missing =name= or an unknown =type=, shows in the status line at the bottom of the window, and the remaining views still load.
443457
444458* Filters
445459
docs/manual/guide/13-configuration.org +14 −1
@@ -171,11 +171,12 @@ These settings have no control in the Settings window. Some are in the View menu
171171| =[org-agenda-prefix-format]= | |
172172| =[org-agenda-sorting-strategy]=, =org-agenda-sort-notime-is-late=, =org-agenda-sort-noeffort-is-high= | |
173173| =[org-agenda-time-grid]=, =org-agenda-use-time-grid=, =org-agenda-show-current-time-in-grid= | |
174| =[org-stuck-projects]= | |
174175| =theme-file= | |
175176
176177* config.toml reference
177178
178Settings that mirror an Emacs variable sit at the top of the file under that variable's name. The agenda prefix formats are in =[org-agenda-prefix-format]=, the sorting strategies in =[org-agenda-sorting-strategy]=, the time grid in =[org-agenda-time-grid]=, type and theme in =[theme]=, and the settings Emacs has no variable for in =[orgstar]=.
179Settings that mirror an Emacs variable sit at the top of the file under that variable's name. The agenda prefix formats are in =[org-agenda-prefix-format]=, the sorting strategies in =[org-agenda-sorting-strategy]=, the time grid in =[org-agenda-time-grid]=, stuck projects in =[org-stuck-projects]=, type and theme in =[theme]=, and the settings Emacs has no variable for in =[orgstar]=.
179180
180181A key you remove from the file goes back to its default. A key that isn't in the table below is reported as unknown.
181182
@@ -271,6 +272,17 @@ These mirror the entries of =org-agenda-prefix-format=. Rows show the category,
271272
272273These mirror the entries of =org-agenda-sorting-strategy=, keys separated by spaces. Unknown keys are ignored. A view in =views.toml= can set its own with =sorting-strategy=. The keys are listed in [[file:07-agenda.org][The agenda]].
273274
275** [org-stuck-projects]
276
277| Key | Type | Default | Effect |
278|----------+--------+--------------------------+-----------------------------------------------------------------|
279| =match= | string | ="+LEVEL=2/-DONE"= | The entries that are projects |
280| =todo= | string | ="TODO NEXT NEXTACTION"= | Keywords, separated by spaces, that make a project active; =*= for any open one |
281| =tags= | string | =""= | Tags, separated by spaces, that make a project active; =*= for any |
282| =regexp= | string | =""= | An Emacs regular expression that makes a project active |
283
284These mirror the four elements of =org-stuck-projects=. See [[file:07-agenda.org][The agenda]].
285
274286** [org-agenda-time-grid]
275287
276288| Key | Type | Default | Effect |
@@ -504,6 +516,7 @@ Only variables whose names start with =org-=, =appt-=, =display-line-numbers=, =
504516| =org-agenda-prefix-format= | =[org-agenda-prefix-format]=: a string sets all three views; an alist sets =agenda=, =todo= and =tags= |
505517| =org-agenda-sorting-strategy= | =[org-agenda-sorting-strategy]=: a list sets all four views; an alist sets =agenda=, =todo=, =tags= and =search=. A list with =user-defined-up= or =user-defined-down= isn't imported |
506518| =org-agenda-sort-notime-is-late=, =org-agenda-sort-noeffort-is-high=, =org-agenda-use-time-grid=, =org-agenda-show-current-time-in-grid= | The same key, as booleans |
519| =org-stuck-projects= | =[org-stuck-projects]=: =match=, =todo=, =tags= and =regexp= from the four elements |
507520| =org-agenda-time-grid= | =[org-agenda-time-grid]=: =when= from the first element, =times= from the second; the strings are left out |
508521| =org-log-done=, =org-log-reschedule=, =org-log-redeadline= | The same key: =nil=, =time= (also =t=) or =note= |
509522| =org-log-into-drawer= | A string as given; =t= becomes ="LOGBOOK"=; =nil= becomes =""= |