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 {
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 }
Tests/OrgAppTests/EmacsImportFoldersTests.swift +13 −1
@@ -54,10 +54,22 @@ struct EmacsImportFoldersTests {
5454 #expect(shared == "\(mac)/inbox.org\n\(dir)/inbox.org\n\(other)/b.org")
5555
5656 // 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")
5858 #expect(EmacsImport.agendaFiles("work.org\n\(mac)/inbox.org", chosenFolders: [mac: picked.url]) == "work.org\n\(dir)/inbox.org")
5959 }
6060
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
6173 @Test func withoutChosenFoldersAddsWhatsWritten() async throws {
6274 let notes = try Folder()
6375 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
393393
394394With 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.
395395
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=. 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.
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.
397397
398398The Agenda, TODO Dependencies, Calendar and Reminders sections are the only places the app changes a setting itself, besides Import from Emacs:
399399