iOS: archive, publishing, calendars, rich text, idle time, agenda import !421

merged merged by cmc on 2026-11-21 14:08 UTC · krz/orgstar:parity-ios into main

26 files changed, +684 −62

Layout: unified · split

Sources/OrgApp/AppStoreCommands.swift +7 −1
@@ -1,7 +1,8 @@
11import Foundation
22
33/// The commands the Mac App Store build leaves out of the palette and menus: exports that run
4/// Emacs, and attaching by link, which the sandbox doesn't allow.
4/// Emacs, and attaching by link, which the sandbox doesn't allow. The iOS app refuses those
5/// with nothing in their place too.
56public enum AppStoreCommands {
67 public static let hidden: Set<String> = [
78 "app.export.pdf",
@@ -12,4 +13,9 @@ public enum AppStoreCommands {
1213 public static func replacement(for id: String) -> String? {
1314 id == "app.export.pdf" ? "app.export.print-pdf" : nil
1415 }
16
17 /// A hidden command with nothing in its place.
18 public static func unavailable(_ id: String) -> Bool {
19 hidden.contains(id) && replacement(for: id) == nil
20 }
1521}
Sources/OrgApp/ClockModel.swift +23
@@ -567,6 +567,29 @@ public final class ClockModel {
567567 )
568568 }
569569
570 /// When every window of the app went to the background, for `cameBack`.
571 @ObservationIgnored private var awayAt: Date?
572
573 /// iOS: the app, all its windows, went to the background at `now`.
574 public func wentAway(at now: Date = Date()) { awayAt = now }
575
576 /// iOS: a window became active. Since when the user was idle, the first time after the
577 /// whole app was away; nil when a window came back while another was in use.
578 public func cameBack(now: Date = Date(), idleMinutes: Int) -> Date? {
579 defer { awayAt = nil }
580 guard let awayAt else { return nil }
581 return Self.idleSince(backgrounded: awayAt, now: now, running: running, idleMinutes: idleMinutes)
582 }
583
584 /// Where iOS has no idle time: since when the user was away, for `resolveIdle`, when the
585 /// app was in the background from `backgrounded` to `now` with `running` going for more
586 /// than `idleMinutes` of that time (`org-clock-idle-time`, 0 for never).
587 public nonisolated static func idleSince(backgrounded: Date, now: Date, running: Running?, idleMinutes: Int) -> Date? {
588 guard idleMinutes > 0, let running else { return nil }
589 let since = max(backgrounded, running.startedAt)
590 return now.timeIntervalSince(since) > Double(idleMinutes * 60) ? since : nil
591 }
592
570593 /// `org-clock-resolve`: asks what to do with `clock`'s time since `lastValid` and does it.
571594 func resolve(
572595 _ clock: OpenClock, description: String, lastValid: Date, clockingIn: Bool, _ session: DocumentSession, ask: Ask, now: () -> Date
Sources/OrgApp/EmacsImport.swift +47 −3
@@ -762,7 +762,8 @@ public struct EmacsImport: Sendable {
762762 add(name, .string(paths.joined(separator: "\n")))
763763 // A file listing the files (the variable's string form) gives no folder.
764764 if value.string != nil, !paths[0].hasSuffix(".org") { return }
765 for path in paths {
765 // A relative entry counts from org-directory, so it has no folder of its own.
766 for path in paths where OrgPaths.expandingTilde(path).hasPrefix("/") {
766767 let folder = path.hasSuffix(".org") ? (path as NSString).deletingLastPathComponent : path
767768 items.append(Item(id: id(), name: name, summary: "add folder \(folder)", source: source, change: .folder(folder)))
768769 }
@@ -1095,6 +1096,36 @@ extension EmacsImport {
10951096 }
10961097 }
10971098
1099 /// `org-agenda-files` (one path a line) with each path below a folder in `chosenFolders` moved
1100 /// to the folder chosen for it. Relative paths are kept as written; they count from the first
1101 /// folder, standing in for `org-directory`. Other paths with no chosen folder that don't exist
1102 /// here are left out; nil when none remain. With `keepingOriginals`, for a config.toml the Mac reads too,
1103 /// the Mac's paths are all kept, a moved one beside its new path; each device skips the paths
1104 /// it doesn't have.
1105 static func agendaFiles(_ list: String, chosenFolders: [String: URL], keepingOriginals: Bool = false) -> String? {
1106 func standard(_ path: String) -> String { URL(fileURLWithPath: OrgPaths.expandingTilde(path)).standardizedFileURL.path }
1107 let folders = chosenFolders.map { (standard($0.key), $0.value.standardizedFileURL.path) }.sorted { $0.0.count > $1.0.count }
1108 var here: [String] = [], all: [String] = []
1109 for path in list.split(separator: "\n").map(String.init) {
1110 guard OrgPaths.expandingTilde(path).hasPrefix("/") else {
1111 here.append(path)
1112 all.append(path)
1113 continue
1114 }
1115 let full = standard(path)
1116 if let (mac, device) = folders.first(where: { full == $0.0 || full.hasPrefix($0.0 + "/") }) {
1117 let moved = device + full.dropFirst(mac.count)
1118 here.append(moved)
1119 all += moved == full ? [path] : [path, moved]
1120 } else {
1121 if FileManager.default.fileExists(atPath: full) { here.append(path) }
1122 all.append(path)
1123 }
1124 }
1125 guard !here.isEmpty else { return nil }
1126 return (keepingOriginals ? all : here).joined(separator: "\n")
1127 }
1128
10981129 @MainActor
10991130 static func isRoot(_ url: URL, in workspace: WorkspaceModel) -> Bool {
11001131 workspace.roots.contains { URL(fileURLWithPath: $0.path).standardizedFileURL.path == url.path }
@@ -1108,6 +1139,7 @@ extension EmacsImport {
11081139 /// With `writeConfig`, settings and structure templates are written into `config.toml` too,
11091140 /// for where nothing syncs user defaults into it (iOS). With `chosenFolders`, folders chosen in
11101141 /// open panels by the path of their item, a folder item is added only as the folder chosen for it.
1142 /// `org-agenda-files` paths below a chosen folder are moved into it; see `agendaFiles`.
11111143 public static func apply(
11121144 _ items: [Item], defaults: UserDefaults = .standard, workspace: WorkspaceModel?, directory: URL = UserConfig.directory,
11131145 writeConfig: Bool = false, chosenFolders: [String: URL]? = nil
@@ -1116,8 +1148,15 @@ extension EmacsImport {
11161148 var settings = 0, folders = 0, templates = 0, bindings = 0, blocks = 0, views = 0, projects = 0
11171149 var problems: [String] = []
11181150 for item in items {
1119 guard case .setting(let key, let value) = item.change,
1151 guard case .setting(let key, var value) = item.change,
11201152 let setting = UserConfig.settings.first(where: { $0.path == key || $0.key == key }) else { continue }
1153 if key == "org-agenda-files", let chosenFolders {
1154 guard let paths = Self.agendaFiles(value.string ?? "", chosenFolders: chosenFolders, keepingOriginals: writeConfig) else {
1155 problems.append("org-agenda-files wasn't set: no folder was chosen for its files")
1156 continue
1157 }
1158 value = .string(paths)
1159 }
11211160 if let problem = UserConfig.store(value, setting, in: defaults) {
11221161 problems.append(problem)
11231162 } else {
@@ -1128,6 +1167,7 @@ extension EmacsImport {
11281167 for item in items {
11291168 guard case .folder(let path) = item.change else { continue }
11301169 var url = URL(fileURLWithPath: OrgPaths.expandingTilde(path)).standardizedFileURL
1170 var picked: URL?
11311171 if let chosenFolders {
11321172 if let workspace, Self.isRoot(url, in: workspace) { continue }
11331173 guard let chosen = chosenFolders[path] else {
@@ -1135,14 +1175,18 @@ extension EmacsImport {
11351175 continue
11361176 }
11371177 url = chosen.standardizedFileURL
1178 picked = chosen
11381179 }
1180 // A folder from a picker is security-scoped; the root's bookmark keeps its own access.
1181 let accessing = picked?.startAccessingSecurityScopedResource() ?? false
1182 defer { if accessing { picked?.stopAccessingSecurityScopedResource() } }
11391183 guard let workspace, FileManager.default.fileExists(atPath: url.path) else {
11401184 problems.append("\(path) doesn't exist")
11411185 continue
11421186 }
11431187 if Self.isRoot(url, in: workspace) { continue }
11441188 do {
1145 try await workspace.addRoot(url)
1189 try await workspace.addRoot(picked ?? url)
11461190 folders += 1
11471191 } catch {
11481192 problems.append("Can't add \(path): \(error.localizedDescription)")
Sources/OrgApp/FolderGrants.swift +3 −1
@@ -13,7 +13,9 @@ public enum SecurityBookmark {
1313 var stale = false
1414 guard let url = try? URL(resolvingBookmarkData: data, options: Sandbox.bookmarkResolutionOptions(sandboxed: sandboxed), bookmarkDataIsStale: &stale) else { return nil }
1515 _ = url.startAccessingSecurityScopedResource()
16 return (url, stale ? make(url, sandboxed: sandboxed) : nil)
16 // Not `make`, which would start access a second time.
17 let renewed = stale ? try? url.bookmarkData(options: Sandbox.bookmarkCreationOptions(sandboxed: sandboxed), includingResourceValuesForKeys: nil, relativeTo: nil) : nil
18 return (url, renewed)
1719 }
1820}
1921
Sources/OrgApp/HTMLPreview.swift added +15
@@ -0,0 +1,15 @@
1import Foundation
2
3/// Export to HTML and Open where the page is shown from a temporary file (iOS, in Quick Look):
4/// the images go in the page, as nothing is beside it there.
5public enum HTMLPreview {
6 /// Writes `html` (an `HTMLExport.page`) as `name` in a new temporary folder. `directory` is
7 /// the Org file's folder, where relative image links are read from.
8 public static func write(_ html: String, directory: URL?, name: String) throws -> URL {
9 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-html-\(UUID().uuidString)")
10 try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true)
11 let url = folder.appendingPathComponent(name)
12 try PDFExport.inliningImages(html, directory: directory).write(to: url, atomically: true, encoding: .utf8)
13 return url
14 }
15}
Sources/OrgApp/Publish.swift +35 −5
@@ -252,9 +252,10 @@ public enum Publish {
252252
253253 /// `org-publish-projects`: each project's sitemap, when it has one, then its files, through
254254 /// its publishing functions. A file whose output is newer than it is skipped unless `force`.
255 /// `export` turns an Org file's text into the HTML, Markdown, LaTeX or plain text to write.
255 /// `export` turns an Org file's text into the HTML, Markdown, LaTeX or plain text to write;
256 /// ODT is exported here, with `author` for a file without `#+AUTHOR:`.
256257 public static func publish(
257 _ chosen: [PublishProject], all: [PublishProject], force: Bool = false, only: String? = nil,
258 _ chosen: [PublishProject], all: [PublishProject], force: Bool = false, only: String? = nil, author: String = NSFullUserName(),
258259 read: (String) -> String?, export: (_ function: String, _ text: String, _ path: String, _ bodyOnly: Bool) throws -> String
259260 ) throws -> Report {
260261 var report = Report()
@@ -276,7 +277,7 @@ public enum Publish {
276277 continue
277278 }
278279 try fm.createDirectory(atPath: (output as NSString).deletingLastPathComponent, withIntermediateDirectories: true)
279 try write(file, to: output, function: function, bodyOnly: p.bodyOnly, read: read, export: export)
280 try write(file, to: output, function: function, bodyOnly: p.bodyOnly, author: author, read: read, export: export)
280281 report.published.append(file)
281282 }
282283 }
@@ -284,6 +285,35 @@ public enum Publish {
284285 return report
285286 }
286287
288 /// What `function` makes of `text`, the file at `path`: HTML, Markdown, LaTeX or plain text,
289 /// with `settings` and the file's setup files. The `export` of `publish` on every platform.
290 public static func export(
291 _ function: String, text: String, path: String, bodyOnly: Bool, settings: OrgSettings, codeStyle: HTMLCodeStyle?,
292 author: String = NSFullUserName(), language: String = OrgPreferences.exportLanguage()
293 ) throws -> String {
294 let settings = settings.resolvingSetupFiles(in: text, path: path, read: OrgSettings.readFile)
295 let name = (path as NSString).lastPathComponent
296 switch function {
297 case "org-md-publish-to-md":
298 return MarkdownExport.document(text, settings: settings, path: path, bodyOnly: bodyOnly)
299 case "org-latex-publish-to-latex":
300 do {
301 return try LaTeXExport.document(text, settings: settings, path: path, bodyOnly: bodyOnly, author: author, language: language, file: true)
302 } catch let error as LaTeXExport.Unsupported {
303 throw LaTeXExport.Unsupported(reason: "Can't export \(name) to LaTeX: \(error.reason)")
304 }
305 case "org-ascii-publish-to-ascii":
306 do {
307 return try ASCIIExport.document(text, settings: settings, path: path, bodyOnly: bodyOnly, author: author, language: language, file: true)
308 } catch let error as ASCIIExport.Unsupported {
309 throw ASCIIExport.Unsupported(reason: "Can't export \(name) to plain text: \(error.reason)")
310 }
311 default:
312 let base = (name as NSString).deletingPathExtension
313 return HTMLExport.page(text, fallbackTitle: base, settings: settings, path: path, bodyOnly: bodyOnly, codeStyle: codeStyle, language: language)
314 }
315 }
316
287317 /// Where `function` publishes `file` in `outputDirectory`; nil for an attachment already there.
288318 private static func outputPath(_ file: String, function: String, in outputDirectory: String, read: (String) -> String?) throws -> String? {
289319 guard function != "org-publish-attachment" else {
@@ -299,7 +329,7 @@ public enum Publish {
299329 /// Copies an attachment to `output`, or writes what `function` exports from `file`; ODT is
300330 /// exported here, with the preferences' settings.
301331 private static func write(
302 _ file: String, to output: String, function: String, bodyOnly: Bool,
332 _ file: String, to output: String, function: String, bodyOnly: Bool, author: String,
303333 read: (String) -> String?, export: (_ function: String, _ text: String, _ path: String, _ bodyOnly: Bool) throws -> String
304334 ) throws {
305335 let fm = FileManager.default
@@ -309,7 +339,7 @@ public enum Publish {
309339 } else if function == "org-odt-publish-to-odt" {
310340 let text = read(file) ?? ""
311341 let settings = OrgPreferences.orgSettings().resolvingSetupFiles(in: text, path: file, read: OrgSettings.readFile)
312 try ODTExport.document(text, settings: settings, path: file, author: NSFullUserName(), language: OrgPreferences.exportLanguage())
342 try ODTExport.document(text, settings: settings, path: file, author: author, language: OrgPreferences.exportLanguage())
313343 .write(to: URL(fileURLWithPath: output), options: .atomic)
314344 } else {
315345 try export(function, read(file) ?? "", file, bodyOnly).write(toFile: output, atomically: true, encoding: .utf8)
Sources/OrgApp/PublishFolders.swift added +62
@@ -0,0 +1,62 @@
1import Foundation
2import OrgCore
3
4/// Publishing directories chosen in a folder picker, by project name. On iOS the app can write
5/// only to folders it was given, so a project whose `publishing-directory` is outside the
6/// app's folders publishes to the folder chosen for it instead. Kept as bookmarks.
7@MainActor
8public final class PublishFolders {
9 public static let shared = PublishFolders()
10 static let key = "publishFolders"
11
12 private let defaults: UserDefaults
13 private let sandboxed: Bool
14 /// The chosen folders by project name, with access started.
15 private var folders: [String: URL] = [:]
16
17 init(defaults: UserDefaults = .standard, sandboxed: Bool = Sandbox.isActive) {
18 self.defaults = defaults
19 self.sandboxed = sandboxed
20 let saved = defaults.dictionary(forKey: Self.key) as? [String: Data] ?? [:]
21 var kept = saved
22 for (name, data) in saved {
23 guard let (url, renewed) = SecurityBookmark.resolve(data, sandboxed: sandboxed) else { continue }
24 folders[name] = url
25 if let renewed { kept[name] = renewed }
26 }
27 if kept != saved { defaults.set(kept, forKey: Self.key) }
28 }
29
30 /// The folder chosen for `project`, if any.
31 public func folder(for project: String) -> URL? { folders[project] }
32
33 /// Keeps `url`, a folder from a folder picker, as where `project` publishes; making its bookmark
34 /// starts access. False when the bookmark can't be made, so it lasts only until the app quits.
35 @discardableResult
36 public func set(_ url: URL, for project: String) -> Bool {
37 folders[project] = url
38 guard let data = SecurityBookmark.make(url, sandboxed: sandboxed) else { return false }
39 var saved = defaults.dictionary(forKey: Self.key) as? [String: Data] ?? [:]
40 saved[project] = data
41 defaults.set(saved, forKey: Self.key)
42 return true
43 }
44
45 /// `projects`, each publishing to the folder chosen for it where there is one.
46 public func applied(to projects: [PublishProject]) -> [PublishProject] {
47 projects.map { project in
48 var project = project
49 if let folder = folders[project.name] { project.publishingDirectory = folder.path }
50 return project
51 }
52 }
53
54 /// The projects among `projects` (expanded from projects of projects) that publish outside
55 /// `roots` with no folder chosen for them.
56 public func needed(_ projects: [PublishProject], all: [PublishProject], roots: [String]) throws -> [PublishProject] {
57 try Publish.expand(projects, all: all).filter { project in
58 folders[project.name] == nil
59 && !roots.contains { FolderGrants.covers(URL(fileURLWithPath: $0), URL(fileURLWithPath: project.publishingDirectory)) }
60 }
61 }
62}
Sources/OrgCore/Compute/TableFormulas.swift +12 −3
@@ -615,7 +615,7 @@ extension EmacsBuffer {
615615
616616 var result: String
617617 if mode.lisp != .none {
618 result = try evalLisp(form, duration: duration)
618 if let value = try evalLisp(form, duration: duration) { result = value } else { (result, fmt) = ("#ERROR", nil) }
619619 } else {
620620 form = form.replacingOccurrences(of: "\\[([0-9]{4}-[0-9]{2}-[0-9]{2}(?: [^\\]>\\n]*)?)\\]", with: "<$1>", options: .regularExpression)
621621 form = Self.normalizeTimestamps(form)
@@ -647,8 +647,9 @@ extension EmacsBuffer {
647647 tableSetField(result)
648648 }
649649
650 /// `(eval (eval (read form)))` for a Lisp formula; an error is `#ERROR`.
651 func evalLisp(_ form: String, duration: DurationFormat?) throws -> String {
650 /// `(eval (eval (read form)))` for a Lisp formula; an error is `#ERROR`, and a cons is nil
651 /// (`#ERROR` without the format).
652 func evalLisp(_ form: String, duration: DurationFormat?) throws -> String? {
652653 let lisp = Elisp()
653654 lisp.standardTime()
654655 Self.defineLookups(lisp)
@@ -663,6 +664,14 @@ extension EmacsBuffer {
663664 }
664665 // Emacs prints functions as `#[ARGS BODY ENV]`.
665666 if Elisp.containsClosure(value) { throw Calc.Unsupported("Lisp formula with a function value") }
667 switch value {
668 case .list([]): break
669 case .list, .dotted:
670 // Org converts a duration before checking for a cons, which signals.
671 if duration != nil { throw Calc.Unsupported("Lisp formula with a list value and a duration") }
672 return nil
673 default: break
674 }
666675 var result = Elisp.printed(value)
667676 if let duration { result = try Self.secondsToString(Elisp.stringToNumber(result), duration) }
668677 return result
Sources/Orgstar/ContentView.swift +1 −18
@@ -1004,24 +1004,7 @@ struct ContentView: View {
10041004 guard reach(involved().flatMap { [$0.baseDirectory, $0.publishingDirectory] }, directories: true) else { return }
10051005 do {
10061006 let report = try Publish.publish(chosen, all: loaded.projects, only: only, read: read) { function, text, path, bodyOnly in
1007 let settings = Preferences.orgSettings.resolvingSetupFiles(in: text, path: path, read: OrgSettings.readFile)
1008 if function == "org-md-publish-to-md" { return MarkdownExport.document(text, settings: settings, path: path, bodyOnly: bodyOnly) }
1009 if function == "org-latex-publish-to-latex" {
1010 do {
1011 return try LaTeXExport.document(text, settings: settings, path: path, bodyOnly: bodyOnly, author: NSFullUserName(), language: OrgPreferences.exportLanguage(), file: true)
1012 } catch let error as LaTeXExport.Unsupported {
1013 throw LaTeXExport.Unsupported(reason: "Can't export \((path as NSString).lastPathComponent) to LaTeX: \(error.reason)")
1014 }
1015 }
1016 if function == "org-ascii-publish-to-ascii" {
1017 do {
1018 return try ASCIIExport.document(text, settings: settings, path: path, bodyOnly: bodyOnly, author: NSFullUserName(), language: OrgPreferences.exportLanguage(), file: true)
1019 } catch let error as ASCIIExport.Unsupported {
1020 throw ASCIIExport.Unsupported(reason: "Can't export \((path as NSString).lastPathComponent) to plain text: \(error.reason)")
1021 }
1022 }
1023 let base = ((path as NSString).lastPathComponent as NSString).deletingPathExtension
1024 return HTMLExport.page(text, fallbackTitle: base, settings: settings, path: path, bodyOnly: bodyOnly, codeStyle: codeStyle, language: OrgPreferences.exportLanguage())
1007 try Publish.export(function, text: text, path: path, bodyOnly: bodyOnly, settings: Preferences.orgSettings, codeStyle: codeStyle)
10251008 }
10261009 commands.show("Published \(report.published.count) files" + (report.skipped.isEmpty ? "" : ", \(report.skipped.count) up to date"))
10271010 } catch {
Sources/OrgstarMobile/ClockScreens.swift +9
@@ -76,6 +76,15 @@ enum MobileClock {
7676 }
7777 return true
7878 }
79
80 /// `org-resolve-clocks-if-idle` for the running clock, idle since `since`.
81 static func resolveIdle(since: Date, model: MobileModel, show: @escaping (String) -> Void) {
82 Task {
83 let outcome = await model.clock.resolveIdle(model.session, idleSince: since, ask: model.clockPrompts.ask)
84 if let jump = outcome.jump { model.openRequest = .offset(jump.path, jump.offset) }
85 if let message = outcome.messages.last(where: { !$0.isEmpty }) { show(message) }
86 }
87 }
7988}
8089
8190/// Recent entries to clock in to, and the commands that choose among them.
Sources/OrgstarMobile/EditorScreen.swift +124
@@ -69,6 +69,15 @@ struct EditorScreen: View {
6969 @State private var photos: [PhotosPickerItem] = []
7070 /// A file shown in Quick Look.
7171 @State private var previewed: URL?
72 /// The project whose publishing folder the folder picker is choosing.
73 @State private var publishFolder: PublishFolderRequest?
74 @State private var choosingPublishFolder = false
75
76 struct PublishFolderRequest {
77 let project: String
78 /// Publishes again, with the folder.
79 let then: () -> Void
80 }
7281
7382 enum Sheet: Identifiable {
7483 case palette, conflict, syncCopies, recovery
@@ -281,6 +290,18 @@ struct EditorScreen: View {
281290 }
282291 }
283292 }
293 .background {
294 Color.clear.fileImporter(isPresented: $choosingPublishFolder, allowedContentTypes: [.folder]) { result in
295 guard let request = publishFolder else { return }
296 publishFolder = nil
297 switch result {
298 case .success(let url):
299 if !PublishFolders.shared.set(url, for: request.project) { message = "orgstar can use \(url.lastPathComponent) only until it quits" }
300 request.then()
301 case .failure(let error): message = error.localizedDescription
302 }
303 }
304 }
284305 .photosPicker(isPresented: $attachingPhotos, selection: $photos, matching: .any(of: [.images, .videos]))
285306 .fullScreenCover(isPresented: $takingPhoto) {
286307 CameraPicker { data in
@@ -441,6 +462,18 @@ struct EditorScreen: View {
441462 if let onPaneCommand { onPaneCommand(id) } else { message = "Not available here" }
442463 } else if id == "app.save" {
443464 _ = session.save(path)
465 } else if id == "app.archive" {
466 if let caret = self.editor?.editContext().caret { message = session.archive(from: (path, caret)) }
467 } else if id == "app.copy-rich-text" {
468 if let text = session.document(of: path)?.text { message = ExportMenu.copy(path: path, text: text, theme: model.theme) }
469 } else if id == "app.export.html-open" {
470 exportHTMLAndOpen()
471 } else if id == "app.export.icalendar-agenda" || id == "app.export.icalendar-combined" {
472 agendaCalendars(combined: id == "app.export.icalendar-combined")
473 } else if id.hasPrefix("app.publish") {
474 publish(id)
475 } else if AppStoreCommands.unavailable(id) {
476 message = "Attachments can't be linked on iPhone and iPad; Attach File… copies the file."
444477 } else if ["app.refile", "app.refile.copy", "app.refile.goto"].contains(id) {
445478 sheet = .refile(id)
446479 } else if id == "app.table-import" {
@@ -576,6 +609,93 @@ extension EditorScreen {
576609 sheet = .exportSubtree(context.caret)
577610 }
578611
612 /// `org-html-export-to-html` and open: the page in Quick Look, from a temporary file.
613 private func exportHTMLAndOpen() {
614 guard let text = session.document(of: path)?.text else { return }
615 let html = OrgExport.html(text, path: path, theme: model.theme)
616 let name = ExportScope.output(for: URL(fileURLWithPath: path), name: ExportScope.fileName(text, settings: OrgPreferences.orgSettings()), extension: "html")
617 .lastPathComponent
618 do {
619 previewed = try HTMLPreview.write(html, directory: URL(fileURLWithPath: path).deletingLastPathComponent(), name: name)
620 } catch {
621 message = "Can't export \(name): \(error.localizedDescription)"
622 }
623 }
624
625 /// The agenda files' calendars written beside them, or combined in one shown in Quick Look,
626 /// whose share button saves or sends it.
627 private func agendaCalendars(combined: Bool) {
628 guard let calendars = AgendaCalendars(model: model) else { return message = "No agenda files" }
629 guard combined else { return message = calendars.exportEach() }
630 do {
631 previewed = try calendars.combined()
632 } catch {
633 message = "Can't export: \(error.localizedDescription)"
634 }
635 }
636
637 /// `org-publish` and its variants, for the `[[publish]]` projects in config.toml.
638 private func publish(_ id: String) {
639 guard let all = publishProjects() else { return }
640 let current = Publish.projects(containing: path, in: all)
641 switch id {
642 case "app.publish.all":
643 publish(all.map(\.name))
644 case "app.publish.current-file":
645 guard let project = current.first else { return message = "File is not part of any known project" }
646 publish([project.name], only: path)
647 case "app.publish.current-project":
648 guard let project = current.first else { return message = "File is not part of any known project" }
649 publish([project.name])
650 default:
651 prompt = PromptRequest(prompt: Prompt(key: "project", message: "Publish project:", choices: all.map(\.name))) { answer in
652 if let answer, all.contains(where: { $0.name == answer }) { publish([answer]) }
653 }
654 }
655 }
656
657 /// The projects in config.toml, each publishing to the folder chosen for it; nil, with a
658 /// message, when there are none.
659 private func publishProjects() -> [PublishProject]? {
660 let config = (try? String(contentsOf: UserConfig.file("config.toml"), encoding: .utf8)) ?? ""
661 let loaded = Publish.projects(fromConfig: config, root: workspace.rootPaths.first)
662 if let problem = loaded.problems.first { message = problem }
663 guard !loaded.projects.isEmpty else {
664 message = "No [[publish]] projects in config.toml"
665 return nil
666 }
667 return PublishFolders.shared.applied(to: loaded.projects)
668 }
669
670 /// Publishes the projects named, `only` that file when given. A project that publishes
671 /// outside the folders added to orgstar asks for its folder first, once.
672 private func publish(_ names: [String], only: String? = nil) {
673 guard let all = publishProjects() else { return }
674 let chosen = all.filter { names.contains($0.name) }
675 do {
676 if let project = try PublishFolders.shared.needed(chosen, all: all, roots: workspace.rootPaths).first {
677 message = "Choose the folder \(project.name) publishes to"
678 publishFolder = PublishFolderRequest(project: project.name) { publish(names, only: only) }
679 choosingPublishFolder = true
680 return
681 }
682 if let project = try Publish.expand(chosen, all: all).first(where: { !FileManager.default.fileExists(atPath: $0.baseDirectory) }) {
683 return message = "Can't read \(project.name)'s base-directory, \(OrgPaths.abbreviatingWithTilde(project.baseDirectory))"
684 }
685 let read = { (file: String) -> String? in
686 session.openDocuments.first { $0.path == file }?.document.text ?? (try? String(contentsOfFile: file, encoding: .utf8))
687 }
688 let codeStyle = HTMLCodeStyle(highlighter: MobileEditor.highlighter, theme: model.theme)
689 // As the Export menu: no author unless the file has #+AUTHOR:.
690 let report = try Publish.publish(chosen, all: all, only: only, author: "", read: read) { function, text, file, bodyOnly in
691 try Publish.export(function, text: text, path: file, bodyOnly: bodyOnly, settings: OrgPreferences.orgSettings(), codeStyle: codeStyle, author: "")
692 }
693 message = "Published \(report.published.count) files" + (report.skipped.isEmpty ? "" : ", \(report.skipped.count) up to date")
694 } catch {
695 message = "\(error)"
696 }
697 }
698
579699 /// Org-roam's commands, with Pro.
580700 private func roam(_ id: String) {
581701 if ProAccess.shared.allows(.roam) { roamActions.run(id) }
@@ -949,6 +1069,10 @@ struct CommandPalette: View {
9491069 ("app.clock.in-last", "Clock In to Last Entry"), ("app.clock.goto-recent", "Go to Recent Clocked Entry…"),
9501070 ("app.clock.default", "Mark as Default Clock Task"), ("app.clock.resolve", "Resolve Open Clocks…"),
9511071 ("app.refile", "Refile…"), ("app.refile.copy", "Copy to Refile Target…"), ("app.refile.goto", "Go to Refile Target…"),
1072 ("app.archive", "Archive Subtree"), ("app.copy-rich-text", "Copy as Rich Text"), ("app.export.html-open", "Export to HTML and Open"),
1073 ("app.export.icalendar-agenda", "Export Agenda Files to iCalendar"), ("app.export.icalendar-combined", "Combine Agenda Files into iCalendar"),
1074 ("app.publish", "Publish Project…"), ("app.publish.all", "Publish All Projects"), ("app.publish.current-file", "Publish Current File"),
1075 ("app.publish.current-project", "Publish Current Project"),
9521076 ("app.toggle-markup", "Show or Hide Markup"),
9531077 ("org.toggle-inline-images", "Show or Hide Inline Images"), ("org.latex-preview", "Show or Hide LaTeX Previews"), ("editor.toggle-truncate-lines", "Truncate or Wrap Long Lines"), ("editor.toggle-auto-fill", "Turn Auto Fill On or Off"),
9541078 ("edit.isearch-forward", "Incremental Search"), ("edit.isearch-backward", "Incremental Search Backward"),
Sources/OrgstarMobile/EmacsImportScreen.swift +37 −6
@@ -5,8 +5,8 @@ import SwiftUI
55
66/// Import from Emacs: a configuration folder (a synced `~/.config/doom` or `~/.emacs.d`), read
77/// and picked from before anything changes. Settings go into the configuration
8/// folder's config.toml when there is one; agenda folders, which name the Mac's paths, are left
9/// out.
8/// folder's config.toml when there is one. Agenda folders name the Mac's paths, so each is
9/// added as the folder chosen for it on this device.
1010struct EmacsImportScreen: View {
1111 let model: MobileModel
1212 @State private var location: URL?
@@ -15,6 +15,11 @@ struct EmacsImportScreen: View {
1515 @State private var choosing = false
1616 @State private var summary: String?
1717 @State private var importing = false
18 /// The folders chosen on this device, by the Mac path they stand for.
19 @State private var folders: [String: URL] = [:]
20 /// The Mac path the folder picker is choosing for.
21 @State private var folderFor: String?
22 @State private var choosingFolder = false
1823
1924 var body: some View {
2025 List {
@@ -27,8 +32,25 @@ struct EmacsImportScreen: View {
2732 if let summary {
2833 Section { Text(summary) }
2934 } else if let result {
30 EmacsImportSections(result: result, groups: result.groups(folders: false), selected: $selected,
35 EmacsImportSections(result: result, groups: result.groups(folders: true), selected: $selected,
3136 font: .system(.callout, design: .monospaced))
37 let paths = EmacsImport.foldersToAdd(result.items.filter { selected.contains($0.id) }, workspace: model.workspace)
38 if !paths.isEmpty {
39 Section {
40 ForEach(paths, id: \.self) { path in
41 Button {
42 folderFor = path
43 choosingFolder = true
44 } label: {
45 LabeledContent(path, value: folders[path]?.lastPathComponent ?? "Choose…")
46 }
47 }
48 } header: {
49 Text("Folders on this device")
50 } footer: {
51 Text("Choose the folder on this device for each one. Folders not chosen aren't added.")
52 }
53 }
3254 }
3355 }
3456 .navigationTitle("Import from Emacs")
@@ -40,6 +62,14 @@ struct EmacsImportScreen: View {
4062 .fileImporter(isPresented: $choosing, allowedContentTypes: [.folder]) { chosen in
4163 if case .success(let url) = chosen { read(url) }
4264 }
65 .background {
66 // A second importer on the same view would replace the first.
67 Color.clear.fileImporter(isPresented: $choosingFolder, allowedContentTypes: [.folder]) { chosen in
68 guard let path = folderFor, case .success(let url) = chosen else { return }
69 // Access starts when the import adds it.
70 folders[path] = url
71 }
72 }
4373 }
4474
4575 private func read(_ url: URL) {
@@ -48,7 +78,8 @@ struct EmacsImportScreen: View {
4878 location = url
4979 let scanned = EmacsImport.scan(EmacsImport.files(in: url))
5080 result = scanned
51 selected = Set(scanned.groups(folders: false).flatMap(\.1).map(\.id))
81 selected = Set(scanned.groups(folders: true).flatMap(\.1).map(\.id))
82 folders = [:]
5283 summary = nil
5384 }
5485
@@ -57,8 +88,8 @@ struct EmacsImportScreen: View {
5788 importing = true
5889 let chosen = result.items.filter { selected.contains($0.id) }
5990 Task {
60 summary = await EmacsImport.apply(chosen, workspace: nil, directory: model.configFolder ?? UserConfig.directory,
61 writeConfig: model.configFolder != nil)
91 summary = await EmacsImport.apply(chosen, workspace: model.workspace, directory: model.configFolder ?? UserConfig.directory,
92 writeConfig: model.configFolder != nil, chosenFolders: folders)
6293 model.reloadConfig()
6394 importing = false
6495 }
Sources/OrgstarMobile/ExportMenu.swift +70 −9
@@ -91,6 +91,15 @@ struct OrgExport: Transferable {
9191 .exportingCondition { $0.format == .ascii }
9292 }
9393
94 /// The page HTML export makes of `text`, the file at `path`, with its setup files.
95 @MainActor
96 static func html(_ text: String, path: String, theme: ThemeSpec) -> String {
97 let base = ((path as NSString).lastPathComponent as NSString).deletingPathExtension
98 let settings = OrgPreferences.orgSettings().resolvingSetupFiles(in: text, path: path, read: OrgSettings.readFile)
99 return HTMLExport.page(text, fallbackTitle: base, settings: settings, path: path,
100 codeStyle: HTMLCodeStyle(highlighter: MobileEditor.highlighter, theme: theme), language: OrgPreferences.exportLanguage())
101 }
102
94103 private func write() async throws -> SentTransferredFile {
95104 let base = ((path as NSString).lastPathComponent as NSString).deletingPathExtension
96105 let settings = settings.resolvingSetupFiles(in: text, path: path, read: OrgSettings.readFile)
@@ -172,26 +181,78 @@ struct ExportMenu: View {
172181 if let exportSubtree {
173182 Button("Export Subtree…", systemImage: "list.bullet.indent") { exportSubtree() }
174183 }
184 if let calendars = AgendaCalendars(model: model) {
185 Divider()
186 if OrgExport.Format.icalendar.locked {
187 Button("Agenda Files to iCalendar (orgstar+)") { ProAccess.shared.allows(.export) }
188 } else {
189 Button("Export Agenda Files to iCalendar", systemImage: "calendar") { report(calendars.exportEach()) }
190 ShareLink(item: calendars, preview: SharePreview(calendars.fileName)) {
191 Label("Combine Agenda Files into iCalendar", systemImage: "calendar.badge.plus")
192 }
193 }
194 }
175195 Divider()
176 Button("Copy as Rich Text", systemImage: "doc.on.doc") { if ProAccess.shared.allows(.export) { copy() } }
196 Button("Copy as Rich Text", systemImage: "doc.on.doc") { if ProAccess.shared.allows(.export) { report(Self.copy(path: path, text: text, theme: model.theme)) } }
177197 }
178198 }
179199
180 /// The file on the clipboard as HTML, RTF and plain text, to paste formatted.
181 private func copy() {
182 let base = ((path as NSString).lastPathComponent as NSString).deletingPathExtension
183 let settings = OrgPreferences.orgSettings().resolvingSetupFiles(in: text, path: path, read: OrgSettings.readFile)
184 let html = HTMLExport.page(text, fallbackTitle: base, settings: settings, path: path,
185 codeStyle: HTMLCodeStyle(highlighter: MobileEditor.highlighter, theme: model.theme), language: OrgPreferences.exportLanguage())
200 /// The file on the clipboard as HTML, RTF and plain text, to paste formatted. Returns a message.
201 @MainActor
202 static func copy(path: String, text: String, theme: ThemeSpec) -> String {
203 let html = OrgExport.html(text, path: path, theme: theme)
186204 do {
187205 try RichTextExport.copy(html: html, directory: URL(fileURLWithPath: path).deletingLastPathComponent())
188 report("Copied as rich text")
206 return "Copied as rich text"
189207 } catch {
190 report("\(error)")
208 return "\(error)"
191209 }
192210 }
193211}
194212
213/// The agenda files as iCalendar: each to a calendar beside it
214/// (`org-icalendar-export-agenda-files`), or all in one calendar to share
215/// (`org-icalendar-combine-agenda-files`), named as `org-icalendar-combined-agenda-file` is.
216struct AgendaCalendars: Transferable {
217 let paths: [String]
218 /// The open files' text, which may not be saved yet.
219 let open: [String: String]
220
221 /// Nil without agenda files.
222 @MainActor init?(model: MobileModel) {
223 guard let paths = model.workspace?.agendaFilePaths(), !paths.isEmpty else { return nil }
224 self.paths = paths
225 open = Dictionary(model.session.openDocuments.map { ($0.path, $0.document.text) }, uniquingKeysWith: { first, _ in first })
226 }
227
228 var fileName: String { (OrgPreferences.icalendarCombinedFile() as NSString).lastPathComponent }
229
230 private func read(_ path: String) -> (text: String, settings: OrgSettings)? {
231 guard let text = open[path] ?? (try? String(contentsOfFile: path, encoding: .utf8)) else { return nil }
232 return (text, OrgPreferences.orgSettings().resolvingSetupFiles(in: text, path: path, read: OrgSettings.readFile))
233 }
234
235 /// Writes each agenda file's calendar beside it. Returns a message.
236 func exportEach() -> String {
237 do {
238 let written = try ICalendarFiles.exportEach(paths, options: OrgPreferences.icalendarOptions(), read: read)
239 return "Exported \(written.count) agenda files to iCalendar"
240 } catch {
241 return "Can't export: \(error.localizedDescription)"
242 }
243 }
244
245 /// The combined calendar, in a new temporary folder.
246 func combined() throws -> URL {
247 let folder = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
248 return try ICalendarFiles.combine(paths, to: folder.appendingPathComponent(fileName).path, options: OrgPreferences.icalendarOptions(), read: read)
249 }
250
251 static var transferRepresentation: some TransferRepresentation {
252 FileRepresentation(exportedContentType: .calendarEvent) { SentTransferredFile(try $0.combined()) }
253 }
254}
255
195256/// The subtree at `caret` shared alone, in each of the export formats.
196257struct SubtreeExportScreen: View {
197258 let path: String
Sources/OrgstarMobile/MobileEditor.swift +3 −1
@@ -425,7 +425,9 @@ final class MobileEditor: NSObject, DocumentBuffer {
425425 case "app.crypt.encrypt-entry": return onAppCommand != nil && OrgCrypt.heading(context.text, at: context.caret) != nil && OrgCrypt.encryptedRange(context.text, at: context.caret) == nil
426426 case "app.crypt.open-entry", "app.crypt.decrypt-entry": return onAppCommand != nil && OrgCrypt.encryptedRange(context.text, at: context.caret) != nil
427427 case "app.table-export", "app.plot": return onAppCommand != nil && ImportTable.exportText(context.text, at: context.caret, path: "") != nil
428 case "app.refile", "app.refile.copy": return onAppCommand != nil && Presentation.heading(containing: context.caret, in: context.tree) != nil
428 case "app.refile", "app.refile.copy", "app.archive": return onAppCommand != nil && Presentation.heading(containing: context.caret, in: context.tree) != nil
429 case "app.copy-rich-text", "app.export.html-open", "app.export.icalendar-agenda", "app.export.icalendar-combined": return onAppCommand != nil
430 case _ where id.hasPrefix("app.publish"): return onAppCommand != nil
429431 case _ where Self.linkCommands.contains(id): return onAppCommand != nil
430432 case "org.link.open": return OpenLinkAtPoint().applies(in: context)
431433 case "org.table.toggle-column-width", "org.table.shrink", "org.table.expand":
Sources/OrgstarMobile/OrgstarMobileApp.swift +10
@@ -10,6 +10,8 @@ import UserNotifications
1010struct OrgstarMobileApp: App {
1111 @UIApplicationDelegateAdaptor private var delegate: AppDelegate
1212 @State private var model = MobileModel.shared
13 /// The app's phase: in the background only when every window is.
14 @Environment(\.scenePhase) private var scenePhase
1315
1416 init() {
1517 // Debug builds, and runs from Xcode, whose scheme sets ORGSTAR_PERF.
@@ -35,6 +37,10 @@ struct OrgstarMobileApp: App {
3537 ContentUnavailableView("Can't open the index", systemImage: "exclamationmark.triangle", description: Text(model.failure ?? ""))
3638 }
3739 }
40 // For the clock's idle time: time working in another window isn't time away.
41 .onChange(of: scenePhase) { _, phase in
42 if phase == .background { model.clock.wentAway() }
43 }
3844 }
3945}
4046
@@ -324,6 +330,10 @@ struct RootView: View {
324330 }
325331 // Files and settings synced while away; not every sync tool tells file presenters.
326332 guard phase == .active else { return }
333 // iOS has no idle time: time away from the app while a clock ran stands in for it.
334 if let since = model.clock.cameBack(idleMinutes: OrgPreferences.clockIdleTime()) {
335 MobileClock.resolveIdle(since: since, model: model) { message = $0 }
336 }
327337 takeShared()
328338 model.reloadConfig()
329339 Task { await workspace.refresh() }
Tests/OrgAppTests/ClockHistoryModelTests.swift +26
@@ -192,4 +192,30 @@ struct ClockHistoryModelTests {
192192 #expect(next.asked == ["You stopped another clock 50 mins ago; start this one from then? (y or n) "])
193193 #expect(clock.running?.heading == "C" && clock.running?.startedAt == idle && clock.leftover == nil)
194194 }
195
196 /// iOS: time in the background past `org-clock-idle-time` is idle from when the app left,
197 /// or from clocking in, when that came later.
198 @Test func backgroundTimeIsIdleTime() {
199 let running = ClockModel.Running(path: work.path, start: "2026-09-09 Wed 10:00", heading: "A", startedAt: start)
200 let left = start.addingTimeInterval(10 * 60)
201 #expect(ClockModel.idleSince(backgrounded: left, now: left.addingTimeInterval(16 * 60), running: running, idleMinutes: 15) == left)
202 #expect(ClockModel.idleSince(backgrounded: left, now: left.addingTimeInterval(15 * 60), running: running, idleMinutes: 15) == nil)
203 #expect(ClockModel.idleSince(backgrounded: left, now: left.addingTimeInterval(60 * 60), running: running, idleMinutes: 0) == nil)
204 #expect(ClockModel.idleSince(backgrounded: left, now: left.addingTimeInterval(60 * 60), running: nil, idleMinutes: 15) == nil)
205 let earlier = start.addingTimeInterval(-30 * 60)
206 #expect(ClockModel.idleSince(backgrounded: earlier, now: start.addingTimeInterval(20 * 60), running: running, idleMinutes: 15) == start)
207 }
208
209 /// iOS: only time with every window in the background is idle, and it's asked about once.
210 @Test func awayTimeIsTheWholeApps() {
211 let clock = ClockModel(file: stateFile, defaults: defaults)
212 _ = clock.clockIn(session, path: work.path, at: offset("* A"), now: start)
213 // One window went to the background while another stayed in use.
214 #expect(clock.cameBack(now: start.addingTimeInterval(60 * 60), idleMinutes: 15) == nil)
215 let left = start.addingTimeInterval(10 * 60)
216 clock.wentAway(at: left)
217 #expect(clock.cameBack(now: left.addingTimeInterval(20 * 60), idleMinutes: 15) == left)
218 // A second window becoming active isn't asked about again.
219 #expect(clock.cameBack(now: left.addingTimeInterval(21 * 60), idleMinutes: 15) == nil)
220 }
195221}
Tests/OrgAppTests/EmacsImportFoldersTests.swift +38
@@ -32,6 +32,44 @@ struct EmacsImportFoldersTests {
3232 #expect(!summary.contains(first), "\(summary)")
3333 }
3434
35 @Test func movesAgendaFilesToTheChosenFolders() async throws {
36 let picked = try Folder()
37 let config = try Folder()
38 let model = try WorkspaceModel(directory: nil)
39 let mac = "/nowhere-\(UUID().uuidString)/org", other = "/also-nowhere-\(UUID().uuidString)"
40 let files = EmacsImport.Item(id: 0, name: "org-agenda-files", summary: "", source: "config.el:1",
41 change: .setting(key: "org-agenda-files", value: .string("\(mac)/inbox.org\n\(mac)/work/a.org\n\(other)/b.org")))
42 let stored = defaults()
43 _ = await EmacsImport.apply([files] + items([mac, other]), defaults: stored, workspace: model, directory: config.url, chosenFolders: [mac: picked.url])
44 let dir = picked.url.standardizedFileURL.path
45 #expect(stored.string(forKey: "agendaFiles") == "\(dir)/inbox.org\n\(dir)/work/a.org")
46
47 let none = defaults()
48 let summary = await EmacsImport.apply([files], defaults: none, workspace: model, directory: config.url, chosenFolders: [:])
49 #expect(none.string(forKey: "agendaFiles") == nil)
50 #expect(summary.contains("org-agenda-files wasn't set"), "\(summary)")
51
52 // A config.toml the Mac reads too keeps the Mac's paths beside the device's.
53 let shared = EmacsImport.agendaFiles("\(mac)/inbox.org\n\(other)/b.org", chosenFolders: [mac: picked.url], keepingOriginals: true)
54 #expect(shared == "\(mac)/inbox.org\n\(dir)/inbox.org\n\(other)/b.org")
55
56 // Relative paths count from org-directory, so they're kept as written.
57 #expect(EmacsImport.agendaFiles("work.org", chosenFolders: ["~/org": picked.url]) == "work.org")
58 #expect(EmacsImport.agendaFiles("work.org\n\(mac)/inbox.org", chosenFolders: [mac: picked.url]) == "work.org\n\(dir)/inbox.org")
59 }
60
61 @Test func relativeAgendaFilesAddNoFolder() throws {
62 let folder = try Folder()
63 try #"(setq org-agenda-files '("work.org" "sub/b.org" "~/notes/" "/srv/org/a.org"))"#
64 .write(to: folder.url.appendingPathComponent("init.el"), atomically: true, encoding: .utf8)
65 let result = EmacsImport.scan(EmacsImport.files(in: folder.url))
66 let folders = result.items.compactMap { item -> String? in
67 if case .folder(let path) = item.change { return path }
68 return nil
69 }
70 #expect(folders == ["~/notes/", "/srv/org"])
71 }
72
3573 @Test func withoutChosenFoldersAddsWhatsWritten() async throws {
3674 let notes = try Folder()
3775 let config = try Folder()
Tests/OrgAppTests/FolderGrantsTests.swift +15
@@ -56,6 +56,21 @@ struct FolderGrantsTests {
5656 #expect(resolved.url.resolvingSymlinksInPath().path == file.resolvingSymlinksInPath().path)
5757 }
5858
59 @Test func staleBookmarkIsRenewed() throws {
60 let folder = try Folder()
61 let before = folder.url.appendingPathComponent("before")
62 let after = folder.url.appendingPathComponent("after")
63 try FileManager.default.createDirectory(at: before, withIntermediateDirectories: true)
64 let data = try #require(SecurityBookmark.make(before, sandboxed: false))
65 try FileManager.default.moveItem(at: before, to: after)
66 let resolved = try #require(SecurityBookmark.resolve(data, sandboxed: false))
67 #expect(resolved.url.resolvingSymlinksInPath().path == after.resolvingSymlinksInPath().path)
68 let renewed = try #require(resolved.renewed)
69 let again = try #require(SecurityBookmark.resolve(renewed, sandboxed: false))
70 #expect(again.url.resolvingSymlinksInPath().path == after.resolvingSymlinksInPath().path)
71 #expect(again.renewed == nil)
72 }
73
5974 @Test func foldersToGrantSkipReachablePaths() {
6075 let reachable = [URL(fileURLWithPath: "/notes"), URL(fileURLWithPath: "/container")]
6176 let existing: Set<String> = ["/", "/notes", "/container", "/other", "/other/site"]
Tests/OrgAppTests/PDFExportTests.swift +12
@@ -54,4 +54,16 @@ struct PDFExportTests {
5454 let html = #"<img src="img/a.png"> <img alt="c" src="/abs/c.svg"> <img src="https://x.org/r.png"> <img src="img/a.png">"#
5555 #expect(PDFExport.imageFiles(html, directory: URL(fileURLWithPath: "/notes")) == ["/notes/img/a.png", "/abs/c.svg"])
5656 }
57
58 /// Export to HTML and Open on iOS: a temporary page with its images in it.
59 @Test func previewHasItsImages() throws {
60 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-\(UUID().uuidString)")
61 try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true)
62 defer { try? FileManager.default.removeItem(at: folder) }
63 try Data([1, 2, 3]).write(to: folder.appendingPathComponent("a.png"))
64 let url = try HTMLPreview.write(#"<p><img src="a.png"></p>"#, directory: folder, name: "notes.html")
65 defer { try? FileManager.default.removeItem(at: url.deletingLastPathComponent()) }
66 #expect(url.lastPathComponent == "notes.html")
67 #expect(try String(contentsOf: url, encoding: .utf8) == #"<p><img src="data:image/png;base64,AQID"></p>"#)
68 }
5769}
Tests/OrgAppTests/PublishTests.swift +80
@@ -261,6 +261,21 @@ struct PublishTests {
261261 #expect(String(decoding: data[30..<38], as: UTF8.self) == "mimetype")
262262 }
263263
264 /// The ODT author comes from the caller: iOS passes none, as its Export menu does.
265 @Test func publishesODTWithTheCallersAuthor() throws {
266 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-publish-\(UUID().uuidString)")
267 defer { try? FileManager.default.removeItem(at: folder) }
268 try Self.tree(folder)
269 let config = "[[publish]]\nname = \"odt\"\nbase-directory = \"\(folder.path)/src\"\npublishing-directory = \"\(folder.path)/odt\"\npublishing-function = \"org-odt-publish-to-odt\"\n"
270 let loaded = Publish.projects(fromConfig: config, root: nil)
271 let read = { (path: String) in try? String(contentsOfFile: path, encoding: .utf8) }
272 let odt = folder.appendingPathComponent("odt/a.odt")
273 _ = try Publish.publish(loaded.projects, all: loaded.projects, author: "Quill Writer", read: read) { _, _, _, _ in "" }
274 #expect(try Data(contentsOf: odt).range(of: Data("Quill Writer".utf8)) != nil)
275 _ = try Publish.publish(loaded.projects, all: loaded.projects, force: true, author: "", read: read) { _, _, _, _ in "" }
276 #expect(try Data(contentsOf: odt).range(of: Data("Quill Writer".utf8)) == nil)
277 }
278
264279 @Test func skipsUpToDateFilesAndFindsProjects() throws {
265280 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-publish-\(UUID().uuidString)").resolvingSymlinksInPath()
266281 defer { try? FileManager.default.removeItem(at: folder) }
@@ -278,4 +293,69 @@ struct PublishTests {
278293 #expect(Publish.projects(fromConfig: "[[publish]]\nname = \"x\"\n", root: nil).problems.count == 1)
279294 #expect(throws: Publish.Failure.self) { try Publish.expand([PublishProject(name: "m")].map { var p = $0; p.components = ["nope"]; return p }, all: []) }
280295 }
296
297 /// The exporter both apps publish with: each function's format, and the file named in a
298 /// refusal.
299 @Test func exportsByFunction() throws {
300 let path = "/notes/a.org"
301 let text = "#+TITLE: A\n* One\nText.\n"
302 func export(_ function: String) throws -> String {
303 try Publish.export(function, text: text, path: path, bodyOnly: false, settings: .default, codeStyle: nil, author: "A. Writer", language: "en")
304 }
305 #expect(try export("org-html-publish-to-html").contains("<title>A</title>"))
306 #expect(try export("org-md-publish-to-md").contains("# One"))
307 #expect(try export("org-latex-publish-to-latex").contains("\\title{A}"))
308 #expect(try export("org-ascii-publish-to-ascii").contains("1 One"))
309 #expect(throws: LaTeXExport.Unsupported(reason: "Can't export a.org to LaTeX: Radio targets")) {
310 try Publish.export("org-latex-publish-to-latex", text: "<<<radio>>> radio\n", path: path, bodyOnly: false, settings: .default, codeStyle: nil, author: "", language: "en")
311 }
312 }
313}
314
315/// Publishing on iOS: a project that publishes outside the app's folders writes to the folder
316/// chosen for it, kept as a bookmark.
317@MainActor
318struct PublishFoldersTests {
319 @Test func publishesToTheBookmarkedFolder() throws {
320 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-publish-ios-\(UUID().uuidString)").resolvingSymlinksInPath()
321 defer { try? FileManager.default.removeItem(at: folder) }
322 try PublishTests.tree(folder)
323 let chosen = folder.appendingPathComponent("chosen")
324 try FileManager.default.createDirectory(at: chosen, withIntermediateDirectories: true)
325 let config = """
326 [[publish]]
327 name = "site"
328 base-directory = "src"
329 publishing-directory = "~/public_html"
330
331 [[publish]]
332 name = "inside"
333 base-directory = "src"
334 publishing-directory = "src/out"
335
336 [[publish]]
337 name = "both"
338 components = "site inside"
339 """
340 let root = folder.path
341 let loaded = Publish.projects(fromConfig: config, root: root)
342 let defaults = UserDefaults(suiteName: "orgstar-publish-\(UUID().uuidString)")!
343 let folders = PublishFolders(defaults: defaults, sandboxed: false)
344 let both = loaded.projects.first { $0.name == "both" }!
345 #expect(try folders.needed([both], all: loaded.projects, roots: [root]).map(\.name) == ["site"])
346 #expect(folders.set(chosen, for: "site"))
347
348 // After a relaunch, the bookmark gives the folder back.
349 let again = PublishFolders(defaults: defaults, sandboxed: false)
350 #expect(again.folder(for: "site")?.standardizedFileURL == chosen.standardizedFileURL)
351 #expect(try again.needed([both], all: loaded.projects, roots: [root]).isEmpty)
352 let projects = again.applied(to: loaded.projects)
353 let site = projects.first { $0.name == "site" }!
354 #expect(URL(fileURLWithPath: site.publishingDirectory).standardizedFileURL == chosen.standardizedFileURL)
355 #expect(projects.first { $0.name == "inside" }?.publishingDirectory == root + "/src/out")
356 let read = { (path: String) in try? String(contentsOfFile: path, encoding: .utf8) }
357 let report = try Publish.publish([site], all: projects, read: read) { _, text, _, _ in text }
358 #expect(!report.published.isEmpty)
359 #expect(FileManager.default.fileExists(atPath: chosen.appendingPathComponent("a.html").path))
360 }
281361}
Tests/OrgCoreTests/TableFormulaTests.swift +16
@@ -45,6 +45,7 @@ struct TableFormulaTests {
4545 "| a | b | c |\n|---+---+---|\n| 1 | 2 | |\n| 3 | 4 | |\n#+TBLFM: $3='(+ $1 $2);L\n",
4646 "| a |\n|---|\n| 1 |\n| 2 |\n|---|\n| |\n#+TBLFM: @>$1='(apply '+ '(@I..@II));N\n",
4747 "| a | b |\n|---+---|\n| 1 | |\n#+TBLFM: $2='(car 1)\n",
48 "| a | b | c | d | e | f |\n|---+---+---+---+---+---|\n| 1 | | | | | |\n#+TBLFM: $2='(list 1 2)::$3='(list \"a\" \"b\")::$4='(cons \"a\" \"b\");%.2f::$5='(list \"a b\" (list \"c\"))::$6='(list)\n",
4849 "| a | b | c |\n|---+---+---|\n| 3.14159 | | |\n| 2 | | |\n#+TBLFM: $2='(format \"%05.1f\" $1);N::$3='(+ $1 1);N%.2f\n",
4950 "| a | b |\n|---+---|\n| 5 | |\n| 12 | |\n#+TBLFM: $2='(if (> $1 10) \"big\" \"small\");N\n",
5051 "| ! | qty | price | total |\n|---+-----+-------+-------|\n| | 2 | 3 | |\n| | 4 | 0.5 | |\n#+TBLFM: $4=$qty*$price\n",
@@ -222,6 +223,21 @@ struct TableFormulaTests {
222223 /// Two formulas, then one only Emacs can do: in row order, as Emacs applies them.
223224 static let unsupported = "| a | b | c | d |\n|---+---+---+---|\n| 1 | | | |\n| 2 | | | |\n#+TBLFM: $2=$1*2::$3=$1+1::$4='(shell-command-to-string $1)\n"
224225
226 @Test func lispConsIsAnError() {
227 let text = "| a | b | c | d | e |\n|---+---+---+---+---|\n| 1 | | | | |\n#+TBLFM: $2='(list 1 2)::$3='(cons \"a\" \"b\");N%.2f::$4='(list 'quote '(\"a\" \"b\"))::$5='(list)\n"
228 let caret = (text as NSString).range(of: "#+TBLFM").location
229 let result = Self.recalculate(TableRecalculate(all: true), text, caret: caret)
230 #expect(result.failure == nil)
231 #expect(result.text.hasPrefix("| a | b | c | d | e |\n|---+--------+--------+--------+-----|\n| 1 | #ERROR | #ERROR | #ERROR | nil |\n"))
232 let duration = "| a | b |\n|---+---|\n| 1 | |\n#+TBLFM: $2='(list 1 2);T\n"
233 let context = EditContext(revision: 0, text: duration, tree: OrgParser.parse(duration), selection: [3..<3])
234 guard case .external(.emacsTable(_, _, _, let reason, _, _, _)) = TableRecalculate(all: true).run(in: context) else {
235 Issue.record("not a request")
236 return
237 }
238 #expect(reason == "Lisp formula with a list value and a duration")
239 }
240
225241 @Test func keepsFieldsWrittenBeforeAFormulaOnlyEmacsCanDo() {
226242 let text = Self.unsupported
227243 let caret = (text as NSString).range(of: "#+TBLFM").location + 3
Tests/OrgEditorAppKitTests/AppStoreCommandsTests.swift +8
@@ -29,4 +29,12 @@ struct AppStoreCommandsTests {
2929 #expect(AppStoreCommands.replacement(for: id) == nil)
3030 }
3131 }
32
33 /// Linking a file from another container fails in the sandbox, so iOS refuses these too.
34 @Test func attachingByLinkIsUnavailable() {
35 #expect(AppStoreCommands.unavailable("app.attach.link"))
36 #expect(AppStoreCommands.unavailable("app.attach.symlink"))
37 #expect(!AppStoreCommands.unavailable("app.attach.attach"))
38 #expect(!AppStoreCommands.unavailable("app.export.pdf"))
39 }
3240}
docs/manual/guide/06-dates-and-clocking.org +3 −1
@@ -399,7 +399,9 @@ While a clock runs, orgstar checks every minute how long the Mac has had no keyb
399399Clocked in & idle for 17.3 mins [jkKtTgGSscCiq]?
400400#+END_EXAMPLE
401401
402The keys are those in the table above, with the idle time starting when input stopped. The iOS app has no idle detection.
402The keys are those in the table above, with the idle time starting when input stopped.
403
404iOS doesn't tell apps how long the device has been idle. Instead, when you return to the app while a clock runs, time spent in other apps or with the device locked counts as idle: past =org-clock-idle-time=, orgstar asks the same question, with the idle time starting when you left the app, or when the clock started if that was later.
403405
404406** Editing clock lines
405407
docs/manual/guide/10-tables.org +2 −1
@@ -574,7 +574,8 @@ Any other function, or a macro not listed, needs Emacs. As in Emacs 31, =lambda=
574574=function= make function objects rather than lists, so a formula whose value is one, or
575575that prints one or takes it apart as a list, needs Emacs; calling one, or passing it to a
576576function that calls it, doesn't. An error inside a Lisp formula
577writes =#ERROR= in the field, as does a Calc error.
577writes =#ERROR= in the field, as does a Calc error. So does a value that is a non-empty
578list, ignoring the format; with =T=, =U= or =t= such a value needs Emacs.
578579
579580=org-sbe= writes the value of a named src block, run with the variables given:
580581
docs/manual/guide/12-export.org +8 −4
@@ -46,7 +46,9 @@ The dialog remembers the format and the *Open after export* setting. The PDF set
4646
4747** On iOS
4848
49The Export menu offers HTML, Markdown, PDF, Word, Rich Text (RTF), Plain Text, ODT, iCalendar, LaTeX and Plain Text (ASCII), and Copy as Rich Text. It is under More in the editor, and in the toolbar in the reader. Choosing one opens the share sheet with the exported file, named after the Org file or its =#+EXPORT_FILE_NAME:=. Send it to another app, or use Save to Files to keep it. The export is the same as on the Mac, except that LaTeX, ODT and ASCII have no author unless the file has =#+AUTHOR:=. PDF through LaTeX is not available on iOS, nor are the agenda-file iCalendar exports.
49The Export menu offers HTML, Markdown, PDF, Word, Rich Text (RTF), Plain Text, ODT, iCalendar, LaTeX and Plain Text (ASCII), and Copy as Rich Text. It is under More in the editor, and in the toolbar in the reader. Choosing one opens the share sheet with the exported file, named after the Org file or its =#+EXPORT_FILE_NAME:=. Send it to another app, or use Save to Files to keep it. The export is the same as on the Mac, except that LaTeX, ODT and ASCII have no author unless the file has =#+AUTHOR:=. PDF through LaTeX is not available on iOS.
50
51The Export menu also has Export Agenda Files to iCalendar and Combine Agenda Files into iCalendar (see [[*iCalendar export][iCalendar export]]). Export to HTML and Open, in Commands or on =C-c C-e h o= with a hardware keyboard, shows the HTML export in Quick Look, with the file's images in the page; nothing is written beside the Org file. Copy as Rich Text is in Commands too.
5052
5153* HTML export
5254
@@ -310,7 +312,7 @@ The summary is the heading's title, or its =SUMMARY= property. The description i
310312
311313=#+ICALENDAR_EXCLUDE_TAGS:= lists tags whose subtrees are left out; =#+EXCLUDE_TAGS:= doesn't apply, so =noexport= subtrees are exported unless listed. =#+SELECT_TAGS=, =COMMENT= headings and =ARCHIVE= tags apply as in the other exports. =#+ICAL-TTL:= sets =X-PUBLISHED-TTL=, the refresh period, such as =PT1H=. The calendar is named after the file, its description is =#+TITLE:=, and its owner =#+AUTHOR:= or your full name. Lines longer than 75 characters are folded and lines end in CRLF, as RFC 5545 asks.
312314
313Export Agenda Files to iCalendar writes an =.ics= beside each agenda file (see [[file:07-agenda.org][The agenda]]). Combine Agenda Files into iCalendar writes all their entries to one calendar named =OrgMode= at =org-icalendar-combined-agenda-file=. On iOS, the Export menu's iCalendar shares the current file's calendar.
315Export Agenda Files to iCalendar writes an =.ics= beside each agenda file (see [[file:07-agenda.org][The agenda]]). Combine Agenda Files into iCalendar writes all their entries to one calendar named =OrgMode= at =org-icalendar-combined-agenda-file=. On iOS, the Export menu's iCalendar shares the current file's calendar, Export Agenda Files to iCalendar writes beside each agenda file as on the Mac, and Combine Agenda Files into iCalendar opens the share sheet with the combined calendar, named as =org-icalendar-combined-agenda-file= is; from Commands it opens in Quick Look, whose share button saves or sends it.
314316
315317Differences from Org: diary sexps (=%%(…)= lines and =<%%(…)>= timestamps) are left out, as they need Emacs's =icalendar.el=. The other =org-icalendar-*= variables keep Org's defaults: alarms only from =APPT_WARNTIME=, categories =(local-tags category)=, the whole body as the description, and local times. Descriptions of tables with column groups or alignment cookies, center blocks and links to targets can differ from Org's in layout.
316318
@@ -362,7 +364,7 @@ components = "notes static"
362364
363365Files whose names start with a dot are left out. An Org file publishes to the same path under =publishing-directory=, named by =#+EXPORT_FILE_NAME= when it has one, with links to other =.org= files pointing to their =.html=. The sitemap lists each file as a link with its =#+TITLE= (or its name), as Org's default sitemap does.
364366
365On the Mac, File ▸ Publish has the commands, which are also in the command palette:
367On the Mac, File ▸ Publish has the commands, which are also in the command palette. On iOS they are in Commands in the editor; Publish Project… lists the projects to choose from. As with the iOS share sheet, LaTeX, ODT and plain text published on iOS have no author unless the file has =#+AUTHOR:=.
366368
367369| Command | Emacs preset | What it does |
368370|-------------------------+---------------+------------------------------------------------------------|
@@ -371,7 +373,9 @@ On the Mac, File ▸ Publish has the commands, which are also in the command pal
371373| Publish Current File | =C-c C-e P f= | The current file, in the first project that has it (=org-publish-current-file=) |
372374| Publish Current Project | =C-c C-e P p= | The first project that has the current file (=org-publish-current-project=) |
373375
374A file whose published copy is newer than it is skipped, as Org skips files that haven't changed; delete the copy to publish it again. The message area says how many files were published and how many were up to date. Differences from Org: preparation and completion functions, =:makeindex=, custom sitemap functions and the export options a project can set (=:with-toc=, =:html-head= and the rest) aren't read; set those with =#+OPTIONS= and the other keywords in the files, or a =#+SETUPFILE=. Publishing is on the Mac only.
376A file whose published copy is newer than it is skipped, as Org skips files that haven't changed; delete the copy to publish it again. The message area says how many files were published and how many were up to date. Differences from Org: preparation and completion functions, =:makeindex=, custom sitemap functions and the export options a project can set (=:with-toc=, =:html-head= and the rest) aren't read; set those with =#+OPTIONS= and the other keywords in the files, or a =#+SETUPFILE=.
377
378On iOS, orgstar can write only inside the folders you added. A relative =base-directory= or =publishing-directory= is read from the first folder. For a project whose =publishing-directory= is outside your folders, orgstar asks for a folder the first time it publishes the project ("Choose the folder /name/ publishes to"), and publishes there from then on. A project whose =base-directory= can't be read stops with "Can't read /name/'s base-directory".
375379
376380* Exporting through Emacs
377381
docs/manual/guide/14-ios.org +18 −9
@@ -159,7 +159,9 @@ Incremental Search is in Commands, and on =C-s= and =C-r= with a hardware keyboa
159159
160160The org-timer commands are in Commands; a running timer shows above the text. See [[file:06-dates-and-clocking.org][Dates and clocking]].
161161
162More ▸ Attachments has the org-attach commands, Attach Photo or Video… and Take Photo…, which insert the photo's link at the caret; files shared to orgstar can be attached to an entry. Pasting an image and dropping files on the editor attach them and link them at the caret. See [[file:04-outlines.org][Outlines]] and [[file:09-links.org][Links]].
162More ▸ Attachments has the org-attach commands, Attach Photo or Video… and Take Photo…, which insert the photo's link at the caret; files shared to orgstar can be attached to an entry. Pasting an image and dropping files on the editor attach them and link them at the caret. Attachments are copied or moved: iOS doesn't let orgstar link a file from another app's storage, so the keys for attaching by hard link or symbolic link say "Attachments can't be linked on iPhone and iPad; Attach File… copies the file." See [[file:04-outlines.org][Outlines]] and [[file:09-links.org][Links]].
163
164Archive Subtree in Commands (or =C-c C-x C-s= with a hardware keyboard) archives the entry at the caret where =org-archive-location= says, as on the Mac.
163165
164166More ▸ 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.
165167
@@ -313,7 +315,7 @@ Recent Entries, in the bar and in the editor's More menu, lists the recently clo
313315
314316Clock questions open in a sheet: the task selection and the resolution keys as lists to tap, and minutes or a date and time as a field. Cancel answers nothing, as =q= does. Clocking in with no clock running first asks about open clocks in your folders, from the editor, an agenda entry's Clock In or a capture template with =clock-in=; Resolve Open Clocks… asks about every open clock. Both work as on the Mac.
315317
316The iOS app has no idle detection, so =org-clock-idle-time= doesn't apply. =org-clock-history-length= does.
318With =org-clock-idle-time= set, returning to the app while a clock runs asks what to do with the time away, if it was longer than that many minutes: iOS has no idle time, so time in other apps or with the device locked stands in for it. Time working in another orgstar window doesn't count. See [[file:06-dates-and-clocking.org][Dates and clocking]]. =org-clock-history-length= applies too.
317319
318320Clock Report shows the time per day and heading for the files you choose. It starts with the files that contain clock lines. Turn on Limit dates to choose a range. The share button sends the report as text.
319321
@@ -331,7 +333,11 @@ The app icon's badge counts the entries in the agenda's Overdue section that are
331333
332334Export (in the reader's toolbar and the editor's More menu) offers HTML, Markdown, PDF, Word, Rich Text (RTF), Plain Text, ODT, iCalendar, LaTeX and Plain Text (ASCII), and Copy as Rich Text. Each opens the share sheet with a file named after the org file, which you can send to another app or keep with Save to Files. The export reads the file's setup files and follows its export keywords, as the Mac's export does. For a file the LaTeX or ASCII export can't write as Emacs would, the share sheet stops and "Can't export to LaTeX: " or "Can't export to plain text: " and the reason show at the bottom of the screen.
333335
334PDF export follows =pdf-margin=, =pdf-font= and =pdf-page-numbers= in =config.toml=, and Word files get heading styles and the file's images, as on the Mac. PDF through LaTeX isn't available on iOS. See [[file:12-export.org][Export]].
336PDF export follows =pdf-margin=, =pdf-font= and =pdf-page-numbers= in =config.toml=, and Word files get heading styles and the file's images, as on the Mac. PDF through LaTeX isn't available on iOS.
337
338The Export menu also has Export Agenda Files to iCalendar, which writes an =.ics= beside each agenda file, and Combine Agenda Files into iCalendar, which shares one calendar of them all. Commands has these, Copy as Rich Text, and Export to HTML and Open, which shows the HTML export in Quick Look.
339
340Publishing works from Commands as on the Mac, with the =[[publish]]= projects in =config.toml=. A project that publishes outside your folders asks for a folder the first time, and uses it from then on. See [[file:12-export.org][Export]].
335341
336342* Code blocks and tables
337343
@@ -385,7 +391,9 @@ Import from Emacs reads an Emacs or Doom configuration folder, such as a synced
3853912. The screen lists the settings, capture templates, key bindings, structure templates and agenda views it found, each with the line it came from, all selected. Clear what you don't want.
3863923. Tap Import. The screen then summarizes what was imported and any problems.
387393
388With a configuration folder, settings and structure templates are written to its =config.toml=, and capture templates, key bindings and agenda views to its =capture.toml=, =keymap.toml= and =views.toml=, so the Mac reads them too. Without one, settings are kept on the device. Folders from =org-agenda-files= name the Mac's paths and aren't offered.
394With a configuration folder, settings and structure templates are written to its =config.toml=, and capture templates, key bindings and agenda views to its =capture.toml=, =keymap.toml= and =views.toml=, so the Mac reads them too. Without one, settings are kept on the device.
395
396Folders from =org-directory= and =org-agenda-files= name the Mac's paths, so the screen lists them under Folders on this device. Tap each one and choose the folder on this device that holds the same files, such as its synced copy in iCloud Drive. Import adds the chosen folders to the Folders tab; folders not chosen aren't added, and the summary says so. =org-agenda-files= entries in a chosen folder point to the same files in the folder chosen for it, and entries in folders not chosen are left out. Relative entries are kept as written and count from the first folder, as Emacs counts them from =org-directory=; they add no folder of their own. With a configuration folder, =config.toml= keeps the Mac's entries as well, beside the device's; each device skips the files it doesn't have.
389397
390398The Agenda, TODO Dependencies, Calendar and Reminders sections are the only places the app changes a setting itself, besides Import from Emacs:
391399
@@ -423,9 +431,10 @@ These settings from =config.toml= apply on iOS:
423431- =org-agenda-span=, =org-agenda-start-day=, =org-agenda-start-on-weekday=, =org-deadline-warning-days=, =agenda-include-subfolders=, =agenda-exclude-archives=, =org-agenda-show-all-dates=, =org-agenda-skip-scheduled-if-done=, =org-agenda-skip-deadline-if-done=, =org-habit-show-habits-only-for-today=, =org-agenda-search-view-always-boolean=, =org-agenda-search-view-force-full-words=, =org-agenda-log-mode-items=, the =org-agenda-todo-ignore-= settings, =org-agenda-tags-todo-honor-ignore-options=
424432- =calendar-events=, =calendar-event-calendars=, =agenda-reminders=, =agenda-reminder-lists=
425433- =reminders=, =appt-message-warning-time=
426- =org-clock-history-length=, =org-clock-into-drawer=, =org-clock-rounding-minutes=, =org-clock-out-remove-zero-time-clocks=, =org-clock-in-switch-to-state=, =org-clock-out-when-done=
434- =org-clock-history-length=, =org-clock-into-drawer=, =org-clock-rounding-minutes=, =org-clock-out-remove-zero-time-clocks=, =org-clock-in-switch-to-state=, =org-clock-out-when-done=, =org-clock-idle-time=
435- =org-icalendar-combined-agenda-file= (its name) and the other =org-icalendar-= settings, =[[publish]]=
427436
428=capture.toml= and =views.toml= in the folder apply too. =keymap= and =keymap.toml= apply with a hardware keyboard. Other settings, including =save= and =org-clock-idle-time=, don't apply on iOS. See [[file:13-configuration.org][Configuration]].
437=capture.toml= and =views.toml= in the folder apply too. =keymap= and =keymap.toml= apply with a hardware keyboard. Other settings, including =save=, don't apply on iOS. See [[file:13-configuration.org][Configuration]].
429438
430439* Spotlight and Quick Look
431440
@@ -436,9 +445,9 @@ Quick Look in the Files app shows org files as the HTML export renders them.
436445* What the Mac has that iOS doesn't
437446
438447- In the download version: running code blocks in languages other than Emacs Lisp and JavaScript, Emacs Lisp beyond orgstar's interpreter, JavaScript that needs node, and tables that need Emacs.
439- Publishing, and in the download version LaTeX-made PDF export.
440- Idle detection while a clock runs.
441- Import from Emacs of agenda folders.
448- In the download version, LaTeX-made PDF export.
449- Idle detection from keyboard and mouse input; iOS uses the time away from the app instead.
450- In the download version, attaching by hard link or symbolic link.
442451- The Columns inspector, the buffer list and tab bar, and resizing panes by dragging their divider. The board and column view are there (see [[file:07-agenda.org][The agenda]] and [[file:04-outlines.org][Outlines]]).
443452- The global capture hotkey and the Settings window.
444453- Explicit saving.