Commit 681a4f41ab

681a4f41ab31a7a30c74fba602d5d0590443ef1c

parent: 06941b2cf2

Verified · cmc

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

Radio lists and org-timer

Radio lists: #+ATTR_ORG :radio checkbox lists (org-toggle-radio-button) through Toggle Checkbox and C-c C-c, and C-c C-c on a list's affiliated keywords repairs it; the #+ORGLST lists were removed in Org 9.2. org-timer: relative and countdown timers, timer values and items (M-RET in timer lists), pause, stop, offsets, shifting times in a region, mode-line display and countdown notifications, org-timer-format and org-timer-default-timer. C-c C-c on items keeps the caret in place.

Closes #46

Layout: unified · split

Sources/OrgApp/EmacsImport.swift +5
@@ -543,6 +543,11 @@ public struct EmacsImport: Sendable {
543 else if let keywords = value.elements?.compactMap(\.string), !keywords.isEmpty, keywords.count == value.elements?.count { 543 else if let keywords = value.elements?.compactMap(\.string), !keywords.isEmpty, keywords.count == value.elements?.count {
544 add(name, .string(keywords.joined(separator: " "))) 544 add(name, .string(keywords.joined(separator: " ")))
545 } else { note("unexpected value \(value.description)") } 545 } else { note("unexpected value \(value.description)") }
546 case "org-timer-format":
547 guard let format = value.string, format.contains("%s") else { return note("not a string with %s") }
548 add(name, .string(format))
549 case "org-timer-default-timer":
550 if let text = value.string { add(name, .string(text)) } else if let number = value.integer { add(name, .string(String(number))) } else { note("not a string or number") }
546 case "org-attach-id-dir": 551 case "org-attach-id-dir":
547 guard let dir = value.string else { return note("not a string") } 552 guard let dir = value.string else { return note("not a string") }
548 add(name, .string(dir)) 553 add(name, .string(dir))
Sources/OrgApp/OrgPreferences.swift +2
@@ -45,6 +45,8 @@ public enum OrgPreferences {
45 options.clockRoundingMinutes = integer("clockRoundingMinutes", defaults) 45 options.clockRoundingMinutes = integer("clockRoundingMinutes", defaults)
46 options.clockOutRemoveZeroTimeClocks = bool("clockRemoveZeroTime", defaults) 46 options.clockOutRemoveZeroTimeClocks = bool("clockRemoveZeroTime", defaults)
47 options.clockInSwitchToState = string("clockInSwitchToState", defaults).nonEmpty 47 options.clockInSwitchToState = string("clockInSwitchToState", defaults).nonEmpty
48 options.timerFormat = string("timerFormat", defaults).contains("%s") ? string("timerFormat", defaults) : "%s "
49 options.timerDefault = string("timerDefault", defaults).nonEmpty ?? "0"
48 let templates = UserConfig.structureTemplates(defaults) 50 let templates = UserConfig.structureTemplates(defaults)
49 options.structureTemplates = templates.isEmpty ? nil : StructureTemplate.merged(templates) 51 options.structureTemplates = templates.isEmpty ? nil : StructureTemplate.merged(templates)
50 options.trackOrderedPropertyWithTag = switch string("trackOrderedTag", defaults) { 52 options.trackOrderedPropertyWithTag = switch string("trackOrderedTag", defaults) {
Sources/OrgApp/TimerModel.swift added +44
@@ -0,0 +1,44 @@
1import Foundation
2import Observation
3import OrgCore
4@preconcurrency import UserNotifications
5
6/// The app's org-timer, which commands get in `EditingOptions.timer` and change through
7/// `Effect.timer`. A countdown ends with a notification and `onDone`.
8@MainActor @Observable
9public final class TimerModel {
10 public static let shared = TimerModel()
11
12 public private(set) var timer: OrgTimer?
13 /// The countdown's message when it ends, for the echo area.
14 @ObservationIgnored public var onDone: ((String) -> Void)?
15 @ObservationIgnored private var countdown: Task<Void, Never>?
16 static let notification = "sh.krz.orgstar.org-timer"
17
18 public init() {}
19
20 public func set(_ new: OrgTimer?) {
21 timer = new
22 countdown?.cancel()
23 countdown = nil
24 let center = UNUserNotificationCenter.current()
25 center.removePendingNotificationRequests(withIdentifiers: [Self.notification])
26 guard let new, new.isCountdown, new.paused == nil else { return }
27 let left = max(0, new.start.timeIntervalSinceNow)
28 countdown = Task { [weak self] in
29 try? await Task.sleep(for: .seconds(left))
30 guard !Task.isCancelled, let self, self.timer == new else { return }
31 self.timer = nil
32 self.onDone?(new.doneMessage)
33 }
34 // The notification shows when orgstar isn't in front, as `org-notify` does.
35 let content = UNMutableNotificationContent()
36 content.title = new.doneMessage
37 content.sound = .default
38 center.requestAuthorization(options: [.alert, .sound]) { granted, _ in
39 guard granted else { return }
40 center.add(UNNotificationRequest(identifier: Self.notification, content: content,
41 trigger: UNTimeIntervalNotificationTrigger(timeInterval: max(1, left), repeats: false)))
42 }
43 }
44}
Sources/OrgApp/UserConfig.swift +4
@@ -147,6 +147,10 @@ public enum UserConfig {
147 comment: "show image links as images when a file opens; #+STARTUP: (no)inlineimages overrides", legacy: ""), 147 comment: "show image links as images when a file opens; #+STARTUP: (no)inlineimages overrides", legacy: ""),
148 Setting(section: "", key: "org-startup-with-latex-preview", defaultsKey: "startupWithLatexPreview", kind: .bool, fallback: .bool(false), 148 Setting(section: "", key: "org-startup-with-latex-preview", defaultsKey: "startupWithLatexPreview", kind: .bool, fallback: .bool(false),
149 comment: "show LaTeX fragments as typeset math when a file opens; #+STARTUP: (no)latexpreview overrides", legacy: ""), 149 comment: "show LaTeX fragments as typeset math when a file opens; #+STARTUP: (no)latexpreview overrides", legacy: ""),
150 Setting(section: "", key: "org-timer-format", defaultsKey: "timerFormat", kind: .string, fallback: .string("%s "),
151 comment: "how Insert Timer Value writes the timer; %s is h:mm:ss", legacy: ""),
152 Setting(section: "", key: "org-timer-default-timer", defaultsKey: "timerDefault", kind: .string, fallback: .string("0"),
153 comment: "the countdown Set Countdown Timer offers, in minutes or h:mm:ss; 0 offers none", legacy: ""),
150 Setting(section: "", key: "org-attach-id-dir", defaultsKey: "attachIDDir", kind: .string, fallback: .string("data/"), 154 Setting(section: "", key: "org-attach-id-dir", defaultsKey: "attachIDDir", kind: .string, fallback: .string("data/"),
151 comment: "the folder attachment folders named by ID go in, relative to the org file's folder unless absolute", legacy: ""), 155 comment: "the folder attachment folders named by ID go in, relative to the org file's folder unless absolute", legacy: ""),
152 Setting(section: "", key: "org-attach-use-inheritance", defaultsKey: "attachUseInheritance", 156 Setting(section: "", key: "org-attach-use-inheritance", defaultsKey: "attachUseInheritance",
Sources/OrgCore/Commands/Command.swift +10
@@ -82,6 +82,12 @@ public struct EditingOptions: Sendable, Equatable, Codable {
82 public var prettyEntities: Bool 82 public var prettyEntities: Bool
83 /// `org-use-sub-superscripts` `{}`: only `_{…}` and `^{…}` are sub- and superscripts. 83 /// `org-use-sub-superscripts` `{}`: only `_{…}` and `^{…}` are sub- and superscripts.
84 public var subSuperscriptsNeedBraces: Bool 84 public var subSuperscriptsNeedBraces: Bool
85 /// The running org-timer, which the app keeps; nil when there is none.
86 public var timer: OrgTimer?
87 /// `org-timer-format`.
88 public var timerFormat = "%s "
89 /// `org-timer-default-timer`.
90 public var timerDefault = "0"
85 91
86 public init( 92 public init(
87 tagsColumn: Int = -77, insertHeadingRespectContent: Bool = false, metaReturnMaySplitLine: Bool = true, 93 tagsColumn: Int = -77, insertHeadingRespectContent: Bool = false, metaReturnMaySplitLine: Bool = true,
@@ -251,6 +257,8 @@ public enum Effect: Sendable, Equatable {
251 case fold(Int) 257 case fold(Int)
252 /// Read the file's `#+SETUPFILE`s again (`org-mode-restart`). 258 /// Read the file's `#+SETUPFILE`s again (`org-mode-restart`).
253 case refreshSetup 259 case refreshSetup
260 /// The org-timer becomes this; nil stops it.
261 case timer(OrgTimer?)
254} 262}
255 263
256public struct EditResult: Sendable, Equatable { 264public struct EditResult: Sendable, Equatable {
@@ -321,6 +329,8 @@ public enum Commands {
321 SetTags(), 329 SetTags(),
322 InsertItem(), InsertCheckboxItem(), IndentItem(), OutdentItem(), IndentItemTree(), OutdentItemTree(), 330 InsertItem(), InsertCheckboxItem(), IndentItem(), OutdentItem(), IndentItemTree(), OutdentItemTree(),
323 MoveItemUp(), MoveItemDown(), ToggleCheckbox(), 331 MoveItemUp(), MoveItemDown(), ToggleCheckbox(),
332 TimerStart(), TimerStart(offset: true), InsertTimer(), InsertTimerItem(), TimerPauseOrContinue(), TimerStop(),
333 TimerSetCountdown(), TimerShowRemaining(), TimerChangeTimes(),
324 InsertTimestamp(), InsertTimestamp(inactive: true), SetPlanning(deadline: false), SetPlanning(deadline: true), 334 InsertTimestamp(), InsertTimestamp(inactive: true), SetPlanning(deadline: false), SetPlanning(deadline: true),
325 RemovePlanning(deadline: false), RemovePlanning(deadline: true), FillParagraph(), CreateTable(), 335 RemovePlanning(deadline: false), RemovePlanning(deadline: true), FillParagraph(), CreateTable(),
326 TableRecalculate(all: false), TableRecalculate(all: true), ExecuteSrcBlock(), OrgDwim(), 336 TableRecalculate(all: false), TableRecalculate(all: true), ExecuteSrcBlock(), OrgDwim(),
Sources/OrgCore/Commands/CtrlCCtrlC.swift +24
@@ -53,9 +53,15 @@ public struct CtrlCCtrlC: OrgCommand {
53 } 53 }
54 if buffer.atTimestamp() != nil { return commitBuffer(context) { try $0.changeTimestamp(0, what: .day) } } 54 if buffer.atTimestamp() != nil { return commitBuffer(context) { try $0.changeTimestamp(0, what: .day) } }
55 if buffer.atHeading { return SetTags().run(in: context) } 55 if buffer.atHeading { return SetTags().run(in: context) }
56 if buffer.atItem, buffer.atRadioList() { return commitBuffer(context) { try $0.toggleRadioButton() } }
56 if buffer.atItem { 57 if buffer.atItem {
57 // The item's checkbox toggles, and the whole list is repaired, its cookie updated. 58 // The item's checkbox toggles, and the whole list is repaired, its cookie updated.
58 return commitBuffer(context) { buffer in 59 return commitBuffer(context) { buffer in
60 let origin = buffer.marker(buffer.point)
61 defer {
62 buffer.point = origin.position
63 buffer.release(origin)
64 }
59 buffer.point = buffer.lineStart(buffer.point) 65 buffer.point = buffer.lineStart(buffer.point)
60 let item = buffer.point 66 let item = buffer.point
61 var structure = buffer.listStruct() 67 var structure = buffer.listStruct()
@@ -71,6 +77,24 @@ public struct CtrlCCtrlC: OrgCommand {
71 buffer.updateCheckboxCount() 77 buffer.updateCheckboxCount()
72 } 78 }
73 } 79 }
80 if let list = buffer.affiliatedListStart() {
81 // On the list's affiliated keywords, the list is repaired.
82 var step = commitBuffer(context) { buffer in
83 let origin = buffer.marker(buffer.point)
84 defer {
85 buffer.point = origin.position
86 buffer.release(origin)
87 }
88 buffer.point = list
89 var structure = buffer.listStruct()
90 buffer.writeStruct(&structure, structure.parents, old: structure)
91 buffer.updateCheckboxCount()
92 }
93 if case .commit(let result) = step, result.edits.isEmpty {
94 step = .commit(EditResult(baseRevision: context.revision, edits: [], effects: [.message("Cannot update this checkbox")]))
95 }
96 return step
97 }
74 if buffer.lookingAtLine("^[ \\t]*#\\+[A-Za-z_]+:") { 98 if buffer.lookingAtLine("^[ \\t]*#\\+[A-Za-z_]+:") {
75 return .commit(EditResult(baseRevision: context.revision, edits: [], effects: [.refreshSetup, .message("Local setup has been refreshed")])) 99 return .commit(EditResult(baseRevision: context.revision, edits: [], effects: [.refreshSetup, .message("Local setup has been refreshed")]))
76 } 100 }
Sources/OrgCore/Commands/ListCommands.swift +58 −3
@@ -1,7 +1,7 @@
1import Foundation 1import Foundation
2 2
3// Plain list commands from org-list.el (Org 9.8.7) on `EmacsBuffer`, matched to Emacs by the 3// Plain list commands from org-list.el (Org 9.8.7) on `EmacsBuffer`, matched to Emacs by the
4// oracle tests. The ORDERED property, radio lists and timer items are not handled. 4// oracle tests. The ORDERED property is not handled.
5 5
6extension EmacsBuffer { 6extension EmacsBuffer {
7 /// `org-insert-item`. False when point isn't in an item. 7 /// `org-insert-item`. False when point isn't in an item.
@@ -83,8 +83,59 @@ extension EmacsBuffer {
83 moveToColumn(column) 83 moveToColumn(column)
84 } 84 }
85 85
86 static let affiliatedKeyword = "^[ \\t]*#\\+(?:attr_[-_A-Za-z0-9]+|caption|data|headers?|label|name|plot|resname|results?|source|srcname|tblname)(?:\\[.*\\])?:"
87
88 /// The first item of the list whose affiliated keywords hold point's line, or nil.
89 func affiliatedListStart() -> Int? {
90 saveExcursion {
91 beginningOfLine()
92 guard looking(Self.affiliatedKeyword) != nil else { return nil }
93 while looking(Self.affiliatedKeyword) != nil { if forwardLine(1) != 0 { return nil } }
94 guard looking(itemPattern) != nil, atItem, inItem() == point else { return nil }
95 return point
96 }
97 }
98
99 /// `org-at-radio-list-p`: point's line is an item of a list whose affiliated keywords have
100 /// `#+ATTR_ORG: … :radio` other than `nil`.
101 func atRadioList() -> Bool {
102 guard saveExcursion({ () -> Bool in beginningOfLine(); return looking(itemPattern) != nil }), let item = inItem() else { return false }
103 let structure = saveExcursion { point = item; return listStruct() }
104 guard structure.item(item) != nil else { return false }
105 var line = structure.listBegin(item, structure.prevs)
106 while line > 0 {
107 let previous = lineStart(line - 1)
108 let keyword = substring(previous, line)
109 guard keyword.range(of: Self.affiliatedKeyword, options: [.regularExpression, .caseInsensitive]) != nil else { break }
110 if let radio = keyword.firstMatch(of: /(?i)^[ \t]*#\+attr_org:.* :radio (\S+)/) { return radio.1 != "nil" }
111 line = previous
112 }
113 return false
114 }
115
116 /// `org-toggle-radio-button`: every item of the list at point unchecked, and the item at
117 /// point toggled.
118 func toggleRadioButton() throws {
119 guard atItem, let item = inItem() else { throw UserError(message: "Cannot toggle checkbox outside of a list") }
120 saveExcursion {
121 point = item
122 var structure = listStruct()
123 let old = structure
124 let parents = structure.parents
125 let box = structure.checkbox(item)
126 for pos in structure.allItems(structure.listBegin(item, structure.prevs), structure.prevs) {
127 structure.set(pos) { $0.checkbox = "[ ]" }
128 }
129 structure.set(item) { $0.checkbox = box == "[X]" ? "[ ]" : "[X]" }
130 fixCheckboxes(&structure, parents)
131 applyStruct(structure, old)
132 }
133 updateCheckboxCount()
134 }
135
86 /// `org-toggle-checkbox` on the item at point. 136 /// `org-toggle-checkbox` on the item at point.
87 func toggleCheckbox() throws { 137 func toggleCheckbox() throws {
138 if atRadioList() { return try toggleRadioButton() }
88 guard atItem else { throw UserError(message: "Not at an item or heading, and no active region") } 139 guard atItem else { throw UserError(message: "Not at an item or heading, and no active region") }
89 saveExcursion { 140 saveExcursion {
90 let lower = lineStart(point) 141 let lower = lineStart(point)
@@ -281,7 +332,9 @@ public struct InsertItem: OrgCommand {
281 public var title: String { "Insert Item" } 332 public var title: String { "Insert Item" }
282 public func applies(in context: EditContext) -> Bool { KeyContext.holds("item", in: context) } 333 public func applies(in context: EditContext) -> Bool { KeyContext.holds("item", in: context) }
283 public func run(in context: EditContext) -> CommandStep { 334 public func run(in context: EditContext) -> CommandStep {
284 listCommand(context) { buffer in 335 // A timer list's items are added by `org-timer-item`.
336 if EmacsBuffer.atTimerList(context) { return InsertTimerItem().run(in: context) }
337 return listCommand(context) { buffer in
285 guard buffer.insertListItem(checkbox: false) else { throw EmacsBuffer.UserError(message: "Not in an item") } 338 guard buffer.insertListItem(checkbox: false) else { throw EmacsBuffer.UserError(message: "Not in an item") }
286 } 339 }
287 } 340 }
@@ -294,7 +347,9 @@ public struct InsertCheckboxItem: OrgCommand {
294 public var title: String { "Insert Checkbox Item" } 347 public var title: String { "Insert Checkbox Item" }
295 public func applies(in context: EditContext) -> Bool { KeyContext.holds("item", in: context) } 348 public func applies(in context: EditContext) -> Bool { KeyContext.holds("item", in: context) }
296 public func run(in context: EditContext) -> CommandStep { 349 public func run(in context: EditContext) -> CommandStep {
297 listCommand(context) { buffer in 350 // A timer list's items are added by `org-timer-item`.
351 if EmacsBuffer.atTimerList(context) { return InsertTimerItem().run(in: context) }
352 return listCommand(context) { buffer in
298 guard buffer.insertListItem(checkbox: true) else { throw EmacsBuffer.UserError(message: "Not in an item") } 353 guard buffer.insertListItem(checkbox: true) else { throw EmacsBuffer.UserError(message: "Not in an item") }
299 } 354 }
300 } 355 }
Sources/OrgCore/Commands/Timer.swift added +343
@@ -0,0 +1,343 @@
1import Foundation
2
3/// org-timer (org-timer.el, Org 9.8.7): a relative timer counting up from a start time, or a
4/// countdown counting down to one. The app keeps the timer and gives it to commands in
5/// `EditingOptions.timer`; commands that change it return `Effect.timer`.
6public struct OrgTimer: Sendable, Equatable, Codable {
7 /// `org-timer-start-time`: when a relative timer read 0:00:00, or when a countdown ends.
8 public var start: Date
9 /// `org-timer-pause-time`.
10 public var paused: Date?
11 /// A countdown rather than a relative timer.
12 public var isCountdown: Bool
13 /// A countdown's title (`org-timer-countdown-timer-title`): its heading, or nil.
14 public var title: String?
15
16 public init(start: Date, paused: Date? = nil, isCountdown: Bool = false, title: String? = nil) {
17 self.start = start
18 self.paused = paused
19 self.isCountdown = isCountdown
20 self.title = title
21 }
22
23 /// The timer's seconds: counted up, or left for a countdown.
24 public func seconds(now: Date) -> Int {
25 let time = (paused ?? now).timeIntervalSince1970 - start.timeIntervalSince1970
26 return abs(Int((isCountdown ? -time : time).rounded(.down)))
27 }
28
29 /// `org-timer-value-string`.
30 public func value(now: Date, format: String = "%s ") -> String {
31 format.replacingOccurrences(of: "%s", with: Self.hms(seconds(now: now)))
32 }
33
34 /// The mode line's ` <0:01:23>`.
35 public func modeLine(now: Date, format: String = "%s ") -> String {
36 " <" + String(value(now: now, format: format).dropLast()) + ">"
37 }
38
39 /// The countdown's notification text when it ends.
40 public var doneMessage: String { "\(title ?? "nil"): time out" }
41
42 /// `org-timer-secs-to-hms`.
43 public static func hms(_ seconds: Int) -> String {
44 let sign = seconds < 0 ? "-" : ""
45 let s = abs(seconds)
46 return String(format: "%@%d:%02d:%02d", sign, s / 3600, s / 60 % 60, s % 60)
47 }
48
49 /// `org-timer-hms-to-secs`: 0 when it isn't h:mm:ss.
50 public static func seconds(_ hms: String) -> Int {
51 guard let m = hms.firstMatch(of: /([-+]?[0-9]+):([0-9]{2}):([0-9]{2})/) else { return 0 }
52 let total = abs(Int(m.1)!) * 3600 + Int(m.2)! * 60 + Int(m.3)!
53 return m.1.hasPrefix("-") ? -total : total
54 }
55
56 /// `org-timer-fix-incomplete`: `5` is 0:00:05 and `2:30` is 0:02:30.
57 public static func fixIncomplete(_ hms: String) -> String? {
58 guard let m = hms.firstMatch(of: /(?:([0-9]+:)?([0-9]+:))?([0-9]+)/) else { return nil }
59 let h = m.1.map { Int($0.dropLast())! } ?? 0
60 let mm = m.2.map { Int($0.dropLast())! } ?? 0
61 let replaced = String(format: "%d:%02d:%02d", h, mm, Int(m.3)!)
62 return hms.replacingCharacters(in: m.range, with: replaced)
63 }
64}
65
66extension Effect {
67 static func timerMessage(_ timer: OrgTimer?, _ message: String) -> [Effect] { [.timer(timer), .message(message)] }
68}
69
70/// The timer the context's options hold.
71private func timer(_ context: EditContext) -> OrgTimer? { context.options.timer }
72
73private func effects(_ context: EditContext, _ effects: [Effect]) -> CommandStep {
74 .commit(EditResult(baseRevision: context.revision, edits: [], effects: effects))
75}
76
77/// C-c C-x 0: `org-timer-start`, from 0:00:00, or with `offset` (C-u C-c C-x 0) from an
78/// offset asked for, defaulting to a timer stamp at point.
79public struct TimerStart: OrgCommand {
80 public let offset: Bool
81 public init(offset: Bool = false) { self.offset = offset }
82 public var id: String { offset ? "org.timer.start-offset" : "org.timer.start" }
83 public var title: String { offset ? "Start Timer with Offset…" : "Start Timer" }
84 public func applies(in context: EditContext) -> Bool { true }
85
86 public func run(in context: EditContext) -> CommandStep {
87 if timer(context)?.isCountdown == true { return .failed("Countdown timer is running. Cancel first") }
88 var delta = 0
89 if offset {
90 let line = (context.text as NSString).lineRange(for: NSRange(location: min(context.caret, (context.text as NSString).length), length: 0))
91 let lineText = (context.text as NSString).substring(with: line)
92 let caretInLine = context.caret - line.location
93 let atPoint = lineText.matches(of: /([-+]?[0-9]+):([0-9]{2}):([0-9]{2})/).first { m in
94 let start = lineText.utf16.distance(from: lineText.startIndex, to: m.range.lowerBound)
95 let end = lineText.utf16.distance(from: lineText.startIndex, to: m.range.upperBound)
96 return start <= caretInLine && caretInLine <= end
97 }.map { String(lineText[$0.range]) }
98 let def = atPoint ?? "0:00:00"
99 guard let answer = context.answers["offset"] else {
100 return .prompt(Prompt(key: "offset", message: "Restart timer with offset [\(def)]: ", requireMatch: false))
101 }
102 let typed = answer.contains(where: { !$0.isWhitespace }) ? answer : def
103 guard let fixed = OrgTimer.fixIncomplete(typed) else { return .failed("Cannot parse HMS string \"\(typed)\"") }
104 delta = OrgTimer.seconds(fixed)
105 }
106 let start = context.now.addingTimeInterval(-Double(delta))
107 return effects(context, Effect.timerMessage(OrgTimer(start: start), Self.message(start, delta, context)))
108 }
109
110 /// What `org-timer-start` says.
111 static func message(_ start: Date, _ delta: Int, _ context: EditContext) -> String {
112 let clock = DateFormatter()
113 clock.dateFormat = "HH:mm:ss"
114 clock.timeZone = context.calendar.timeZone
115 return "Timer start time set to \(clock.string(from: start)), current value is \(OrgTimer.hms(delta))"
116 }
117}
118
119/// C-c C-x ,: `org-timer-pause-or-continue`.
120public struct TimerPauseOrContinue: OrgCommand {
121 public init() {}
122 public var id: String { "org.timer.pause" }
123 public var title: String { "Pause or Continue Timer" }
124 public func applies(in context: EditContext) -> Bool { true }
125
126 public func run(in context: EditContext) -> CommandStep {
127 guard var current = timer(context) else { return .failed("No timer is running") }
128 let format = context.options.timerFormat
129 if let paused = current.paused {
130 let elapsed = paused.timeIntervalSince(current.start)
131 // A countdown runs again for what was left; a relative timer goes on from its value.
132 current.start = context.now.addingTimeInterval(-elapsed)
133 current.paused = nil
134 return effects(context, Effect.timerMessage(current, "Timer continues at \(current.value(now: context.now, format: format))"))
135 }
136 current.paused = context.now
137 return effects(context, Effect.timerMessage(current, "Timer paused at \(current.value(now: context.now, format: format))"))
138 }
139}
140
141/// C-c C-x _: `org-timer-stop`.
142public struct TimerStop: OrgCommand {
143 public init() {}
144 public var id: String { "org.timer.stop" }
145 public var title: String { "Stop Timer" }
146 public func applies(in context: EditContext) -> Bool { true }
147
148 public func run(in context: EditContext) -> CommandStep {
149 guard timer(context) != nil else { return .failed("No timer running") }
150 return effects(context, Effect.timerMessage(nil, "Timer stopped"))
151 }
152}
153
154/// C-c C-x .: `org-timer`, the timer's value at point, starting a relative timer first when
155/// none is running.
156public struct InsertTimer: OrgCommand {
157 public init() {}
158 public var id: String { "org.timer.insert" }
159 public var title: String { "Insert Timer Value" }
160 public func applies(in context: EditContext) -> Bool { true }
161
162 public func run(in context: EditContext) -> CommandStep {
163 let (current, started) = Self.timer(context)
164 let value = current.value(now: context.now, format: context.options.timerFormat)
165 let end = context.caret + (value as NSString).length
166 return .commit(EditResult(baseRevision: context.revision, edits: [TextEdit(range: context.caret..<context.caret, replacement: value)],
167 selection: [end..<end], effects: started ? Self.started(current, context) : []))
168 }
169
170 static func started(_ timer: OrgTimer, _ context: EditContext) -> [Effect] {
171 Effect.timerMessage(timer, TimerStart.message(timer.start, 0, context))
172 }
173
174 /// The running timer, or a new one started now.
175 static func timer(_ context: EditContext) -> (OrgTimer, started: Bool) {
176 if let current = context.options.timer { return (current, false) }
177 return (OrgTimer(start: context.now), true)
178 }
179}
180
181/// C-c C-x -: `org-timer-item`, a description item with the timer's value: a new item in a
182/// timer list, or a new list.
183public struct InsertTimerItem: OrgCommand {
184 public init() {}
185 public var id: String { "org.timer.item" }
186 public var title: String { "Insert Timer Item" }
187 public func applies(in context: EditContext) -> Bool { true }
188
189 public func run(in context: EditContext) -> CommandStep {
190 let (current, started) = InsertTimer.timer(context)
191 let value = current.value(now: context.now, format: context.options.timerFormat)
192 let step = commitBuffer(context) { try $0.timerItem(value) }
193 guard started, case .commit(let result) = step else { return step }
194 return .commit(EditResult(baseRevision: result.baseRevision, edits: result.edits, selection: result.selection, effects: result.effects + InsertTimer.started(current, context)))
195 }
196}
197
198/// C-c C-x ;: `org-timer-set-timer`, a countdown for the entry's Effort, or for a time asked
199/// for.
200public struct TimerSetCountdown: OrgCommand {
201 public init() {}
202 public var id: String { "org.timer.set" }
203 public var title: String { "Set Countdown Timer…" }
204 public func applies(in context: EditContext) -> Bool { true }
205
206 public func run(in context: EditContext) -> CommandStep {
207 let current = timer(context)
208 if let current, !current.isCountdown { return .failed("Relative timer is running. Stop first") }
209 let model = DocumentModel(tree: context.tree)
210 let heading = model.headings.lastIndex { $0.headingRange.lowerBound <= context.caret }
211 var minutes: String
212 if let heading, let effort = model.property("Effort", of: heading)?.value, effort.contains(where: { !$0.isWhitespace }),
213 let value = ColumnView.minutes(effort) {
214 minutes = String(Int(value.rounded(.down)))
215 } else {
216 let fallback = context.options.timerDefault
217 guard let answer = context.answers["minutes"] else {
218 return .prompt(Prompt(key: "minutes", message: "How much time left? (minutes or h:mm:ss) ", initial: fallback == "0" ? "" : fallback, requireMatch: false))
219 }
220 minutes = answer
221 }
222 if minutes.wholeMatch(of: /[0-9]+/) != nil { minutes += ":00" }
223 guard minutes.contains(where: \.isNumber) else { return TimerShowRemaining().run(in: context) }
224 if current != nil {
225 guard let replace = context.answers["replace"] else {
226 return .prompt(Prompt(key: "replace", message: "Replace current timer? (y or n) ", choices: ["y", "n"]))
227 }
228 if replace != "y" { return effects(context, [.message("No timer set")]) }
229 }
230 guard let fixed = OrgTimer.fixIncomplete(minutes) else { return .failed("Cannot parse HMS string \"\(minutes)\"") }
231 let seconds = OrgTimer.seconds(fixed)
232 // `org-get-heading`, which fails before the first heading.
233 let title: String? = heading == nil ? nil : EmacsBuffer(context.text, point: context.caret, settings: context.tree.settings).orgGetHeading()
234 return effects(context, [.timer(OrgTimer(start: context.now.addingTimeInterval(Double(seconds)), isCountdown: true, title: title))])
235 }
236}
237
238/// `org-timer-show-remaining-time`.
239public struct TimerShowRemaining: OrgCommand {
240 public init() {}
241 public var id: String { "org.timer.show-remaining" }
242 public var title: String { "Show Remaining Countdown Time" }
243 public func applies(in context: EditContext) -> Bool { true }
244
245 public func run(in context: EditContext) -> CommandStep {
246 guard let current = timer(context), current.isCountdown else { return effects(context, [.message("No timer set")]) }
247 let left = Int(((current.paused ?? context.now).distance(to: current.start)).rounded(.down))
248 return effects(context, [.message("\(left / 60) minute(s) \(left % 60) seconds left before next time out")])
249 }
250}
251
252/// C-u C-u C-c C-x 0: `org-timer-change-times-in-region`, every h:mm:ss in the region moved by
253/// a difference asked for, by default the one that makes the first 0:00:00.
254public struct TimerChangeTimes: OrgCommand {
255 public init() {}
256 public var id: String { "org.timer.change-times" }
257 public var title: String { "Shift Timer Values in Region…" }
258 public func applies(in context: EditContext) -> Bool { context.selection.first.map { !$0.isEmpty } ?? false }
259
260 public func run(in context: EditContext) -> CommandStep {
261 guard let region = context.selection.first, !region.isEmpty else { return .failed("The mark is not set now, so there is no region") }
262 guard var delta = context.answers["delta"] else {
263 return .prompt(Prompt(key: "delta", message: "Enter time difference like \"-1:08:26\". Default is first time to zero: ", requireMatch: false))
264 }
265 let pattern = try! NSRegularExpression(pattern: "[-+]?[0-9]+:[0-9]{2}:[0-9]{2}")
266 let first = pattern.firstMatch(in: context.text, range: NSRange(region))
267 if !delta.contains(where: { !$0.isWhitespace }), let first {
268 let stamp = (context.text as NSString).substring(with: first.range)
269 delta = stamp.hasPrefix("-") ? String(stamp.dropFirst()) : "-" + stamp
270 }
271 guard let fixed = OrgTimer.fixIncomplete(delta) else { return .failed("Cannot parse HMS string \"\(delta)\"") }
272 let seconds = OrgTimer.seconds(fixed)
273 guard seconds != 0 else { return .failed("No change") }
274 // `re-search-backward` from the region's end: the match starting nearest before the
275 // position and ending by it, so `0:00:00` inside `10:00:00` is found first.
276 let text = NSMutableString(string: context.text)
277 var position = region.upperBound
278 while position > region.lowerBound {
279 var found: NSRange?
280 var start = position - 1
281 while start >= region.lowerBound, found == nil {
282 found = pattern.firstMatch(in: text as String, options: .anchored, range: NSRange(location: start, length: position - start))?.range
283 start -= 1
284 }
285 guard let match = found else { break }
286 text.replaceCharacters(in: match, with: OrgTimer.hms(OrgTimer.seconds(text.substring(with: match)) + seconds))
287 position = match.location
288 }
289 let edits = TextEdit.between(context.text, text as String)
290 return .commit(EditResult(baseRevision: context.revision, edits: edits))
291 }
292}
293
294extension EmacsBuffer {
295 /// Whether the item at the caret starts with a timer, as `org-insert-item` checks.
296 static func atTimerList(_ context: EditContext) -> Bool {
297 let buffer = EmacsBuffer(context.text, point: context.caret, settings: context.tree.settings, options: context.options)
298 guard let item = buffer.inItem() else { return false }
299 buffer.point = item
300 return buffer.atTimerItem
301 }
302
303 /// `org-at-item-timer-p`.
304 var atTimerItem: Bool {
305 saveExcursion {
306 beginningOfLine()
307 guard let match = looking(itemPattern) else { return false }
308 point = match[0]!.upperBound
309 // `org-list-at-regexp-after-bullet-p`: past a counter, not a checkbox.
310 let counter = options.listAllowAlphabetical ? "(?:\\[@(?:start:)?([0-9]+|[A-Za-z])\\][ \\t]*)?" : "(?:\\[@(?:start:)?[0-9]+\\][ \\t]*)?"
311 return looking(counter + "([0-9]+:[0-9]+:[0-9]+)[ \\t]+::[ \\t]+") != nil
312 }
313 }
314
315 /// `org-timer-item` with the timer's `value`.
316 func timerItem(_ value: String) throws {
317 let pos = point
318 if let item = inItem() {
319 point = item
320 guard atTimerItem else {
321 point = pos
322 throw UserError(message: "This is not a timer list")
323 }
324 var structure = listStruct()
325 structure = insertItem(at: pos, structure, structure.prevs, checkbox: false, afterBullet: value + ":: ", splitLine: options.metaReturnMaySplitLine)
326 writeStruct(&structure, structure.parents)
327 beginningOfLine()
328 if let match = looking(Self.fullItemPattern) { point = match[0]!.upperBound }
329 return
330 }
331 // `org-indent-line` outside a list, with `org-adapt-indentation` nil: as the line
332 // above that isn't blank, or at column 0 after a heading or at the start.
333 let column = saveExcursion { () -> Int in
334 beginningOfLine()
335 skipBackward([32, 9, 10, 13])
336 guard point > 0 else { return 0 }
337 beginningOfLine()
338 return atHeading ? 0 : currentTextIndentation
339 }
340 indentLineTo(column)
341 insert("- " + value + ":: ")
342 }
343}
Sources/OrgCore/Keymap/PresetEmacs.swift +27
@@ -194,6 +194,33 @@ extension KeymapPreset {
194 keys = "C-c C-x C-l" 194 keys = "C-c C-x C-l"
195 command = "org.latex-preview" 195 command = "org.latex-preview"
196 [[bind]] 196 [[bind]]
197 keys = "C-c C-x 0"
198 command = "org.timer.start"
199 [[bind]]
200 keys = "C-u C-c C-x 0"
201 command = "org.timer.start-offset"
202 [[bind]]
203 keys = "C-u C-u C-c C-x 0"
204 command = "org.timer.change-times"
205 [[bind]]
206 keys = "C-c C-x ."
207 command = "org.timer.insert"
208 [[bind]]
209 keys = "C-c C-x -"
210 command = "org.timer.item"
211 [[bind]]
212 keys = "C-c C-x ,"
213 command = "org.timer.pause"
214 [[bind]]
215 keys = "C-u C-c C-x ,"
216 command = "org.timer.stop"
217 [[bind]]
218 keys = "C-c C-x _"
219 command = "org.timer.stop"
220 [[bind]]
221 keys = "C-c C-x ;"
222 command = "org.timer.set"
223 [[bind]]
197 keys = "C-c C-a a" 224 keys = "C-c C-a a"
198 command = "app.attach.attach" 225 command = "app.attach.attach"
199 [[bind]] 226 [[bind]]
Sources/Orgstar/ContentView.swift +2
@@ -67,6 +67,7 @@ struct ContentView: View {
67 ) 67 )
68 // The agenda files, for clock tables over `agenda` scopes. 68 // The agenda files, for clock tables over `agenda` scopes.
69 options.agendaFiles = workspace.agendaFilePaths() 69 options.agendaFiles = workspace.agendaFilePaths()
70 options.timer = TimerModel.shared.timer
70 return options 71 return options
71 } 72 }
72 /// A block being edited apart (`org-edit-special`). 73 /// A block being edited apart (`org-edit-special`).
@@ -324,6 +325,7 @@ struct ContentView: View {
324 } 325 }
325 .onChange(of: saveMode, initial: true) { _, mode in session.saveMode = mode } 326 .onChange(of: saveMode, initial: true) { _, mode in session.saveMode = mode }
326 .onChange(of: options, initial: true) { _, options in session.options = options } 327 .onChange(of: options, initial: true) { _, options in session.options = options }
328 .onAppear { TimerModel.shared.onDone = { [commands] in commands.show($0) } }
327 .onReceive(NotificationCenter.default.publisher(for: UserDefaults.didChangeNotification)) { _ in defaultsChanges += 1 } 329 .onReceive(NotificationCenter.default.publisher(for: UserDefaults.didChangeNotification)) { _ in defaultsChanges += 1 }
328 .onChange(of: preset, initial: true) { loadKeymap() } 330 .onChange(of: preset, initial: true) { loadKeymap() }
329 .sheet(isPresented: $showingImport) { EmacsImportView(workspace: workspace) } 331 .sheet(isPresented: $showingImport) { EmacsImportView(workspace: workspace) }
Sources/Orgstar/ModeLine.swift +14
@@ -48,6 +48,20 @@ struct ModeLine: View {
48 .foregroundStyle(theme.color("modeline-highlight") ?? .primary) 48 .foregroundStyle(theme.color("modeline-highlight") ?? .primary)
49 .help("Clocked in since \(running.startedAt.formatted(date: .omitted, time: .shortened))") 49 .help("Clocked in since \(running.startedAt.formatted(date: .omitted, time: .shortened))")
50 } 50 }
51 if let timer = TimerModel.shared.timer {
52 Menu {
53 Button(timer.paused == nil ? "Pause Timer" : "Continue Timer") { commands.editor?.run("org.timer.pause") }
54 Button("Stop Timer") { commands.editor?.run("org.timer.stop") }
55 } label: {
56 TimelineView(.periodic(from: .now, by: 1)) { context in
57 Text(timer.modeLine(now: context.date)).font(.system(.caption, design: .monospaced))
58 }
59 }
60 .menuStyle(.borderlessButton)
61 .menuIndicator(.hidden)
62 .fixedSize()
63 .help(timer.isCountdown ? "Countdown timer" : "Relative timer")
64 }
51 if selection.length > 0, let region = region(text, selection) { 65 if selection.length > 0, let region = region(text, selection) {
52 Text("\(region.lines) \(region.lines == 1 ? "line" : "lines"), \(region.words) \(region.words == 1 ? "word" : "words"), \(region.characters) chars") 66 Text("\(region.lines) \(region.lines == 1 ? "line" : "lines"), \(region.words) \(region.words == 1 ? "word" : "words"), \(region.characters) chars")
53 .help("Selection (count-words-region)") 67 .help("Selection (count-words-region)")
Sources/Orgstar/PaneView.swift +1
@@ -130,6 +130,7 @@ struct PaneView: NSViewRepresentable {
130 NSPasteboard.general.clearContents() 130 NSPasteboard.general.clearContents()
131 NSPasteboard.general.setString(text, forType: .string) 131 NSPasteboard.general.setString(text, forType: .string)
132 case .refreshSetup: session?.refreshSetup() 132 case .refreshSetup: session?.refreshSetup()
133 case .timer(let timer): TimerModel.shared.set(timer)
133 case .message, .sparseTree, .fold: break 134 case .message, .sparseTree, .fold: break
134 } 135 }
135 } 136 }
Sources/OrgstarMobile/EditorScreen.swift +16 −6
@@ -32,6 +32,7 @@ struct EditorScreen: View {
32 var options = session.options 32 var options = session.options
33 options.filePath = path 33 options.filePath = path
34 options.agendaFiles = workspace.agendaFilePaths() 34 options.agendaFiles = workspace.agendaFilePaths()
35 options.timer = TimerModel.shared.timer
35 return options 36 return options
36 } 37 }
37 38
@@ -137,13 +138,21 @@ struct EditorScreen: View {
137 } 138 }
138 } 139 }
139 .safeAreaInset(edge: .top) { 140 .safeAreaInset(edge: .top) {
140 if let message { 141 VStack(spacing: 0) {
141 Text(message).font(.callout).padding(8).frame(maxWidth: .infinity).background(.bar) 142 if let timer = TimerModel.shared.timer {
142 .onTapGesture { self.message = nil } 143 TimelineView(.periodic(from: .now, by: 1)) { context in
143 .task(id: message) { 144 Text(timer.modeLine(now: context.date)).font(.callout.monospacedDigit())
144 try? await Task.sleep(for: .seconds(4))
145 if self.message == message { self.message = nil }
146 } 145 }
146 .frame(maxWidth: .infinity).padding(4).background(.bar)
147 }
148 if let message {
149 Text(message).font(.callout).padding(8).frame(maxWidth: .infinity).background(.bar)
150 .onTapGesture { self.message = nil }
151 .task(id: message) {
152 try? await Task.sleep(for: .seconds(4))
153 if self.message == message { self.message = nil }
154 }
155 }
147 } 156 }
148 } 157 }
149 .sheet(item: $prompt) { request in 158 .sheet(item: $prompt) { request in
@@ -239,6 +248,7 @@ struct EditorScreen: View {
239 editor?.modal = model.modalKeys 248 editor?.modal = model.modalKeys
240 } 249 }
241 .onChange(of: model.showMarkup) { editor?.showMarkup = model.showMarkup } 250 .onChange(of: model.showMarkup) { editor?.showMarkup = model.showMarkup }
251 .onChange(of: TimerModel.shared.timer) { editor?.options = editorOptions }
242 .onDisappear { 252 .onDisappear {
243 // Typing the reader shows next, and a save, don't wait for the autosave delay. 253 // Typing the reader shows next, and a save, don't wait for the autosave delay.
244 if session.dirtyPaths.contains(path) { _ = session.save(path) } 254 if session.dirtyPaths.contains(path) { _ = session.save(path) }
Sources/OrgstarMobile/MobileEditor.swift +1
@@ -219,6 +219,7 @@ final class MobileEditor: NSObject, DocumentBuffer {
219 state.folds.insert(start) 219 state.folds.insert(start)
220 setFolds(state) 220 setFolds(state)
221 case .refreshSetup: onRefreshSetup?() 221 case .refreshSetup: onRefreshSetup?()
222 case .timer(let timer): TimerModel.shared.set(timer)
222 default: break 223 default: break
223 } 224 }
224 } 225 }
Sources/OrgstarMobile/OrgstarMobileApp.swift +3
@@ -47,6 +47,8 @@ final class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCent
47 nonisolated func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification) async -> UNNotificationPresentationOptions { 47 nonisolated func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification) async -> UNNotificationPresentationOptions {
48 // A midnight badge update shows nothing else. 48 // A midnight badge update shows nothing else.
49 if notification.request.content.badge != nil { return [.badge] } 49 if notification.request.content.badge != nil { return [.badge] }
50 // A countdown's end shows in the app's own message.
51 if notification.request.identifier == "sh.krz.orgstar.org-timer" { return [] }
50 return [.banner, .sound, .list] 52 return [.banner, .sound, .list]
51 } 53 }
52 54
@@ -254,6 +256,7 @@ struct RootView: View {
254 } 256 }
255 } 257 }
256 .task { 258 .task {
259 TimerModel.shared.onDone = { message = $0 }
257 takeShared() 260 takeShared()
258 // Development: `ORGSTAR_ROOT` adds a folder at launch, as on the Mac. 261 // Development: `ORGSTAR_ROOT` adds a folder at launch, as on the Mac.
259 if let root = ProcessInfo.processInfo.environment["ORGSTAR_ROOT"] { try? await workspace.addRoot(URL(fileURLWithPath: root)) } 262 if let root = ProcessInfo.processInfo.environment["ORGSTAR_ROOT"] { try? await workspace.addRoot(URL(fileURLWithPath: root)) }
Tests/OrgCoreTests/ListCommandTests.swift +28
@@ -80,3 +80,31 @@ struct ListOracleTests {
80 try compareWithEmacs(samples, Self.commands) 80 try compareWithEmacs(samples, Self.commands)
81 } 81 }
82} 82}
83
84/// Checkbox lists with `#+ATTR_ORG: :radio t`: one box checked at a time.
85struct RadioListOracleTests {
86 static let variants = [
87 "#+ATTR_ORG: :radio t\n- [ ] a\n- [X] b\n- [ ] c\n",
88 "#+attr_org: :radio t\n- a\n- [ ] b\n",
89 "#+ATTR_ORG: :radio nil\n- [ ] a\n- [X] b\n",
90 "#+NAME: pick\n#+ATTR_ORG: :width 10 :radio yes\n#+CAPTION: c\n- [X] a\n- [ ] b\n",
91 "* T [1/3]\n#+ATTR_ORG: :radio t\n- [ ] a\n- [X] b\n- [ ] c\n",
92 "#+ATTR_ORG: :radio t\n- [ ] a\n - [ ] x\n - [X] y\n- [X] b\n",
93 "#+ATTR_ORG: :radio t\n#+TITLE: t\n- [ ] a\n- [X] b\n",
94 "#+ATTR_ORG: :radio t\n\n- [ ] a\n- [X] b\n",
95 "#+ATTR_ORG: :radio t\n1. [ ] one\n2. [ ] two\n",
96 ]
97
98 static let commands: [(command: any OrgCommand, form: String, headingLineOnly: Bool)] = [
99 (ToggleCheckbox(), "(if (org-at-heading-p) (error \"heading\") (org-toggle-checkbox))", false),
100 (CtrlCCtrlC(), "(org-ctrl-c-ctrl-c)", false),
101 ]
102
103 @Test(.enabled(if: ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil))
104 func radioButtonsMatchEmacs() throws {
105 // Off heading lines, where C-c C-c asks for tags.
106 try compareWithEmacs(Self.variants.map { text in
107 (text, EmacsOracle.positions(text).filter { headingOnLine(at: $0, in: OrgParser.parse(text)) == nil })
108 }, Self.commands)
109 }
110}
Tests/OrgCoreTests/TimerTests.swift added +177
@@ -0,0 +1,177 @@
1import Foundation
2import Testing
3@testable import OrgCore
4
5/// org-timer against Emacs with the clock frozen: the text the commands insert, and the
6/// messages and timers the others leave.
7struct TimerOracleTests {
8 static let now = 1_789_000_000
9 static func date(_ seconds: Int) -> Date { Date(timeIntervalSince1970: TimeInterval(seconds)) }
10
11 /// The timer as Lisp sets it, and as ours.
12 static let timers: [(lisp: String, timer: OrgTimer?)] = [
13 ("", nil),
14 ("(setq org-timer-start-time (seconds-to-time \(now - 75)))", OrgTimer(start: date(now - 75))),
15 ("(setq org-timer-start-time (seconds-to-time \(now - 100)) org-timer-pause-time (seconds-to-time \(now - 40)))",
16 OrgTimer(start: date(now - 100), paused: date(now - 40))),
17 ("(setq org-timer-start-time (seconds-to-time \(now + 3725)) org-timer-countdown-timer (run-with-timer 3725 nil #'ignore) org-timer-countdown-timer-title \"T\")",
18 OrgTimer(start: date(now + 3725), isCountdown: true, title: "T")),
19 ]
20
21 static func context(_ text: String, caret: Int, timer: OrgTimer?, selection: Range<Int>? = nil, answers: [String: String] = [:]) -> EditContext {
22 var options = EditingOptions.org
23 options.timer = timer
24 var utc = Calendar(identifier: .gregorian)
25 utc.timeZone = TimeZone(identifier: "UTC")!
26 return EditContext(revision: 0, text: text, tree: OrgParser.parse(text), selection: [selection ?? caret..<caret],
27 now: date(now), calendar: utc, answers: answers, options: options)
28 }
29
30 @Test(.enabled(if: ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil))
31 func insertingMatchesEmacs() throws {
32 let texts = ["* H\n\n", "* H\nfoo\n", "- 0:00:05 :: a\n- 0:01:00 :: b\n", "- a\n- b\n", " text\n", "1. 0:00:03 :: x\n", "- [ ] 0:00:01 :: c\n"]
33 let commands: [(command: any OrgCommand, form: String)] = [
34 (InsertTimer(), "(org-timer)"),
35 (InsertTimerItem(), "(org-timer-item)"),
36 (InsertItem(), "(or (org-insert-item) (error \"Not in an item\"))"),
37 ]
38 var cases: [EmacsOracle.Case] = []
39 var ours: [(label: String, text: String, caret: Int, failed: Bool)] = []
40 for text in texts {
41 for offset in EmacsOracle.positions(text) {
42 for (lisp, timer) in Self.timers {
43 for (command, form) in commands {
44 cases.append(EmacsOracle.Case(text: text, point: EmacsOracle.point(offset, in: text),
45 form: frozenClock(Self.now, "(progn (require 'org-timer) (setq org-timer-start-time nil org-timer-pause-time nil org-timer-countdown-timer nil) \(lisp) \(form))")))
46 let label = "\(command.id) at \(offset) with \(lisp) in \(text.debugDescription)"
47 switch command.run(in: Self.context(text, caret: offset, timer: timer)) {
48 case .commit(let result):
49 let new = result.edits.sorted { $0.range.lowerBound > $1.range.lowerBound }.reduce(text) { $1.apply(to: $0) }
50 ours.append((label, new, result.selection?.first?.lowerBound ?? offset, false))
51 default:
52 ours.append((label, text, offset, true))
53 }
54 }
55 }
56 }
57 }
58 let results = try EmacsOracle.run(cases)
59 var mismatches = 0
60 for (mine, theirs) in zip(ours, results) {
61 let theirCaret = theirs.text.unicodeScalars.prefix(theirs.point - 1).reduce(0) { $0 + $1.utf16.count }
62 let same = mine.failed ? !theirs.error.isEmpty : theirs.error.isEmpty && mine.text == theirs.text && mine.caret == theirCaret
63 if !same {
64 mismatches += 1
65 if mismatches <= 15 { Issue.record("\(mine.label)\n ours: \(mine.failed ? "failed" : mine.text.debugDescription) @\(mine.caret)\n emacs: \(theirs.error.isEmpty ? theirs.text.debugDescription : theirs.error) @\(theirCaret)") }
66 }
67 }
68 #expect(mismatches == 0, "\(mismatches) of \(cases.count) cases differ")
69 }
70
71 /// What a command leaves: its message, and the timer as `start paused countdown title`.
72 static let report = """
73 (format "%s|%s" msg
74 (if org-timer-start-time
75 (format "%s %s %s %s" (format-time-string "%s" org-timer-start-time)
76 (if org-timer-pause-time (format-time-string "%s" org-timer-pause-time) "nil")
77 (if org-timer-countdown-timer "t" "nil")
78 (if org-timer-countdown-timer org-timer-countdown-timer-title "nil"))
79 "none"))
80 """
81
82 static func ourReport(_ step: CommandStep, before: OrgTimer?) -> String {
83 var message = ""
84 var timer = before
85 switch step {
86 case .commit(let result):
87 for effect in result.effects {
88 if case .message(let m) = effect { message = m }
89 if case .timer(let t) = effect { timer = t }
90 }
91 case .failed(let m): message = m
92 default: message = "prompt"
93 }
94 let state = timer.map { t in
95 "\(Int(t.start.timeIntervalSince1970)) \(t.paused.map { String(Int($0.timeIntervalSince1970)) } ?? "nil") \(t.isCountdown ? "t" : "nil") \(t.isCountdown ? (t.title ?? "nil") : "nil")"
96 } ?? "none"
97 return message + "|" + state
98 }
99
100 @Test(.enabled(if: ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil))
101 func timerStateMatchesEmacs() throws {
102 let text = "* TODO Write :work:\n:PROPERTIES:\n:Effort: 0:25\n:END:\n* Plain\n- 0:02:10 :: x\n"
103 let plain = (text as NSString).range(of: "* Plain").location
104 let stamp = (text as NSString).range(of: "0:02:10").location + 3
105 // Command, Lisp, caret, answers, and the stubbed minibuffer answer.
106 let commands: [(command: any OrgCommand, form: String, caret: Int, answers: [String: String])] = [
107 (TimerStart(), "(org-timer-start)", 0, [:]),
108 (TimerStart(offset: true), "(org-timer-start '(4))", 0, ["offset": "1:30"]),
109 (TimerStart(offset: true), "(org-timer-start '(4))", stamp, ["offset": ""]),
110 (TimerPauseOrContinue(), "(org-timer-pause-or-continue)", 0, [:]),
111 (TimerStop(), "(org-timer-stop)", 0, [:]),
112 (TimerShowRemaining(), "(org-timer-show-remaining-time)", 0, [:]),
113 (TimerSetCountdown(), "(org-timer-set-timer)", 0, ["replace": "n"]),
114 (TimerSetCountdown(), "(org-timer-set-timer)", plain, ["minutes": "10", "replace": "y"]),
115 (TimerSetCountdown(), "(org-timer-set-timer)", plain, ["minutes": "1:02:03", "replace": "n"]),
116 (InsertTimer(), "(org-timer)", 0, [:]),
117 ]
118 var cases: [EmacsOracle.Case] = []
119 var ours: [String] = []
120 for (lisp, timer) in Self.timers {
121 for (command, form, caret, answers) in commands {
122 let minibuffer = answers["minutes"] ?? answers["offset"] ?? ""
123 let yes = answers["replace"] == "y" ? "t" : "nil"
124 let body = """
125 (progn (require 'org-timer)
126 (let ((msg ""))
127 (cl-letf (((symbol-function 'message) (lambda (f &rest a) (setq msg (if f (apply #'format f a) ""))))
128 ((symbol-function 'read-string) (lambda (&rest _) \(minibuffer.debugDescription)))
129 ((symbol-function 'read-from-minibuffer) (lambda (&rest _) \(minibuffer.debugDescription)))
130 ((symbol-function 'y-or-n-p) (lambda (&rest _) \(yes)))
131 )
132 (setq org-timer-start-time nil org-timer-pause-time nil org-timer-countdown-timer nil)
133 \(lisp)
134 (condition-case e \(form) (error (setq msg (error-message-string e))))
135 (let ((r \(Self.report))) (erase-buffer) (insert r)))))
136 """
137 cases.append(EmacsOracle.Case(text: text, point: EmacsOracle.point(caret, in: text), form: frozenClock(Self.now, body)))
138 ours.append(Self.ourReport(command.run(in: Self.context(text, caret: caret, timer: timer, answers: answers)), before: timer))
139 }
140 }
141 let results = try EmacsOracle.run(cases)
142 for (index, (mine, theirs)) in zip(ours, results).enumerated() {
143 #expect(mine == theirs.text, "case \(index) ours \(mine.debugDescription) emacs \(theirs.text.debugDescription) \(theirs.error)")
144 }
145 }
146
147 @Test(.enabled(if: ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil))
148 func changingTimesMatchesEmacs() throws {
149 let text = "- 0:01:10 :: a\n- 0:02:00 :: b\n- -0:00:05 x 10:00:00\n"
150 let region = 0..<(text as NSString).length
151 var cases: [EmacsOracle.Case] = []
152 var ours: [String] = []
153 for delta in ["", "0:01:00", "-30", "1:00:00:00", "0:00:00"] {
154 cases.append(EmacsOracle.Case(text: text, point: 1, form: """
155 (progn (require 'org-timer) (org-timer-change-times-in-region (point-min) (point-max) \(delta.debugDescription)))
156 """))
157 switch TimerChangeTimes().run(in: Self.context(text, caret: 0, timer: nil, selection: region, answers: ["delta": delta])) {
158 case .commit(let result): ours.append(result.edits.sorted { $0.range.lowerBound > $1.range.lowerBound }.reduce(text) { $1.apply(to: $0) })
159 case .failed(let message): ours.append("error: " + message)
160 default: ours.append("prompt")
161 }
162 }
163 let results = try EmacsOracle.run(cases)
164 for (mine, theirs) in zip(ours, results) {
165 #expect(mine == (theirs.error.isEmpty ? theirs.text : "error: " + theirs.error), "ours \(mine.debugDescription) emacs \(theirs.text.debugDescription)")
166 }
167 }
168
169 @Test func conversions() {
170 #expect(OrgTimer.hms(3725) == "1:02:05")
171 #expect(OrgTimer.hms(-65) == "-0:01:05")
172 #expect(OrgTimer.seconds("-1:00:01") == -3601)
173 #expect(OrgTimer.fixIncomplete("5") == "0:00:05")
174 #expect(OrgTimer.fixIncomplete("2:30") == "0:02:30")
175 #expect(OrgTimer(start: Self.date(Self.now - 75)).modeLine(now: Self.date(Self.now)) == " <0:01:15>")
176 }
177}
docs/manual/guide/03-keys.org +9
@@ -901,6 +901,15 @@ When a key appears in several rows, it runs the command whose condition holds at
901| Resolve Open Clocks… (=app.clock.resolve=) | =C-c C-x C-z= | — | =SPC m c r= (N) | Asks what to do with each open =CLOCK:= line in your folders (=org-resolve-clocks=). | 901| Resolve Open Clocks… (=app.clock.resolve=) | =C-c C-x C-z= | — | =SPC m c r= (N) | Asks what to do with each open =CLOCK:= line in your folders (=org-resolve-clocks=). |
902| Clock Report (=app.clock.report=) | — | — | =SPC z t= (N), =SPC m c R= (N) | Opens the Clock Report window. | 902| Clock Report (=app.clock.report=) | — | — | =SPC z t= (N), =SPC m c R= (N) | Opens the Clock Report window. |
903| Insert or Update Clock Table (=org.clock.report=) | =C-c C-x C-r= | — | — | Inserts a clock table, or updates the one at point (=org-clock-report=). | 903| Insert or Update Clock Table (=org.clock.report=) | =C-c C-x C-r= | — | — | Inserts a clock table, or updates the one at point (=org-clock-report=). |
904| Start Timer (=org.timer.start=) | =C-c C-x 0= | — | — | Starts the relative timer (=org-timer-start=). See [[file:06-dates-and-clocking.org][Dates and clocking]]. |
905| Start Timer with Offset… (=org.timer.start-offset=) | =C-u C-c C-x 0= | — | — | Starts the timer from a value asked for (=org-timer-start= with =C-u=). |
906| Shift Timer Values in Region… (=org.timer.change-times=) | =C-u C-u C-c C-x 0= | — | — | Moves every timer value in the selection by a difference (=org-timer-change-times-in-region=). |
907| Insert Timer Value (=org.timer.insert=) | =C-c C-x .= | — | — | Inserts the timer's value, starting the timer if needed (=org-timer=). |
908| Insert Timer Item (=org.timer.item=) | =C-c C-x -= | — | — | Inserts a timer list item (=org-timer-item=). |
909| Pause or Continue Timer (=org.timer.pause=) | =C-c C-x ,= | — | — | Pauses or continues the timer (=org-timer-pause-or-continue=). |
910| Stop Timer (=org.timer.stop=) | =C-c C-x _=, =C-u C-c C-x ,= | — | — | Stops the timer (=org-timer-stop=). |
911| Set Countdown Timer… (=org.timer.set=) | =C-c C-x ;= | — | — | Starts a countdown (=org-timer-set-timer=). |
912| Show Remaining Countdown Time (=org.timer.show-remaining=) | — | — | — | Says how long the countdown has left (=org-timer-show-remaining-time=). |
904 913
905** Tables 914** Tables
906 915
docs/manual/guide/04-outlines.org +19 −1
@@ -405,6 +405,24 @@ subitems").
405Toggle Checkbox works only on item lines. Org's behaviour on a heading, toggling the 405Toggle Checkbox works only on item lines. Org's behaviour on a heading, toggling the
406checkboxes of the region or subtree, is not available. 406checkboxes of the region or subtree, is not available.
407 407
408** Radio lists
409
410A list with =:radio= in its =#+ATTR_ORG:= line, other than =:radio nil=, is a radio list:
411checking one item unchecks the others. Toggle Checkbox and =C-c C-c= on an item check it
412and uncheck the rest of its list (=org-toggle-radio-button=); items without a checkbox
413get one.
414
415#+BEGIN_SRC org
416,#+ATTR_ORG: :radio t
417- [ ] tea
418- [X] coffee
419- [ ] water
420#+END_SRC
421
422=C-c C-c= on an =#+ATTR_ORG:= or other affiliated keyword line of a list repairs the
423list, as on an item without a checkbox. Org's =org-list-checkbox-radio-mode=, which makes
424every list in a buffer a radio list, isn't available.
425
408** Statistics cookies 426** Statistics cookies
409 427
410A cookie =[/]= or =[%]= on a heading or an item shows progress: 428A cookie =[/]= or =[%]= on a heading or an item shows progress:
@@ -1004,4 +1022,4 @@ These Org structure features are not in orgstar:
1004 1022
1005- Editing values in column view, and writing summaries from it; the 1023- Editing values in column view, and writing summaries from it; the
1006 =columnview= dynamic block does write summaries. 1024 =columnview= dynamic block does write summaries.
1007- The =ORDERED= property, radio lists and timer list items in the list commands. 1025- The =ORDERED= property in the list commands.
docs/manual/guide/06-dates-and-clocking.org +32
@@ -204,6 +204,38 @@ Set Effort asks for a value, such as =0:30= or =2:00=, starting with the current
204 204
205Effort appears in column view and in clock tables with =:properties ("Effort")=. orgstar does not compare the running clock with the effort estimate. 205Effort appears in column view and in clock tables with =:properties ("Effort")=. orgstar does not compare the running clock with the effort estimate.
206 206
207* Timers
208
209orgstar has Org's relative timer, which counts up from when it starts, and its countdown
210timer (org-timer). One timer runs at a time, for every file; it shows in the mode line as
211=<0:01:23>= (above the text on iOS) and stops when orgstar quits.
212
213| Command | Emacs | What it does |
214|-+-+-|
215| Start Timer | =C-c C-x 0= | Starts the relative timer at 0:00:00. |
216| Start Timer with Offset… | =C-u C-c C-x 0= | Asks for a value to start from, =h:mm:ss= or a shorter =m:ss= or seconds; empty takes the timer value at the caret, or 0:00:00. |
217| Insert Timer Value | =C-c C-x .= | Inserts the timer's value, as =0:01:23 =; starts the timer first when none is running. |
218| Insert Timer Item | =C-c C-x -= | Inserts a timer item, =- 0:01:23 :: =: a new item in a timer list, or a new list elsewhere. |
219| Pause or Continue Timer | =C-c C-x ,= | Pauses the timer, or lets a paused one go on. |
220| Stop Timer | =C-c C-x _=, =C-u C-c C-x ,= | Stops the timer. |
221| Set Countdown Timer… | =C-c C-x ;= | Starts a countdown for the entry's =Effort=, or asks how long: minutes, or =h:mm:ss=. |
222| Show Remaining Countdown Time | — | Says how long the countdown has left. |
223| Shift Timer Values in Region… | =C-u C-u C-c C-x 0= | Adds a difference to every =h:mm:ss= in the selection; empty makes the first one 0:00:00. |
224
225M-RET in a timer list inserts a timer item, so notes taken in a meeting can be stamped as
226they're written:
227
228#+BEGIN_SRC org
229- 0:00:05 :: Introductions
230- 0:04:40 :: Budget
231#+END_SRC
232
233When a countdown ends, orgstar shows =Heading: time out=, and a notification when it isn't
234in front. Starting a relative timer during a countdown, or a countdown during a relative
235timer, is refused until the other is stopped. =org-timer-format= (="%s "=) sets what Insert
236Timer Value writes, and =org-timer-default-timer= the countdown Set Countdown Timer… offers;
237see [[file:13-configuration.org][Configuration]].
238
207* Clocking 239* Clocking
208 240
209Clocking records the time you work on an entry as =CLOCK:= lines in its =LOGBOOK= drawer. 241Clocking records the time you work on an entry as =CLOCK:= lines in its =LOGBOOK= drawer.
docs/manual/guide/13-configuration.org +4
@@ -160,6 +160,7 @@ These settings have no control in the Settings window. Some are in the View menu
160| =org-archive-location= | | 160| =org-archive-location= | |
161| =org-use-tag-inheritance=, =org-tags-exclude-from-inheritance=, =org-tag-alist= | | 161| =org-use-tag-inheritance=, =org-tags-exclude-from-inheritance=, =org-tag-alist= | |
162| =org-track-ordered-property-with-tag= | | 162| =org-track-ordered-property-with-tag= | |
163| =org-timer-format=, =org-timer-default-timer= | |
163| =org-attach-id-dir=, =org-attach-use-inheritance= | | 164| =org-attach-id-dir=, =org-attach-use-inheritance= | |
164| =org-crypt-tag-matcher= | | 165| =org-crypt-tag-matcher= | |
165| =org-agenda-start-on-weekday= | | 166| =org-agenda-start-on-weekday= | |
@@ -210,6 +211,8 @@ A key you remove from the file goes back to its default. A key that isn't in the
210| =org-tags-exclude-from-inheritance= | string | =""= | Tags that never inherit, separated by spaces. Read at launch. Mirrors =org-tags-exclude-from-inheritance=. | 211| =org-tags-exclude-from-inheritance= | string | =""= | Tags that never inherit, separated by spaces. Read at launch. Mirrors =org-tags-exclude-from-inheritance=. |
211| =org-tag-alist= | string | =""= | The tags Set Tags offers in files without =#+TAGS=, in =#+TAGS= syntax with keys and groups, rows separated by =\n=. Mirrors =org-tag-alist=. | 212| =org-tag-alist= | string | =""= | The tags Set Tags offers in files without =#+TAGS=, in =#+TAGS= syntax with keys and groups, rows separated by =\n=. Mirrors =org-tag-alist=. |
212| =org-track-ordered-property-with-tag= | string | ="nil"= | A tag that Toggle ORDERED Property adds and removes with the property: ="t"= for the tag =ORDERED=, or a tag name. Mirrors =org-track-ordered-property-with-tag=. | 213| =org-track-ordered-property-with-tag= | string | ="nil"= | A tag that Toggle ORDERED Property adds and removes with the property: ="t"= for the tag =ORDERED=, or a tag name. Mirrors =org-track-ordered-property-with-tag=. |
214| =org-timer-format= | string | ="%s "= | What Insert Timer Value writes, with =%s= for the =h:mm:ss= value. Mirrors =org-timer-format=. |
215| =org-timer-default-timer= | string | ="0"= | The countdown Set Countdown Timer… offers, in minutes or =h:mm:ss=; ="0"= offers none. Mirrors =org-timer-default-timer=. |
213| =org-attach-id-dir= | string | ="data/"= | The folder ID-based attachment folders go in, relative to the org file's folder unless absolute. See [[file:04-outlines.org][Outlines]]. Mirrors =org-attach-id-dir=. | 216| =org-attach-id-dir= | string | ="data/"= | The folder ID-based attachment folders go in, relative to the org file's folder unless absolute. See [[file:04-outlines.org][Outlines]]. Mirrors =org-attach-id-dir=. |
214| =org-attach-use-inheritance= | string | ="selective"= | Whether attachment folders come from an ancestor's =DIR= or =ID=: =selective=, ="t"= or ="nil"=. Mirrors =org-attach-use-inheritance=. | 217| =org-attach-use-inheritance= | string | ="selective"= | Whether attachment folders come from an ancestor's =DIR= or =ID=: =selective=, ="t"= or ="nil"=. Mirrors =org-attach-use-inheritance=. |
215| =org-crypt-tag-matcher= | string | ="crypt"= | The tag Encrypt Tagged Entries… encrypts. A single tag. See [[file:04-outlines.org][Outlines]]. Mirrors =org-crypt-tag-matcher=. | 218| =org-crypt-tag-matcher= | string | ="crypt"= | The tag Encrypt Tagged Entries… encrypts. A single tag. See [[file:04-outlines.org][Outlines]]. Mirrors =org-crypt-tag-matcher=. |
@@ -570,6 +573,7 @@ Only variables whose names start with =org-=, =appt-=, =display-line-numbers=, =
570| =org-agenda-log-mode-items= | The symbols =closed=, =clock= and =state= of the list, separated by spaces | 573| =org-agenda-log-mode-items= | The symbols =closed=, =clock= and =state= of the list, separated by spaces |
571| =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 | 574| =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 |
572| =org-track-ordered-property-with-tag= | A tag name as given; =t= becomes ="t"=, =nil= ="nil"= | 575| =org-track-ordered-property-with-tag= | A tag name as given; =t= becomes ="t"=, =nil= ="nil"= |
576| =org-timer-format=, =org-timer-default-timer= | The same keys; a number becomes a string |
573| =org-attach-id-dir= | The same key, when the value is a string or an =expand-file-name= form | 577| =org-attach-id-dir= | The same key, when the value is a string or an =expand-file-name= form |
574| =org-attach-use-inheritance= | =selective=, or =t= / =nil= as ="t"= / ="nil"= | 578| =org-attach-use-inheritance= | =selective=, or =t= / =nil= as ="t"= / ="nil"= |
575| =org-crypt-tag-matcher= | The same key, when the value is a single tag | 579| =org-crypt-tag-matcher= | The same key, when the value is a single tag |
docs/manual/guide/14-ios.org +3 −1
@@ -133,6 +133,8 @@ Cancel answers nothing, as =C-g= does.
133 133
134=C-c '= on a block, and =C-c `= on a table field, open the text in a sheet of its own; Save puts it back. A src block's code is colored as its language, as in the editor. 134=C-c '= on a block, and =C-c `= on a table field, open the text in a sheet of its own; Save puts it back. A src block's code is colored as its language, as in the editor.
135 135
136The org-timer commands are in Commands; a running timer shows above the text. See [[file:06-dates-and-clocking.org][Dates and clocking]].
137
136More ▸ Attachments has the org-attach commands and Attach Photo or Video…; files shared to orgstar can be attached to an entry. See [[file:04-outlines.org][Outlines]]. 138More ▸ Attachments has the org-attach commands and Attach Photo or Video…; files shared to orgstar can be attached to an entry. See [[file:04-outlines.org][Outlines]].
137 139
138More ▸ Encryption has the org-crypt commands; see [[file:04-outlines.org][Outlines]]. A remembered passphrase is used after Face ID, Touch ID or the device passcode. 140More ▸ Encryption has the org-crypt commands; see [[file:04-outlines.org][Outlines]]. A remembered passphrase is used after Face ID, Touch ID or the device passcode.
@@ -353,7 +355,7 @@ These settings from =config.toml= apply on iOS:
353- =[theme]= (=font=, =font-size=, =line-spacing=, =heading-size-step=, =theme-file= and colours), =[theme.light]=, =[theme.dark]=, =[theme.todo]=, =[theme.category]= 355- =[theme]= (=font=, =font-size=, =line-spacing=, =heading-size-step=, =theme-file= and colours), =[theme.light]=, =[theme.dark]=, =[theme.todo]=, =[theme.category]=
354- =org-log-done=, =org-log-reschedule=, =org-log-redeadline=, =org-log-into-drawer= 356- =org-log-done=, =org-log-reschedule=, =org-log-redeadline=, =org-log-into-drawer=
355- =org-enforce-todo-dependencies=, =org-enforce-todo-checkbox-dependencies=, =org-track-ordered-property-with-tag=, =org-agenda-dim-blocked-tasks= 357- =org-enforce-todo-dependencies=, =org-enforce-todo-checkbox-dependencies=, =org-track-ordered-property-with-tag=, =org-agenda-dim-blocked-tasks=
356- =org-crypt-tag-matcher=, =org-attach-id-dir=, =org-attach-use-inheritance= 358- =org-crypt-tag-matcher=, =org-attach-id-dir=, =org-attach-use-inheritance=, =org-timer-format=, =org-timer-default-timer=
357- =org-archive-location=, =[org-structure-template-alist]= 359- =org-archive-location=, =[org-structure-template-alist]=
358- =org-use-tag-inheritance=, =org-tags-exclude-from-inheritance=, =org-tag-alist= 360- =org-use-tag-inheritance=, =org-tags-exclude-from-inheritance=, =org-tag-alist=
359- =org-use-speed-commands=, with a hardware keyboard 361- =org-use-speed-commands=, with a hardware keyboard
docs/manual/guide/15-alongside-emacs.org +2
@@ -248,6 +248,8 @@ Other:
248- =display-line-numbers-type= has no relative or visual mode. 248- =display-line-numbers-type= has no relative or visual mode.
249- The agenda's text search (see [[file:07-agenda.org][The agenda]]) covers the agenda files only: =org-agenda-text-search-extra-files= and =org-agenda-search-view-max-outline-level= aren't supported. It runs from the view menu rather than the dispatcher's =s= and =S=, and the search view's =[=, =]=, ={= and =}= keys, which add words and regexps to the search, aren't supported. 249- The agenda's text search (see [[file:07-agenda.org][The agenda]]) covers the agenda files only: =org-agenda-text-search-extra-files= and =org-agenda-search-view-max-outline-level= aren't supported. It runs from the view menu rather than the dispatcher's =s= and =S=, and the search view's =[=, =]=, ={= and =}= keys, which add words and regexps to the search, aren't supported.
250- In regexps, =\<=, =\>= and =\b= use Org's word syntax but don't find a word boundary where the script changes between two word characters, as Emacs does (for example between an emoji and a letter). 250- In regexps, =\<=, =\>= and =\b= use Org's word syntax but don't find a word boundary where the script changes between two word characters, as Emacs does (for example between an emoji and a letter).
251- org-timer: =org-timer-display= is always the mode line. The timer's =C-u= forms are separate commands bound to =C-u C-c C-x 0=, =C-u C-u C-c C-x 0= and =C-u C-c C-x ,=; Set Countdown Timer… has no prefix-argument forms.
252- Radio lists are Org 9.8's =#+ATTR_ORG: :radio= checkbox lists. The =#+ORGLST= radio lists of Org 9.1 and earlier, removed in Org 9.2, aren't supported, nor is =org-list-checkbox-radio-mode=.
251- org-attach: =org-attach-method= is always =cp= for Attach File… (the other methods have their own commands), =org-attach-auto-tag= is always =ATTACH=, =org-attach-preferred-new-method= is always =id=, and =org-attach-id-to-path-function-list= is Org's default. The dispatcher's =b=, =O= and =F= keys and =org-attach-archive-delete= aren't supported. Delete All Attachments… asks once and deletes the folder with what's in it. 253- org-attach: =org-attach-method= is always =cp= for Attach File… (the other methods have their own commands), =org-attach-auto-tag= is always =ATTACH=, =org-attach-preferred-new-method= is always =id=, and =org-attach-id-to-path-function-list= is Org's default. The dispatcher's =b=, =O= and =F= keys and =org-attach-archive-delete= aren't supported. Delete All Attachments… asks once and deletes the folder with what's in it.
252- org-crypt works with symmetric encryption only (=org-crypt-key= nil); public keys and =org-crypt-use-before-save-magic= aren't supported. =org-crypt-tag-matcher= is a single tag. 254- org-crypt works with symmetric encryption only (=org-crypt-key= nil); public keys and =org-crypt-use-before-save-magic= aren't supported. =org-crypt-tag-matcher= is a single tag.
253- =org-track-ordered-property-with-tag= isn't supported; Toggle ORDERED Property sets only the property. 255- =org-track-ordered-property-with-tag= isn't supported; Toggle ORDERED Property sets only the property.