Clocks: org-clock-into-drawer and CLOCK_INTO_DRAWER !255
11 files changed, +156 −30
Layout: unified · split
Sources/OrgApp/EmacsImport.swift +2
| @@ -543,6 +543,8 @@ public struct EmacsImport: Sendable { | ||
| 543 | 543 | case "org-clock-idle-time": |
| 544 | 544 | // nil is never; a number is minutes. |
| 545 | 545 | if value.symbol == "nil" { add(name, .integer(0)) } else if let minutes = value.integer, minutes > 0 { add(name, .integer(minutes)) } else { note("not a number of minutes") } |
| 546 | case "org-clock-into-drawer": | |
| 547 | if let drawer = value.string { add(name, .string(drawer)) } else if let n = value.integer { add(name, .string("\(n)")) } else { add(name, .string(truthy ? "t" : "nil")) } | |
| 546 | 548 | case "org-clock-history-length": |
| 547 | 549 | guard let length = value.integer, length > 0 else { return note("not a positive number") } |
| 548 | 550 | add(name, .integer(length)) |
Sources/OrgApp/OrgPreferences.swift +1
| @@ -36,6 +36,7 @@ public enum OrgPreferences { | ||
| 36 | 36 | options.enforceTodoDependencies = bool("enforceTodoDependencies", defaults) |
| 37 | 37 | options.enforceTodoCheckboxDependencies = bool("enforceTodoCheckboxDependencies", defaults) |
| 38 | 38 | options.archiveLocation = string("archiveLocation", defaults).nonEmpty |
| 39 | options.clockIntoDrawer = string("clockIntoDrawer", defaults).nonEmpty | |
| 39 | 40 | let templates = UserConfig.structureTemplates(defaults) |
| 40 | 41 | options.structureTemplates = templates.isEmpty ? nil : StructureTemplate.merged(templates) |
| 41 | 42 | options.trackOrderedPropertyWithTag = switch string("trackOrderedTag", defaults) { |
Sources/OrgApp/UserConfig.swift +2
| @@ -185,6 +185,8 @@ public enum UserConfig { | ||
| 185 | 185 | comment: "minutes of warning before timed entries; APPT_WARNTIME overrides", legacy: "agenda.reminder-lead"), |
| 186 | 186 | Setting(section: "", key: "org-clock-idle-time", defaultsKey: "clockIdleTime", kind: .integer, fallback: .integer(0), |
| 187 | 187 | comment: "minutes idle with a clock running before asking what to do with the time; 0 never (nil)", legacy: ""), |
| 188 | Setting(section: "", key: "org-clock-into-drawer", defaultsKey: "clockIntoDrawer", kind: .string, fallback: .string("t"), | |
| 189 | comment: "t: clock lines go in the log drawer (LOGBOOK); nil: none; a number: once there are that many; or a drawer name", legacy: ""), | |
| 188 | 190 | Setting(section: "", key: "org-clock-history-length", defaultsKey: "clockHistoryLength", kind: .integer, fallback: .integer(5), |
| 189 | 191 | comment: "recently clocked entries to remember", legacy: ""), |
| 190 | 192 | Setting(section: "org-agenda-prefix-format", key: "agenda", defaultsKey: "agendaPrefixAgenda", kind: .string, fallback: .string(PrefixFormat.defaults["agenda"]!), |
Sources/OrgCore/Commands/Clock.swift +72 −16
| @@ -1,11 +1,46 @@ | ||
| 1 | 1 | import Foundation |
| 2 | 2 | |
| 3 | // Clocking (org-clock.el, Org 9.8.7) with `org-clock-into-drawer` t (a LOGBOOK drawer), | |
| 4 | // `org-log-states-order-reversed` t (newest first), no rounding, no resume, and zero-time | |
| 5 | // clocks kept. | |
| 3 | // Clocking (org-clock.el, Org 9.8.7) with `org-clock-into-drawer` and the CLOCK_INTO_DRAWER | |
| 4 | // property, `org-log-states-order-reversed` t (newest first), no rounding, no resume, and | |
| 5 | // zero-time clocks kept. | |
| 6 | 6 | |
| 7 | 7 | extension EmacsBuffer { |
| 8 | static let clockDrawer = "LOGBOOK" | |
| 8 | /// What `org-clock-into-drawer` comes to for an entry. | |
| 9 | enum ClockDrawer: Equatable { | |
| 10 | case none | |
| 11 | /// Into the drawer once there are this many clock lines. | |
| 12 | case count(Int) | |
| 13 | case named(String) | |
| 14 | } | |
| 15 | ||
| 16 | /// `org-log-into-drawer` for the entry: the setting, `#+STARTUP: logdrawer` and the | |
| 17 | /// LOG_INTO_DRAWER property. | |
| 18 | func logIntoDrawer() -> String? { logSettings().drawer } | |
| 19 | ||
| 20 | /// `org-clock-into-drawer` (the function): the entry's CLOCK_INTO_DRAWER over the setting. | |
| 21 | func clockIntoDrawer() -> ClockDrawer { | |
| 22 | func read(_ value: String) -> ClockDrawer? { | |
| 23 | switch value.trimmingCharacters(in: .whitespaces) { | |
| 24 | case "nil": return ClockDrawer.none | |
| 25 | case "t": return .named(logIntoDrawer() ?? "LOGBOOK") | |
| 26 | case "": return nil | |
| 27 | case let text where text.allSatisfy(\.isASCII) && text.allSatisfy(\.isNumber): return .count(Int(text) ?? 0) | |
| 28 | case let name: return .named(name) | |
| 29 | } | |
| 30 | } | |
| 31 | if let property = inheritedProperty("CLOCK_INTO_DRAWER")?.value, let value = read(property) { return value } | |
| 32 | return options.clockIntoDrawer.flatMap(read) ?? .named(logIntoDrawer() ?? "LOGBOOK") | |
| 33 | } | |
| 34 | ||
| 35 | /// `org-clock-drawer-name`. | |
| 36 | func clockDrawerName() -> String? { | |
| 37 | switch clockIntoDrawer() { | |
| 38 | case .none: nil | |
| 39 | case .count: logIntoDrawer() ?? "LOGBOOK" | |
| 40 | case .named(let name): name | |
| 41 | } | |
| 42 | } | |
| 43 | ||
| 9 | 44 | static let openClockPattern = "^[ \\t]*CLOCK: \\[([0-9]{4}-[0-9]{2}-[0-9]{2} *[^\\]\\s]+ +[012][0-9]:[0-5][0-9])\\][ \\t]*$" |
| 10 | 45 | |
| 11 | 46 | /// `org-clock-find-position` without `find-unclosed`. |
| @@ -15,13 +50,17 @@ extension EmacsBuffer { | ||
| 15 | 50 | _ = outlineNextHeading() |
| 16 | 51 | return point |
| 17 | 52 | } |
| 18 | let drawerPattern = "^[ \\t]*:" + Self.clockDrawer + ":[ \\t]*$" | |
| 19 | point = beg | |
| 20 | while let match = searchForward(drawerPattern, bound: end, caseInsensitive: false) { | |
| 21 | if element(at: lineStart(match[0]!.lowerBound))?.kind == .drawer { | |
| 22 | point = match[0]!.upperBound | |
| 23 | forwardLine(1) | |
| 24 | return | |
| 53 | let into = clockIntoDrawer() | |
| 54 | let drawer = clockDrawerName() | |
| 55 | if let drawer { | |
| 56 | let drawerPattern = "^[ \\t]*:" + NSRegularExpression.escapedPattern(for: drawer) + ":[ \\t]*$" | |
| 57 | point = beg | |
| 58 | while let match = searchForward(drawerPattern, bound: end, caseInsensitive: false) { | |
| 59 | if element(at: lineStart(match[0]!.lowerBound))?.kind == .drawer { | |
| 60 | point = match[0]!.upperBound | |
| 61 | forwardLine(1) | |
| 62 | return | |
| 63 | } | |
| 25 | 64 | } |
| 26 | 65 | } |
| 27 | 66 | point = beg |
| @@ -34,8 +73,25 @@ extension EmacsBuffer { | ||
| 34 | 73 | if positions.isEmpty { |
| 35 | 74 | endOfMetaData() |
| 36 | 75 | if !bolp { insertBeforeMarkers("\n") } |
| 37 | insertBeforeMarkers(":" + Self.clockDrawer + ":\n:END:\n") | |
| 38 | forwardLine(-1) | |
| 76 | let creates: Bool = switch into { | |
| 77 | case .none: false | |
| 78 | case .count(let n): n < 2 | |
| 79 | case .named: true | |
| 80 | } | |
| 81 | if creates, let drawer { | |
| 82 | insertBeforeMarkers(":" + drawer + ":\n:END:\n") | |
| 83 | forwardLine(-1) | |
| 84 | } | |
| 85 | return | |
| 86 | } | |
| 87 | // Without a drawer, or with fewer clocks than the setting's number, the new clock goes | |
| 88 | // first. | |
| 89 | let wraps: Bool = switch into { | |
| 90 | case .count(let n): positions.count + 1 >= n | |
| 91 | default: drawer != nil | |
| 92 | } | |
| 93 | guard wraps, let drawer else { | |
| 94 | point = positions.last! | |
| 39 | 95 | return |
| 40 | 96 | } |
| 41 | 97 | // Clocks outside a drawer move into a new one. |
| @@ -58,7 +114,7 @@ extension EmacsBuffer { | ||
| 58 | 114 | let endMarker = marker(point) |
| 59 | 115 | defer { release(endMarker) } |
| 60 | 116 | point = start |
| 61 | saveExcursion { insertBeforeMarkers(":" + Self.clockDrawer + ":\n") } | |
| 117 | saveExcursion { insertBeforeMarkers(":" + drawer + ":\n") } | |
| 62 | 118 | forwardLine(1) |
| 63 | 119 | } |
| 64 | 120 | |
| @@ -136,13 +192,13 @@ extension EmacsBuffer { | ||
| 136 | 192 | /// `org-clock-remove-empty-clock-drawer` for the subtree at point. |
| 137 | 193 | func removeEmptyClockDrawer() { |
| 138 | 194 | saveExcursion { |
| 139 | guard let heading = try? backToHeading() else { return } | |
| 195 | guard let heading = try? backToHeading(), let drawer = clockDrawerName() else { return } | |
| 140 | 196 | let end = saveExcursion { () -> Int in |
| 141 | 197 | point = heading |
| 142 | 198 | return endOfSubtree() |
| 143 | 199 | } |
| 144 | 200 | point = heading |
| 145 | let pattern = "(?i)^[ \\t]*:" + Self.clockDrawer + ":[ \\t]*$" | |
| 201 | let pattern = "(?i)^[ \\t]*:" + NSRegularExpression.escapedPattern(for: drawer) + ":[ \\t]*$" | |
| 146 | 202 | while let match = searchForward(pattern, bound: end, caseInsensitive: true) { |
| 147 | 203 | removeEmptyDrawer(at: match[0]!.upperBound) |
| 148 | 204 | } |
Sources/OrgCore/Commands/Command.swift +3
| @@ -27,6 +27,9 @@ public struct EditingOptions: Sendable, Equatable, Codable { | ||
| 27 | 27 | public var enforceTodoDependencies = false |
| 28 | 28 | /// `org-enforce-todo-checkbox-dependencies`: an entry can't become done with unchecked boxes. |
| 29 | 29 | public var enforceTodoCheckboxDependencies = false |
| 30 | /// `org-clock-into-drawer` as `config.toml` writes it: `nil`, `t`, a number of clock lines, | |
| 31 | /// or a drawer name; nil for Org's default, `t`. | |
| 32 | public var clockIntoDrawer: String? | |
| 30 | 33 | /// `org-structure-template-alist`, for C-c C-, and `<` completion; nil for Org's. |
| 31 | 34 | public var structureTemplates: [StructureTemplate]? |
| 32 | 35 | /// `org-archive-location`, for entries without an `ARCHIVE` property or `#+ARCHIVE:`; nil |
Tests/OrgAppTests/EmacsImportTests.swift +3 −2
| @@ -48,6 +48,7 @@ struct EmacsImportTests { | ||
| 48 | 48 | org-agenda-todo-ignore-scheduled 'future |
| 49 | 49 | org-agenda-todo-ignore-deadlines 7 |
| 50 | 50 | org-agenda-log-mode-items '(closed clock state) |
| 51 | org-clock-into-drawer "CLOCKS" | |
| 51 | 52 | org-agenda-start-day "-3d" |
| 52 | 53 | org-clock-idle-time 15 |
| 53 | 54 | org-clock-history-length 10 |
| @@ -93,7 +94,7 @@ struct EmacsImportTests { | ||
| 93 | 94 | #expect(s["org-agenda-start-on-weekday"] == .string("0")) |
| 94 | 95 | #expect(s["org-track-ordered-property-with-tag"] == .string("t")) |
| 95 | 96 | #expect(s["org-archive-location"] == .string("archive/%s::")) |
| 96 | #expect(s["org-agenda-log-mode-items"] == .string("closed clock state")) | |
| 97 | #expect(s["org-agenda-log-mode-items"] == .string("closed clock state") && s["org-clock-into-drawer"] == .string("CLOCKS")) | |
| 97 | 98 | #expect(s["org-agenda-todo-ignore-scheduled"] == .string("future") && s["org-agenda-todo-ignore-deadlines"] == .string("7")) |
| 98 | 99 | #expect(s["org-agenda-start-day"] == .string("-3d")) |
| 99 | 100 | #expect(s["org-clock-idle-time"] == .integer(15)) |
| @@ -186,7 +187,7 @@ struct EmacsImportTests { | ||
| 186 | 187 | let keymap = folder.appendingPathComponent("keymap.toml") |
| 187 | 188 | #expect(KeymapLoader.load(.doom, userFile: keymap).problems.isEmpty) |
| 188 | 189 | #expect(KeymapLoader.load(.doom, userFile: keymap).keymap.keyLabels(for: "app.agenda", modes: ["normal"]).contains("C-c a")) |
| 189 | #expect(summary.hasPrefix("Imported 26 settings, 3 capture templates, 3 key bindings, 2 structure templates."), "\(summary)") | |
| 190 | #expect(summary.hasPrefix("Imported 27 settings, 3 capture templates, 3 key bindings, 2 structure templates."), "\(summary)") | |
| 190 | 191 | #expect(UserConfig.structureTemplates(defaults) == [.init(key: "el", type: "src emacs-lisp"), .init(key: "q", type: "QUOTE")]) |
| 191 | 192 | #expect(OrgPreferences.options(defaults).structureTemplates?.first { $0.key == "q" }?.type == "QUOTE") |
| 192 | 193 | #expect(defaults.string(forKey: "themeFont") == "JetBrains Mono") |
Tests/OrgAppTests/OrgPreferencesTests.swift +2 −1
| @@ -35,6 +35,7 @@ struct OrgPreferencesTests { | ||
| 35 | 35 | org-agenda-todo-ignore-deadlines = "t" |
| 36 | 36 | org-agenda-todo-ignore-scheduled = "-2" |
| 37 | 37 | org-agenda-log-mode-items = "closed state" |
| 38 | org-clock-into-drawer = "3" | |
| 38 | 39 | org-M-RET-may-split-line = true |
| 39 | 40 | org-hide-emphasis-markers = false |
| 40 | 41 | org-pretty-entities = false |
| @@ -52,7 +53,7 @@ struct OrgPreferencesTests { | ||
| 52 | 53 | #expect(OrgPreferences.options(defaults).trackOrderedPropertyWithTag == "ORDERED") |
| 53 | 54 | #expect(OrgPreferences.options(defaults).archiveLocation == "~/org/archive.org::* %s") |
| 54 | 55 | let ignoring = OrgPreferences.agendaOptions(AgendaOptions(), defaults) |
| 55 | #expect(ignoring.logItems == ["closed", "state"]) | |
| 56 | #expect(ignoring.logItems == ["closed", "state"] && OrgPreferences.options(defaults).clockIntoDrawer == "3") | |
| 56 | 57 | #expect(ignoring.todoIgnoreDeadlines == .near && ignoring.todoIgnoreScheduled == .days(-2) && ignoring.todoIgnoreTimestamp == .off) |
| 57 | 58 | #expect(OrgPreferences.agendaOptions(AgendaOptions(), defaults).deadlineWarningDays == 5) |
| 58 | 59 | #expect(!OrgPreferences.reminders(defaults) && OrgPreferences.reminderLead(defaults) == 30) |
Tests/OrgCoreTests/ClockTests.swift +52 −7
| @@ -21,8 +21,8 @@ struct ClockTests { | ||
| 21 | 21 | return c |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | func run(_ command: any OrgCommand, _ text: String, caret: Int, at seconds: Int) -> (text: String, caret: Int, failure: String?) { | |
| 25 | let context = EditContext(revision: 0, text: text, tree: OrgParser.parse(text), selection: [caret..<caret], now: Date(timeIntervalSince1970: Double(seconds)), calendar: Self.utc) | |
| 24 | func run(_ command: any OrgCommand, _ text: String, caret: Int, at seconds: Int, options: EditingOptions = .org) -> (text: String, caret: Int, failure: String?) { | |
| 25 | let context = EditContext(revision: 0, text: text, tree: OrgParser.parse(text), selection: [caret..<caret], now: Date(timeIntervalSince1970: Double(seconds)), calendar: Self.utc, options: options) | |
| 26 | 26 | switch command.run(in: context) { |
| 27 | 27 | case .commit(let result): |
| 28 | 28 | var new = text |
| @@ -35,27 +35,50 @@ struct ClockTests { | ||
| 35 | 35 | |
| 36 | 36 | @Test(.enabled(if: ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil)) |
| 37 | 37 | func matchesEmacs() throws { |
| 38 | try compare(Self.texts) | |
| 39 | } | |
| 40 | ||
| 41 | /// `org-clock-into-drawer` values, `org-log-into-drawer`, and the CLOCK_INTO_DRAWER and | |
| 42 | /// LOG_INTO_DRAWER properties. | |
| 43 | @Test(.enabled(if: ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil)) | |
| 44 | func intoDrawerMatchesEmacs() throws { | |
| 45 | let texts = Self.texts + [ | |
| 46 | "* Task\nCLOCK: [2026-10-03 Sat 09:00]--[2026-10-03 Sat 10:00] => 1:00\nCLOCK: [2026-10-04 Sun 09:00]--[2026-10-04 Sun 10:00] => 1:00\n", | |
| 47 | "* Task\n:PROPERTIES:\n:CLOCK_INTO_DRAWER: nil\n:END:\nBody\n", | |
| 48 | "* Parent\n:PROPERTIES:\n:CLOCK_INTO_DRAWER: TIMES\n:END:\n** Task\nBody\n", | |
| 49 | "* Task\n:PROPERTIES:\n:CLOCK_INTO_DRAWER: 2\n:END:\nCLOCK: [2026-10-04 Sun 09:00]--[2026-10-04 Sun 10:00] => 1:00\n", | |
| 50 | "* Task\n:PROPERTIES:\n:CLOCK_INTO_DRAWER: t\n:LOG_INTO_DRAWER: NOTES\n:END:\n", | |
| 51 | ] | |
| 52 | for (lisp, value, log) in [("nil", "nil", nil), ("2", "2", nil), ("3", "3", nil), ("\"CLOCKS\"", "CLOCKS", nil), ("t", nil, "NOTES"), ("2", "2", "NOTES")] as [(String, String?, String?)] { | |
| 53 | var options = EditingOptions.org | |
| 54 | options.clockIntoDrawer = value | |
| 55 | options.logIntoDrawer = log | |
| 56 | try compare(texts, lisp: lisp, log: log.map { "\"\($0)\"" } ?? "nil", options: options) | |
| 57 | } | |
| 58 | } | |
| 59 | ||
| 60 | func compare(_ texts: [String], lisp: String = "t", log: String = "nil", options: EditingOptions = .org) throws { | |
| 38 | 61 | let t1 = 1_789_000_000 // Thu 2026-09-10 00:26 |
| 39 | 62 | let t2 = t1 + 3 * 3600 + 17 * 60 + 42 |
| 40 | 63 | var cases: [EmacsOracle.Case] = [] |
| 41 | 64 | var ours: [(String, String)] = [] |
| 42 | for text in Self.texts { | |
| 65 | for text in texts { | |
| 43 | 66 | let caret = (text as NSString).range(of: "Task").location |
| 44 | 67 | for mode in ["out", "cancel"] { |
| 45 | 68 | // Clock in at t1, then out (or cancel) at t2. |
| 46 | let first = run(ClockIn(), text, caret: caret, at: t1) | |
| 69 | let first = run(ClockIn(), text, caret: caret, at: t1, options: options) | |
| 47 | 70 | guard let start = ClockIn.runningStart(in: first.text, near: caret) else { |
| 48 | 71 | ours.append(("no running clock: \(first.failure ?? "")", text)) |
| 49 | 72 | cases.append(EmacsOracle.Case(text: text, point: 1, form: "nil")) |
| 50 | 73 | continue |
| 51 | 74 | } |
| 52 | let second = run(ClockOut(start: start, cancel: mode == "cancel"), first.text, caret: first.caret, at: t2) | |
| 75 | let second = run(ClockOut(start: start, cancel: mode == "cancel"), first.text, caret: first.caret, at: t2, options: options) | |
| 53 | 76 | ours.append((second.text, first.text)) |
| 54 | 77 | let out = mode == "cancel" ? "(org-clock-cancel)" : "(org-clock-out)" |
| 55 | 78 | cases.append(EmacsOracle.Case(text: text, point: EmacsOracle.point(caret, in: text), form: """ |
| 56 | 79 | (progn |
| 57 | 80 | (require 'org-clock) |
| 58 | (setq org-clock-persist nil org-clock-idle-time nil org-clock-auto-clock-resolution nil org-clock-into-drawer t) | |
| 81 | (setq org-clock-persist nil org-clock-idle-time nil org-clock-auto-clock-resolution nil org-clock-into-drawer \(lisp) org-log-into-drawer \(log)) | |
| 59 | 82 | \(frozenClock(t1, "(org-clock-in)")) |
| 60 | 83 | (setq orgstar-after-in (buffer-substring-no-properties (point-min) (point-max))) |
| 61 | 84 | \(frozenClock(t2, out))) |
| @@ -64,7 +87,7 @@ struct ClockTests { | ||
| 64 | 87 | } |
| 65 | 88 | let emacs = try EmacsOracle.run(cases) |
| 66 | 89 | for (i, (mine, theirs)) in zip(ours, emacs).enumerated() { |
| 67 | #expect(mine.0 == theirs.text, "case \(i) \(cases[i].form.contains("cancel") ? "cancel" : "out")\n\(cases[i].text.debugDescription)\nafter in (ours): \(mine.1.debugDescription)\nours: \(mine.0.debugDescription)\nemacs: \(theirs.text.debugDescription) \(theirs.error)") | |
| 90 | #expect(mine.0 == theirs.text, "case \(i) \(lisp) \(cases[i].form.contains("cancel") ? "cancel" : "out")\n\(cases[i].text.debugDescription)\nafter in (ours): \(mine.1.debugDescription)\nours: \(mine.0.debugDescription)\nemacs: \(theirs.text.debugDescription) \(theirs.error)") | |
| 68 | 91 | } |
| 69 | 92 | } |
| 70 | 93 | } |
| @@ -139,3 +162,25 @@ struct ClockReportTests { | ||
| 139 | 162 | } |
| 140 | 163 | } |
| 141 | 164 | } |
| 165 | ||
| 166 | struct ClockDrawerStartupTests { | |
| 167 | @Test(.enabled(if: ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil)) | |
| 168 | func startupLogdrawerMatchesEmacs() throws { | |
| 169 | let text = "#+STARTUP: nologdrawer\n* Task\nBody\n" | |
| 170 | let caret = (text as NSString).range(of: "Task").location | |
| 171 | let t1 = 1_789_000_000 | |
| 172 | var options = EditingOptions.org | |
| 173 | options.logIntoDrawer = "NOTES" | |
| 174 | let context = EditContext(revision: 0, text: text, tree: OrgParser.parse(text), selection: [caret..<caret], now: Date(timeIntervalSince1970: Double(t1)), calendar: ClockTests.utc, options: options) | |
| 175 | guard case .commit(let result) = ClockIn().run(in: context) else { Issue.record("no commit"); return } | |
| 176 | let ours = result.edits.sorted { $0.range.lowerBound > $1.range.lowerBound }.reduce(text) { $1.apply(to: $0) } | |
| 177 | let emacs = try EmacsOracle.run([EmacsOracle.Case(text: text, point: EmacsOracle.point(caret, in: text), form: """ | |
| 178 | (progn (require 'org-clock) | |
| 179 | (setq org-clock-persist nil org-clock-idle-time nil org-clock-auto-clock-resolution nil org-clock-into-drawer t) | |
| 180 | (setq-default org-log-into-drawer "NOTES") | |
| 181 | (org-mode) | |
| 182 | \(frozenClock(t1, "(org-clock-in)"))) | |
| 183 | """)]) | |
| 184 | #expect(ours == emacs[0].text, "ours: \(ours.debugDescription)\nemacs: \(emacs[0].text.debugDescription) \(emacs[0].error)") | |
| 185 | } | |
| 186 | } | |
docs/manual/guide/06-dates-and-clocking.org +15 −3
| @@ -226,7 +226,7 @@ orgstar has no =C-u= forms of these commands. Clock In to Recent Entry… and Go | ||
| 226 | 226 | |
| 227 | 227 | ** Clocking in and out |
| 228 | 228 | |
| 229 | Clock In starts a clock on the heading at the caret and inserts a line at the top of its =LOGBOOK= drawer, creating the drawer after the planning line and property drawer if needed: | |
| 229 | Clock In starts a clock on the heading at the caret and inserts a line at the top of its =LOGBOOK= drawer, creating the drawer after the planning line and property drawer if needed (see "The clock drawer" below for other drawers): | |
| 230 | 230 | |
| 231 | 231 | #+BEGIN_SRC org |
| 232 | 232 | ,* TODO Write the report |
| @@ -250,8 +250,20 @@ orgstar remembers the running clock and the clock history across restarts, in =c | ||
| 250 | 250 | These parts of Org's clocking are not implemented: |
| 251 | 251 | |
| 252 | 252 | - sharing the running clock with Emacs: orgstar does not read or write Emacs's =org-clock-persist= file, so a clock started in one is not known to the other, although both see the open =CLOCK:= line; |
| 253 | - rounding, changing the TODO state on clock-in (=org-clock-in-switch-to-state=), and clocking out when the entry is marked done (=org-clock-out-when-done=): the clock keeps running; | |
| 254 | - a =CLOCK_INTO_DRAWER= property or another drawer name: clocks always go into =LOGBOOK=. | |
| 253 | - rounding, changing the TODO state on clock-in (=org-clock-in-switch-to-state=), and clocking out when the entry is marked done (=org-clock-out-when-done=): the clock keeps running. | |
| 254 | ||
| 255 | ** The clock drawer | |
| 256 | ||
| 257 | Where clock lines go follows =org-clock-into-drawer= in =config.toml=, or an entry's =CLOCK_INTO_DRAWER= property, which its subtree inherits: | |
| 258 | ||
| 259 | | Value | Clock lines go | | |
| 260 | |----------------+-----------------------------------------------------------------------------------------------------| | |
| 261 | | =t= (default) | into the drawer =org-log-into-drawer= (or a =LOG_INTO_DRAWER= property) names, else =LOGBOOK= | | |
| 262 | | =nil= | under the heading, newest first, without a drawer | | |
| 263 | | a number /n/ | under the heading until there would be /n/ of them; then all of them move into the log drawer | | |
| 264 | | a drawer name | into that drawer | | |
| 265 | ||
| 266 | An existing drawer of that name always takes the new line. | |
| 255 | 267 | |
| 256 | 268 | ** The running clock |
| 257 | 269 | |
docs/manual/guide/13-configuration.org +3
| @@ -162,6 +162,7 @@ These settings have no control in the Settings window. Some are in the View menu | ||
| 162 | 162 | | =org-agenda-skip-scheduled-if-done= | | |
| 163 | 163 | | =org-agenda-skip-deadline-if-done= | | |
| 164 | 164 | | =org-agenda-log-mode-items= | | |
| 165 | | =org-clock-into-drawer= | | | |
| 165 | 166 | | =org-agenda-todo-ignore-with-date=, =org-agenda-todo-ignore-scheduled=, =org-agenda-todo-ignore-deadlines=, =org-agenda-todo-ignore-timestamp=, =org-agenda-tags-todo-honor-ignore-options= | | |
| 166 | 167 | | =org-agenda-search-view-always-boolean= | | |
| 167 | 168 | | =org-agenda-search-view-force-full-words= | | |
| @@ -223,6 +224,7 @@ A key you remove from the file goes back to its default. A key that isn't in the | ||
| 223 | 224 | | =org-agenda-dim-blocked-tasks= | string | ="t"= | =t= dims entries the two enforce settings block, =invisible= hides them (entries blocked only by checkboxes are still dimmed), =nil= shows them as usual. Mirrors =org-agenda-dim-blocked-tasks=. | |
| 224 | 225 | | =appt-message-warning-time= | integer | =12= | Minutes of warning before timed entries. An entry's =APPT_WARNTIME= property overrides it. Mirrors =appt-message-warning-time=. | |
| 225 | 226 | | =org-clock-idle-time= | integer | =0= | Minutes without keyboard or mouse input, with a clock running, before orgstar asks what to do with the idle time. =0= never asks (Emacs's =nil=). Mac only. Mirrors =org-clock-idle-time=. | |
| 227 | | =org-clock-into-drawer= | string | ="t"= | Where clock lines go: ="t"= the log drawer (=LOGBOOK=), ="nil"= no drawer, ="N"= a drawer once there are N clock lines, or a drawer's name. An entry's =CLOCK_INTO_DRAWER= property overrides it. Mirrors =org-clock-into-drawer=. | | |
| 226 | 228 | | =org-clock-history-length= | integer | =5= | How many recently clocked entries orgstar remembers. Mirrors =org-clock-history-length=. | |
| 227 | 229 | |
| 228 | 230 | The default =org-todo-keywords= is the first sequence of Doom Emacs's default: |
| @@ -471,6 +473,7 @@ Only variables whose names start with =org-=, =appt-=, =display-line-numbers=, = | ||
| 471 | 473 | | =org-agenda-span= | A number, or =day= (1), =week= (7), =fortnight= (14), =month= (30), =year= (365) | |
| 472 | 474 | | =org-clock-idle-time= | Minutes; =nil= becomes =0= (never) | |
| 473 | 475 | | =org-clock-history-length= | The same key, when the value is a positive number | |
| 476 | | =org-clock-into-drawer= | A drawer name as given, a number as a string, =t= or =nil= | | |
| 474 | 477 | | =org-agenda-start-day= | A day offset such as ="-3d"=; =nil= becomes ="+0d"=. Other forms aren't supported. | |
| 475 | 478 | | =org-agenda-start-on-weekday= | ="0"= to ="6"=, or ="nil"= | |
| 476 | 479 | | =org-agenda-log-mode-items= | The symbols =closed=, =clock= and =state= of the list, separated by spaces | |
docs/manual/guide/14-ios.org +1 −1
| @@ -354,7 +354,7 @@ These settings from =config.toml= apply on iOS: | ||
| 354 | 354 | - =org-agenda-span=, =org-agenda-start-day=, =org-agenda-start-on-weekday=, =org-deadline-warning-days=, =agenda-include-subfolders=, =org-agenda-show-all-dates=, =org-agenda-skip-scheduled-if-done=, =org-agenda-skip-deadline-if-done=, =org-agenda-search-view-always-boolean=, =org-agenda-search-view-force-full-words=, =org-agenda-log-mode-items=, the =org-agenda-todo-ignore-= settings, =org-agenda-tags-todo-honor-ignore-options= |
| 355 | 355 | - =calendar-events=, =calendar-event-calendars= |
| 356 | 356 | - =reminders=, =appt-message-warning-time= |
| 357 | - =org-clock-history-length= | |
| 357 | - =org-clock-history-length=, =org-clock-into-drawer= | |
| 358 | 358 | |
| 359 | 359 | =capture.toml= and =views.toml= in the folder apply too. Other settings, including =keymap=, =save= and =org-clock-idle-time=, don't apply on iOS. See [[file:13-configuration.org][Configuration]]. |
| 360 | 360 | |