Commit 7b8e9c5338
7b8e9c5338e64edcb9d405f5449784741a5bdfa2
parent: 9e1739554b
Verified · cmc
cmc <hello@cleberg.net> · 2026-11-21 09:56 UTC
Keep relative org-agenda-files entries on iOS import
Layout: unified · split
Sources/OrgApp/EmacsImport.swift
+8 −2
| @@ -1096,8 +1096,9 @@ extension EmacsImport { |
| 1096 | } |
1096 | } |
| 1097 | |
1097 | |
| 1098 | /// `org-agenda-files` (one path a line) with each path below a folder in `chosenFolders` moved |
1098 | /// `org-agenda-files` (one path a line) with each path below a folder in `chosenFolders` moved |
| 1099 | /// to the folder chosen for it. Paths with no chosen folder that don't exist here are left |
1099 | /// to the folder chosen for it. Relative paths are kept as written; they count from the first |
| 1100 | /// out; nil when none remain. With `keepingOriginals`, for a config.toml the Mac reads too, |
1100 | /// folder, standing in for `org-directory`. Other paths with no chosen folder that don't exist |
| |
1101 | /// here are left out; nil when none remain. With `keepingOriginals`, for a config.toml the Mac reads too, |
| 1101 | /// the Mac's paths are all kept, a moved one beside its new path; each device skips the paths |
1102 | /// the Mac's paths are all kept, a moved one beside its new path; each device skips the paths |
| 1102 | /// it doesn't have. |
1103 | /// it doesn't have. |
| 1103 | static func agendaFiles(_ list: String, chosenFolders: [String: URL], keepingOriginals: Bool = false) -> String? { |
1104 | static func agendaFiles(_ list: String, chosenFolders: [String: URL], keepingOriginals: Bool = false) -> String? { |
| @@ -1105,6 +1106,11 @@ extension EmacsImport { |
| 1105 | let folders = chosenFolders.map { (standard($0.key), $0.value.standardizedFileURL.path) }.sorted { $0.0.count > $1.0.count } |
1106 | let folders = chosenFolders.map { (standard($0.key), $0.value.standardizedFileURL.path) }.sorted { $0.0.count > $1.0.count } |
| 1106 | var here: [String] = [], all: [String] = [] |
1107 | var here: [String] = [], all: [String] = [] |
| 1107 | for path in list.split(separator: "\n").map(String.init) { |
1108 | for path in list.split(separator: "\n").map(String.init) { |
| |
1109 | guard OrgPaths.expandingTilde(path).hasPrefix("/") else { |
| |
1110 | here.append(path) |
| |
1111 | all.append(path) |
| |
1112 | continue |
| |
1113 | } |
| 1108 | let full = standard(path) |
1114 | let full = standard(path) |
| 1109 | if let (mac, device) = folders.first(where: { full == $0.0 || full.hasPrefix($0.0 + "/") }) { |
1115 | if let (mac, device) = folders.first(where: { full == $0.0 || full.hasPrefix($0.0 + "/") }) { |
| 1110 | let moved = device + full.dropFirst(mac.count) |
1116 | let moved = device + full.dropFirst(mac.count) |
Tests/OrgAppTests/EmacsImportFoldersTests.swift
+4
| @@ -52,6 +52,10 @@ struct EmacsImportFoldersTests { |
| 52 | // A config.toml the Mac reads too keeps the Mac's paths beside the device's. |
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) |
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") |
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, "": picked.url]) == "work.org") |
| |
58 | #expect(EmacsImport.agendaFiles("work.org\n\(mac)/inbox.org", chosenFolders: [mac: picked.url]) == "work.org\n\(dir)/inbox.org") |
| 55 | } |
59 | } |
| 56 | |
60 | |
| 57 | @Test func withoutChosenFoldersAddsWhatsWritten() async throws { |
61 | @Test func withoutChosenFoldersAddsWhatsWritten() async throws { |
docs/manual/guide/14-ios.org
+1 −1
| @@ -393,7 +393,7 @@ Import from Emacs reads an Emacs or Doom configuration folder, such as a synced |
| 393 | |
393 | |
| 394 | With 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. |
394 | With 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 | |
395 | |
| 396 | Folders 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. 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. |
396 | Folders 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=. 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. |
| 397 | |
397 | |
| 398 | The Agenda, TODO Dependencies, Calendar and Reminders sections are the only places the app changes a setting itself, besides Import from Emacs: |
398 | The Agenda, TODO Dependencies, Calendar and Reminders sections are the only places the app changes a setting itself, besides Import from Emacs: |
| 399 | |
399 | |