Commit 6cb60eeae9
6cb60eeae9a3e515290559d05b56070de7190124
parent: 7b8e9c5338
Verified · cmc
cmc <hello@cleberg.net> · 2026-11-21 11:19 UTC
Add no folder for relative org-agenda-files entries
Layout: unified · split
Sources/OrgApp/EmacsImport.swift
+2 −1
| @@ -762,7 +762,8 @@ public struct EmacsImport: Sendable { |
| 762 | add(name, .string(paths.joined(separator: "\n"))) |
762 | add(name, .string(paths.joined(separator: "\n"))) |
| 763 | // A file listing the files (the variable's string form) gives no folder. |
763 | // A file listing the files (the variable's string form) gives no folder. |
| 764 | if value.string != nil, !paths[0].hasSuffix(".org") { return } |
764 | 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("/") { |
| 766 | let folder = path.hasSuffix(".org") ? (path as NSString).deletingLastPathComponent : path |
767 | let folder = path.hasSuffix(".org") ? (path as NSString).deletingLastPathComponent : path |
| 767 | items.append(Item(id: id(), name: name, summary: "add folder \(folder)", source: source, change: .folder(folder))) |
768 | items.append(Item(id: id(), name: name, summary: "add folder \(folder)", source: source, change: .folder(folder))) |
| 768 | } |
769 | } |
Tests/OrgAppTests/EmacsImportFoldersTests.swift
+13 −1
| @@ -54,10 +54,22 @@ struct EmacsImportFoldersTests { |
| 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 | |
55 | |
| 56 | // Relative paths count from org-directory, so they're kept as written. |
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") |
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") |
58 | #expect(EmacsImport.agendaFiles("work.org\n\(mac)/inbox.org", chosenFolders: [mac: picked.url]) == "work.org\n\(dir)/inbox.org") |
| 59 | } |
59 | } |
| 60 | |
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 | |
| 61 | @Test func withoutChosenFoldersAddsWhatsWritten() async throws { |
73 | @Test func withoutChosenFoldersAddsWhatsWritten() async throws { |
| 62 | let notes = try Folder() |
74 | let notes = try Folder() |
| 63 | let config = try Folder() |
75 | let config = try Folder() |
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. 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. |
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=; 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. |
| 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 | |