Commit f10bcc641f
Verified · cmc
Layout: unified · split
Sources/OrgApp/EmacsImport.swift +55 −10
| @@ -55,6 +55,8 @@ public struct EmacsImport: Sendable { | |||
| 55 | /// Doom's own org defaults Orgstar has no use for, not listed one by one. | 55 | /// Doom's own org defaults Orgstar has no use for, not listed one by one. |
| 56 | public var doomDefaultsLeftOut = 0 | 56 | public var doomDefaultsLeftOut = 0 |
| 57 | public var isDoom = false | 57 | public var isDoom = false |
| 58 | /// Doom's own org defaults were found and read. | ||
| 59 | public var doomDefaultsRead = false | ||
| 58 | 60 | ||
| 59 | // MARK: - Finding the configuration | 61 | // MARK: - Finding the configuration |
| 60 | 62 | ||
| @@ -80,6 +82,19 @@ public struct EmacsImport: Sendable { | |||
| 80 | return candidates.filter { !files(in: $0).isEmpty && !isDoomInstall($0) } | 82 | return candidates.filter { !files(in: $0).isEmpty && !isDoomInstall($0) } |
| 81 | } | 83 | } |
| 82 | 84 | ||
| 85 | /// Where an open panel for the configuration starts: the first configuration found, or the | ||
| 86 | /// home folder. | ||
| 87 | public static func pickerLocation() -> URL { | ||
| 88 | defaultLocations().first ?? URL(fileURLWithPath: OrgPaths.home) | ||
| 89 | } | ||
| 90 | |||
| 91 | /// Where Doom is usually installed, `EMACSDIR` first. | ||
| 92 | public static func doomInstallLocations() -> [URL] { | ||
| 93 | let home = URL(fileURLWithPath: OrgPaths.home) | ||
| 94 | return [ProcessInfo.processInfo.environment["EMACSDIR"]].compactMap { $0 }.map { URL(fileURLWithPath: $0) } | ||
| 95 | + [".config/emacs", ".emacs.d"].map { home.appendingPathComponent($0) } | ||
| 96 | } | ||
| 97 | |||
| 83 | /// Doom's own source folder, which holds `lisp/doom.el`, isn't a user configuration. | 98 | /// Doom's own source folder, which holds `lisp/doom.el`, isn't a user configuration. |
| 84 | static func isDoomInstall(_ url: URL) -> Bool { | 99 | static func isDoomInstall(_ url: URL) -> Bool { |
| 85 | FileManager.default.fileExists(atPath: url.appendingPathComponent("lisp/doom.el").path) | 100 | FileManager.default.fileExists(atPath: url.appendingPathComponent("lisp/doom.el").path) |
| @@ -87,11 +102,13 @@ public struct EmacsImport: Sendable { | |||
| 87 | 102 | ||
| 88 | /// Doom's org module and core defaults, if Doom is installed. | 103 | /// Doom's org module and core defaults, if Doom is installed. |
| 89 | static func doomDefaultFiles() -> [URL] { | 104 | static func doomDefaultFiles() -> [URL] { |
| 90 | let home = URL(fileURLWithPath: OrgPaths.home) | 105 | guard let install = doomInstallLocations().first(where: isDoomInstall) else { return [] } |
| 91 | let environment = ProcessInfo.processInfo.environment | 106 | return doomDefaultFiles(in: install) |
| 92 | let installs = ([environment["EMACSDIR"]].compactMap { $0 }.map { URL(fileURLWithPath: $0) }) | 107 | } |
| 93 | + [".config/emacs", ".emacs.d"].map { home.appendingPathComponent($0) } | 108 | |
| 94 | guard let install = installs.first(where: isDoomInstall) else { return [] } | 109 | /// Doom's org module and core defaults in `install`, Doom's own folder; empty when it isn't one. |
| 110 | public static func doomDefaultFiles(in install: URL) -> [URL] { | ||
| 111 | guard isDoomInstall(install) else { return [] } | ||
| 95 | var files = [install.appendingPathComponent("lisp/doom-emacs.el")] | 112 | var files = [install.appendingPathComponent("lisp/doom-emacs.el")] |
| 96 | var moduleRoots = [install.appendingPathComponent("modules")] | 113 | var moduleRoots = [install.appendingPathComponent("modules")] |
| 97 | if let sources = try? FileManager.default.contentsOfDirectory(at: install.appendingPathComponent("sources"), includingPropertiesForKeys: nil) { | 114 | if let sources = try? FileManager.default.contentsOfDirectory(at: install.appendingPathComponent("sources"), includingPropertiesForKeys: nil) { |
| @@ -119,7 +136,10 @@ public struct EmacsImport: Sendable { | |||
| 119 | result.isDoom = sources.contains { $0.text.contains("(doom!") || $0.text.contains("(map! ") || $0.text.contains("(after! ") } | 136 | result.isDoom = sources.contains { $0.text.contains("(doom!") || $0.text.contains("(map! ") || $0.text.contains("(after! ") } |
| 120 | if result.isDoom { | 137 | if result.isDoom { |
| 121 | for url in doomDefaults ?? doomDefaultFiles() { | 138 | for url in doomDefaults ?? doomDefaultFiles() { |
| 122 | if let text = try? String(contentsOf: url, encoding: .utf8) { sources.insert(("Doom", text, 0), at: 0) } | 139 | if let text = try? String(contentsOf: url, encoding: .utf8) { |
| 140 | sources.insert(("Doom", text, 0), at: 0) | ||
| 141 | result.doomDefaultsRead = true | ||
| 142 | } | ||
| 123 | } | 143 | } |
| 124 | } | 144 | } |
| 125 | var scanner = Scanner() | 145 | var scanner = Scanner() |
| @@ -1064,16 +1084,33 @@ public struct EmacsImport: Sendable { | |||
| 1064 | } | 1084 | } |
| 1065 | 1085 | ||
| 1066 | extension EmacsImport { | 1086 | extension EmacsImport { |
| 1087 | /// The paths of `items`' folders that aren't in the sidebar yet, as written. | ||
| 1088 | @MainActor | ||
| 1089 | public static func foldersToAdd(_ items: [Item], workspace: WorkspaceModel?) -> [String] { | ||
| 1090 | items.compactMap { item in | ||
| 1091 | guard case .folder(let path) = item.change else { return nil } | ||
| 1092 | let url = URL(fileURLWithPath: OrgPaths.expandingTilde(path)).standardizedFileURL | ||
| 1093 | if let workspace, isRoot(url, in: workspace) { return nil } | ||
| 1094 | return path | ||
| 1095 | } | ||
| 1096 | } | ||
| 1097 | |||
| 1098 | @MainActor | ||
| 1099 | static func isRoot(_ url: URL, in workspace: WorkspaceModel) -> Bool { | ||
| 1100 | workspace.roots.contains { URL(fileURLWithPath: $0.path).standardizedFileURL.path == url.path } | ||
| 1101 | } | ||
| 1102 | |||
| 1067 | /// Applies `items`: settings to `defaults` (and so config.toml), folders to the workspace, | 1103 | /// Applies `items`: settings to `defaults` (and so config.toml), folders to the workspace, |
| 1068 | /// capture templates and key bindings appended to capture.toml and keymap.toml in | 1104 | /// capture templates and key bindings appended to capture.toml and keymap.toml in |
| 1069 | /// `directory`, leaving out templates whose key is there already and bindings that are | 1105 | /// `directory`, leaving out templates whose key is there already and bindings that are |
| 1070 | /// there already. Returns a summary. | 1106 | /// there already. Returns a summary. |
| 1071 | @MainActor | 1107 | @MainActor |
| 1072 | /// With `writeConfig`, settings and structure templates are written into `config.toml` too, | 1108 | /// With `writeConfig`, settings and structure templates are written into `config.toml` too, |
| 1073 | /// for where nothing syncs user defaults into it (iOS). | 1109 | /// for where nothing syncs user defaults into it (iOS). With `chosenFolders`, folders chosen in |
| 1110 | /// open panels by the path of their item, a folder item is added only as the folder chosen for it. | ||
| 1074 | public static func apply( | 1111 | public static func apply( |
| 1075 | _ items: [Item], defaults: UserDefaults = .standard, workspace: WorkspaceModel?, directory: URL = UserConfig.directory, | 1112 | _ items: [Item], defaults: UserDefaults = .standard, workspace: WorkspaceModel?, directory: URL = UserConfig.directory, |
| 1076 | writeConfig: Bool = false | 1113 | writeConfig: Bool = false, chosenFolders: [String: URL]? = nil |
| 1077 | ) async -> String { | 1114 | ) async -> String { |
| 1078 | var stored: [UserConfig.Setting] = [] | 1115 | var stored: [UserConfig.Setting] = [] |
| 1079 | var settings = 0, folders = 0, templates = 0, bindings = 0, blocks = 0, views = 0, projects = 0 | 1116 | var settings = 0, folders = 0, templates = 0, bindings = 0, blocks = 0, views = 0, projects = 0 |
| @@ -1090,12 +1127,20 @@ extension EmacsImport { | |||
| 1090 | } | 1127 | } |
| 1091 | for item in items { | 1128 | for item in items { |
| 1092 | guard case .folder(let path) = item.change else { continue } | 1129 | guard case .folder(let path) = item.change else { continue } |
| 1093 | let url = URL(fileURLWithPath: OrgPaths.expandingTilde(path)).standardizedFileURL | 1130 | var url = URL(fileURLWithPath: OrgPaths.expandingTilde(path)).standardizedFileURL |
| 1131 | if let chosenFolders { | ||
| 1132 | if let workspace, Self.isRoot(url, in: workspace) { continue } | ||
| 1133 | guard let chosen = chosenFolders[path] else { | ||
| 1134 | problems.append("\(path) wasn't added") | ||
| 1135 | continue | ||
| 1136 | } | ||
| 1137 | url = chosen.standardizedFileURL | ||
| 1138 | } | ||
| 1094 | guard let workspace, FileManager.default.fileExists(atPath: url.path) else { | 1139 | guard let workspace, FileManager.default.fileExists(atPath: url.path) else { |
| 1095 | problems.append("\(path) doesn't exist") | 1140 | problems.append("\(path) doesn't exist") |
| 1096 | continue | 1141 | continue |
| 1097 | } | 1142 | } |
| 1098 | if workspace.roots.contains(where: { URL(fileURLWithPath: $0.path).standardizedFileURL.path == url.path }) { continue } | 1143 | if Self.isRoot(url, in: workspace) { continue } |
| 1099 | do { | 1144 | do { |
| 1100 | try await workspace.addRoot(url) | 1145 | try await workspace.addRoot(url) |
| 1101 | folders += 1 | 1146 | folders += 1 |
Sources/OrgApp/WorkspaceModel.swift +16
| @@ -31,6 +31,9 @@ public final class WorkspaceModel { | |||
| 31 | private let rootsFile: URL | 31 | private let rootsFile: URL |
| 32 | /// Resolved root folders, keyed by their resolved path, which is how the index stores them. | 32 | /// Resolved root folders, keyed by their resolved path, which is how the index stores them. |
| 33 | private var resolvedRoots: [String: URL] = [:] | 33 | private var resolvedRoots: [String: URL] = [:] |
| 34 | /// Roots whose bookmark doesn't resolve: a folder gone, on a volume not mounted, or out of | ||
| 35 | /// the sandbox's reach. | ||
| 36 | public private(set) var unresolvedRoots: [WorkspaceRoot] = [] | ||
| 34 | @ObservationIgnored private var watcher: AnyObject? | 37 | @ObservationIgnored private var watcher: AnyObject? |
| 35 | /// Watchers of the roots where there are no FSEvents. | 38 | /// Watchers of the roots where there are no FSEvents. |
| 36 | @ObservationIgnored private var presenters: [FolderPresenter] = [] | 39 | @ObservationIgnored private var presenters: [FolderPresenter] = [] |
| @@ -92,6 +95,17 @@ public final class WorkspaceModel { | |||
| 92 | await refresh() | 95 | await refresh() |
| 93 | } | 96 | } |
| 94 | 97 | ||
| 98 | /// Replaces `root`, one that doesn't resolve, with `url`, chosen again in an open panel. | ||
| 99 | public func regrant(_ root: WorkspaceRoot, with url: URL) async throws { | ||
| 100 | let fresh = try WorkspaceRoot(url: url) | ||
| 101 | roots.removeAll { $0 == root } | ||
| 102 | if !roots.contains(where: { $0.path == fresh.path }), resolvedRoots[fresh.path] == nil { roots.append(fresh) } | ||
| 103 | try saveRoots() | ||
| 104 | resolveRoots() | ||
| 105 | rootsChanged() | ||
| 106 | await refresh() | ||
| 107 | } | ||
| 108 | |||
| 95 | /// Removes a root by its resolved path, as `FileEntry.root` gives it. | 109 | /// Removes a root by its resolved path, as `FileEntry.root` gives it. |
| 96 | public func removeRoot(path: String) throws { | 110 | public func removeRoot(path: String) throws { |
| 97 | let bookmarkPaths = roots.filter { (try? $0.resolve().url.path) == path || $0.path == path }.map(\.path) | 111 | let bookmarkPaths = roots.filter { (try? $0.resolve().url.path) == path || $0.path == path }.map(\.path) |
| @@ -116,10 +130,12 @@ public final class WorkspaceModel { | |||
| 116 | /// Resolves bookmarks; refreshes stale ones; reports folders that can't be found. | 130 | /// Resolves bookmarks; refreshes stale ones; reports folders that can't be found. |
| 117 | private func resolveRoots() { | 131 | private func resolveRoots() { |
| 118 | resolvedRoots = [:] | 132 | resolvedRoots = [:] |
| 133 | unresolvedRoots = [] | ||
| 119 | var refreshed = roots | 134 | var refreshed = roots |
| 120 | for (i, root) in roots.enumerated() { | 135 | for (i, root) in roots.enumerated() { |
| 121 | guard let (url, isStale) = try? root.resolve() else { | 136 | guard let (url, isStale) = try? root.resolve() else { |
| 122 | lastError = "Can't find the folder \(root.path)." | 137 | lastError = "Can't find the folder \(root.path)." |
| 138 | unresolvedRoots.append(root) | ||
| 123 | continue | 139 | continue |
| 124 | } | 140 | } |
| 125 | if isStale, let fresh = try? WorkspaceRoot(url: url) { refreshed[i] = fresh } | 141 | if isStale, let fresh = try? WorkspaceRoot(url: url) { refreshed[i] = fresh } |
Sources/Orgstar/ContentView.swift +17 −4
| @@ -183,15 +183,25 @@ struct ContentView: View { | |||
| 183 | } | 183 | } |
| 184 | } else { | 184 | } else { |
| 185 | ContentUnavailableView { | 185 | ContentUnavailableView { |
| 186 | Label(workspace.roots.isEmpty ? "Add a folder of org files" : "Choose a file", systemImage: "doc.text") | 186 | Label(noFolders ? "Add a folder of org files" : "Choose a file", systemImage: "doc.text") |
| 187 | } description: { | 187 | } description: { |
| 188 | Text(workspace.roots.isEmpty ? "File ▸ Add Folder… (⇧⌘O)" : "Or press ⌘P to open one by name.") | 188 | Text(noFolders ? "File ▸ Add Folder… (⇧⌘O)" : "Or press ⌘P to open one by name.") |
| 189 | } actions: { | 189 | } actions: { |
| 190 | if workspace.roots.isEmpty { Button("Get Started…") { commands.showingWelcome = true } } | 190 | if noFolders { Button("Get Started…") { commands.showingWelcome = true } } |
| 191 | } | 191 | } |
| 192 | } | 192 | } |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | /// No folder to show: in the App Store build, also when none of them resolves, so the | ||
| 196 | /// welcome sheet can ask for them again. | ||
| 197 | private var noFolders: Bool { | ||
| 198 | #if APPSTORE | ||
| 199 | workspace.rootPaths.isEmpty | ||
| 200 | #else | ||
| 201 | workspace.roots.isEmpty | ||
| 202 | #endif | ||
| 203 | } | ||
| 204 | |||
| 195 | @ToolbarContentBuilder | 205 | @ToolbarContentBuilder |
| 196 | private var toolbarItems: some ToolbarContent { | 206 | private var toolbarItems: some ToolbarContent { |
| 197 | ToolbarItem(placement: .navigation) { | 207 | ToolbarItem(placement: .navigation) { |
| @@ -303,6 +313,9 @@ struct ContentView: View { | |||
| 303 | commands.externalHandler = runExternal | 313 | commands.externalHandler = runExternal |
| 304 | commands.filesHandler = { attachActions.drop($0) } | 314 | commands.filesHandler = { attachActions.drop($0) } |
| 305 | commands.imageHandler = { attachActions.yankImage($0, ext: $1) } | 315 | commands.imageHandler = { attachActions.yankImage($0, ext: $1) } |
| 316 | #if APPSTORE | ||
| 317 | commands.reach = { [workspace] in GrantAccess.reach($0, workspace: workspace) } | ||
| 318 | #endif | ||
| 306 | // `org-clock-out-when-done`, and the notification when the Effort runs out. | 319 | // `org-clock-out-when-done`, and the notification when the Effort runs out. |
| 307 | clock.notifications = SystemReminderCenter.isAvailable ? SystemReminderCenter() : nil | 320 | clock.notifications = SystemReminderCenter.isAvailable ? SystemReminderCenter() : nil |
| 308 | session.textChanged = { [weak session, weak clock, weak commands] path in | 321 | session.textChanged = { [weak session, weak clock, weak commands] path in |
| @@ -312,7 +325,7 @@ struct ContentView: View { | |||
| 312 | clock.remindAtEffort(session) | 325 | clock.remindAtEffort(session) |
| 313 | commands.knownTags = { [index = workspace.index] in (try? index.tags()) ?? [] } | 326 | commands.knownTags = { [index = workspace.index] in (try? index.tags()) ?? [] } |
| 314 | commands.mainWindowOpen = true | 327 | commands.mainWindowOpen = true |
| 315 | if workspace.roots.isEmpty, !welcomeShown { | 328 | if noFolders, !welcomeShown { |
| 316 | welcomeShown = true | 329 | welcomeShown = true |
| 317 | commands.showingWelcome = true | 330 | commands.showingWelcome = true |
| 318 | } | 331 | } |
Sources/Orgstar/EmacsImportView.swift +72 −4
| @@ -12,6 +12,8 @@ struct EmacsImportView: View { | |||
| 12 | @State private var choosing = false | 12 | @State private var choosing = false |
| 13 | @State private var summary: String? | 13 | @State private var summary: String? |
| 14 | @State private var importing = false | 14 | @State private var importing = false |
| 15 | /// Doom's own folder, chosen in the App Store build, where the sandbox can't find it. | ||
| 16 | @State private var doomInstall: URL? | ||
| 15 | 17 | ||
| 16 | var body: some View { | 18 | var body: some View { |
| 17 | VStack(alignment: .leading, spacing: 0) { | 19 | VStack(alignment: .leading, spacing: 0) { |
| @@ -46,7 +48,7 @@ struct EmacsImportView: View { | |||
| 46 | .onAppear { | 48 | .onAppear { |
| 47 | // The sandbox can't look in the home folder, so the App Store build starts with the picker. | 49 | // The sandbox can't look in the home folder, so the App Store build starts with the picker. |
| 48 | #if APPSTORE | 50 | #if APPSTORE |
| 49 | if location == nil { choosing = true } | 51 | if location == nil { DispatchQueue.main.async { choose() } } |
| 50 | #else | 52 | #else |
| 51 | if location == nil, let first = EmacsImport.defaultLocations().first { read(first) } | 53 | if location == nil, let first = EmacsImport.defaultLocations().first { read(first) } |
| 52 | #endif | 54 | #endif |
| @@ -60,15 +62,69 @@ struct EmacsImportView: View { | |||
| 60 | HStack { | 62 | HStack { |
| 61 | VStack(alignment: .leading, spacing: 2) { | 63 | VStack(alignment: .leading, spacing: 2) { |
| 62 | Text("Import from Emacs").font(.headline) | 64 | Text("Import from Emacs").font(.headline) |
| 63 | Text(location.map { "Reading \($0.path)" + ((result?.isDoom ?? false) ? ", with Doom's own org defaults" : "") } ?? "") | 65 | Text(location.map { "Reading \($0.path)" + (withDoomDefaults ? ", with Doom's own org defaults" : "") } ?? "") |
| 64 | .font(.caption).foregroundStyle(.secondary).lineLimit(2) | 66 | .font(.caption).foregroundStyle(.secondary).lineLimit(2) |
| 65 | } | 67 | } |
| 66 | Spacer() | 68 | Spacer() |
| 67 | Button("Choose…") { choosing = true } | 69 | #if APPSTORE |
| 70 | if let result, result.isDoom, !result.doomDefaultsRead { | ||
| 71 | Button("Choose Doom Folder…") { chooseDoom() } | ||
| 72 | .help("Doom's own org defaults are read from the folder Doom is installed in") | ||
| 73 | } | ||
| 74 | #endif | ||
| 75 | Button("Choose…") { choose() } | ||
| 68 | } | 76 | } |
| 69 | .padding(12) | 77 | .padding(12) |
| 70 | } | 78 | } |
| 71 | 79 | ||
| 80 | private var withDoomDefaults: Bool { | ||
| 81 | #if APPSTORE | ||
| 82 | result?.doomDefaultsRead ?? false | ||
| 83 | #else | ||
| 84 | result?.isDoom ?? false | ||
| 85 | #endif | ||
| 86 | } | ||
| 87 | |||
| 88 | private func choose() { | ||
| 89 | #if APPSTORE | ||
| 90 | let message = String(localized: "Choose your init.el, or the folder holding it (~/.emacs.d, ~/.config/doom).", | ||
| 91 | comment: "Open panel for importing an Emacs configuration") | ||
| 92 | if let url = GrantAccess.choose(at: EmacsImport.pickerLocation(), message: message, prompt: String(localized: "Choose"), files: true, hidden: true) { | ||
| 93 | read(url) | ||
| 94 | } | ||
| 95 | #else | ||
| 96 | choosing = true | ||
| 97 | #endif | ||
| 98 | } | ||
| 99 | |||
| 100 | #if APPSTORE | ||
| 101 | /// Doom's install folder, for its org defaults; the sandbox keeps orgstar from finding it. | ||
| 102 | private func chooseDoom() { | ||
| 103 | let message = String(localized: "Choose the folder Doom is installed in (~/.config/emacs or ~/.emacs.d) to read Doom's own org defaults.", | ||
| 104 | comment: "Open panel for Doom's install folder when importing from Emacs") | ||
| 105 | guard let install = EmacsImport.doomInstallLocations().first, | ||
| 106 | let url = GrantAccess.choose(at: install, message: message, prompt: String(localized: "Choose"), hidden: true), | ||
| 107 | let location else { return } | ||
| 108 | doomInstall = url | ||
| 109 | read(location) | ||
| 110 | } | ||
| 111 | |||
| 112 | /// Asks for each folder the import adds, with an open panel at it, and adds the folders | ||
| 113 | /// chosen there: the sandbox lets orgstar into those alone. | ||
| 114 | private func chooseFolders(_ items: [EmacsImport.Item]) -> [String: URL] { | ||
| 115 | var chosen: [String: URL] = [:] | ||
| 116 | for path in EmacsImport.foldersToAdd(items, workspace: workspace) where chosen[path] == nil { | ||
| 117 | let name = OrgPaths.abbreviatingWithTilde(OrgPaths.expandingTilde(path)) | ||
| 118 | let message = String(localized: "Choose \(name) to add it to the sidebar.", comment: "Open panel for a folder imported from Emacs") | ||
| 119 | if let url = GrantAccess.choose(at: URL(fileURLWithPath: OrgPaths.expandingTilde(path)), message: message, | ||
| 120 | prompt: String(localized: "Add Folder")) { | ||
| 121 | chosen[path] = url | ||
| 122 | } | ||
| 123 | } | ||
| 124 | return chosen | ||
| 125 | } | ||
| 126 | #endif | ||
| 127 | |||
| 72 | private func list(_ result: EmacsImport) -> some View { | 128 | private func list(_ result: EmacsImport) -> some View { |
| 73 | List { | 129 | List { |
| 74 | EmacsImportSections(result: result, groups: result.groups(folders: true), selected: $selected, | 130 | EmacsImportSections(result: result, groups: result.groups(folders: true), selected: $selected, |
| @@ -79,6 +135,9 @@ struct EmacsImportView: View { | |||
| 79 | private func footnote(_ result: EmacsImport) -> String { | 135 | private func footnote(_ result: EmacsImport) -> String { |
| 80 | var parts = ["\(result.skipped) variables not about org left alone"] | 136 | var parts = ["\(result.skipped) variables not about org left alone"] |
| 81 | if result.doomDefaultsLeftOut > 0 { parts.append("\(result.doomDefaultsLeftOut) Doom defaults orgstar has no use for") } | 137 | if result.doomDefaultsLeftOut > 0 { parts.append("\(result.doomDefaultsLeftOut) Doom defaults orgstar has no use for") } |
| 138 | #if APPSTORE | ||
| 139 | if result.isDoom, !result.doomDefaultsRead { parts.append("Doom's own org defaults skipped") } | ||
| 140 | #endif | ||
| 82 | return parts.joined(separator: "; ") | 141 | return parts.joined(separator: "; ") |
| 83 | } | 142 | } |
| 84 | 143 | ||
| @@ -86,7 +145,11 @@ struct EmacsImportView: View { | |||
| 86 | let accessing = url.startAccessingSecurityScopedResource() | 145 | let accessing = url.startAccessingSecurityScopedResource() |
| 87 | defer { if accessing { url.stopAccessingSecurityScopedResource() } } | 146 | defer { if accessing { url.stopAccessingSecurityScopedResource() } } |
| 88 | location = url | 147 | location = url |
| 148 | #if APPSTORE | ||
| 149 | let scanned = EmacsImport.scan(EmacsImport.files(in: url), doomDefaults: doomInstall.map(EmacsImport.doomDefaultFiles(in:))) | ||
| 150 | #else | ||
| 89 | let scanned = EmacsImport.scan(EmacsImport.files(in: url)) | 151 | let scanned = EmacsImport.scan(EmacsImport.files(in: url)) |
| 152 | #endif | ||
| 90 | result = scanned | 153 | result = scanned |
| 91 | selected = Set(scanned.items.map(\.id)) | 154 | selected = Set(scanned.items.map(\.id)) |
| 92 | summary = nil | 155 | summary = nil |
| @@ -96,8 +159,13 @@ struct EmacsImportView: View { | |||
| 96 | guard let result else { return } | 159 | guard let result else { return } |
| 97 | importing = true | 160 | importing = true |
| 98 | let chosen = result.items.filter { selected.contains($0.id) } | 161 | let chosen = result.items.filter { selected.contains($0.id) } |
| 162 | #if APPSTORE | ||
| 163 | let folders: [String: URL]? = chooseFolders(chosen) | ||
| 164 | #else | ||
| 165 | let folders: [String: URL]? = nil | ||
| 166 | #endif | ||
| 99 | Task { | 167 | Task { |
| 100 | summary = await EmacsImport.apply(chosen, workspace: workspace) | 168 | summary = await EmacsImport.apply(chosen, workspace: workspace, chosenFolders: folders) |
| 101 | importing = false | 169 | importing = false |
| 102 | } | 170 | } |
| 103 | } | 171 | } |
Sources/Orgstar/GrantAccess.swift +28 −7
| @@ -2,6 +2,7 @@ | |||
| 2 | import AppKit | 2 | import AppKit |
| 3 | import OrgApp | 3 | import OrgApp |
| 4 | import OrgCore | 4 | import OrgCore |
| 5 | import OrgWorkspace | ||
| 5 | 6 | ||
| 6 | /// Access to folders outside the sidebar's folders, which the sandbox keeps orgstar out of | 7 | /// Access to folders outside the sidebar's folders, which the sandbox keeps orgstar out of |
| 7 | /// until they're chosen in an open panel. | 8 | /// until they're chosen in an open panel. |
| @@ -27,16 +28,36 @@ enum GrantAccess { | |||
| 27 | case .alertSecondButtonReturn where alternative != nil: return .alternative | 28 | case .alertSecondButtonReturn where alternative != nil: return .alternative |
| 28 | default: return .canceled | 29 | default: return .canceled |
| 29 | } | 30 | } |
| 31 | guard let url = choose(at: folder, message: String(localized: "Choose \(name) or a folder that contains it.", comment: "Open panel for giving orgstar access to a folder"), | ||
| 32 | prompt: String(localized: "Grant Access", comment: "Open panel button that gives orgstar access to a folder")) else { return .canceled } | ||
| 33 | FolderGrants.shared.add(url) | ||
| 34 | return workspace.foldersToGrant(for: [folder.path], directories: true).isEmpty ? .granted : .canceled | ||
| 35 | } | ||
| 36 | |||
| 37 | /// An open panel at `location`, for a folder, or a file too with `files`. Hidden files show | ||
| 38 | /// with `hidden`, for dot folders such as `~/.config`. | ||
| 39 | static func choose(at location: URL, message: String, prompt: String, files: Bool = false, hidden: Bool = false) -> URL? { | ||
| 30 | let panel = NSOpenPanel() | 40 | let panel = NSOpenPanel() |
| 31 | panel.canChooseDirectories = true | 41 | panel.canChooseDirectories = true |
| 32 | panel.canChooseFiles = false | 42 | panel.canChooseFiles = files |
| 33 | panel.canCreateDirectories = true | 43 | panel.canCreateDirectories = true |
| 34 | panel.directoryURL = folder | 44 | panel.showsHiddenFiles = hidden |
| 35 | panel.prompt = String(localized: "Grant Access", comment: "Open panel button that gives orgstar access to a folder") | 45 | panel.directoryURL = location |
| 36 | panel.message = String(localized: "Choose \(name) or a folder that contains it.", comment: "Open panel for giving orgstar access to a folder") | 46 | panel.prompt = prompt |
| 37 | guard panel.runModal() == .OK, let url = panel.url else { return .canceled } | 47 | panel.message = message |
| 38 | FolderGrants.shared.add(url) | 48 | return panel.runModal() == .OK ? panel.url : nil |
| 39 | return workspace.foldersToGrant(for: [folder.path], directories: true).isEmpty ? .granted : .canceled | 49 | } |
| 50 | |||
| 51 | /// Asks again for `root`, a sidebar folder that doesn't resolve, with an open panel at where | ||
| 52 | /// it was, and puts the folder chosen in its place. | ||
| 53 | static func regrant(_ root: WorkspaceRoot, workspace: WorkspaceModel) { | ||
| 54 | let name = OrgPaths.abbreviatingWithTilde(root.path) | ||
| 55 | guard let url = choose(at: URL(fileURLWithPath: root.path), | ||
| 56 | message: String(localized: "Choose \(name) to give orgstar access to it again.", comment: "Open panel for a sidebar folder orgstar can't open"), | ||
| 57 | prompt: String(localized: "Grant Access", comment: "Open panel button that gives orgstar access to a folder")) else { return } | ||
| 58 | Task { | ||
| 59 | do { try await workspace.regrant(root, with: url) } catch { workspace.lastError = error.localizedDescription } | ||
| 60 | } | ||
| 40 | } | 61 | } |
| 41 | 62 | ||
| 42 | /// Asks for each folder `paths` need, in turn. Whether all of them can now be reached. | 63 | /// Asks for each folder `paths` need, in turn. Whether all of them can now be reached. |
Sources/Orgstar/LinkOpener.swift +5
| @@ -8,6 +8,11 @@ enum LinkOpener { | |||
| 8 | /// Returns a message when the link can't be followed. | 8 | /// Returns a message when the link can't be followed. |
| 9 | /// `ask` picks among a query link's matches. | 9 | /// `ask` picks among a query link's matches. |
| 10 | static func open(_ link: OrgLink, session: DocumentSession, workspace: WorkspaceModel, ask: @escaping (Prompt, @escaping (String?) -> Void) -> Void) -> String? { | 10 | static func open(_ link: OrgLink, session: DocumentSession, workspace: WorkspaceModel, ask: @escaping (Prompt, @escaping (String?) -> Void) -> Void) -> String? { |
| 11 | #if APPSTORE | ||
| 12 | // A file outside the sidebar's folders needs access to its folder first. | ||
| 13 | if link.type == "file", !link.path.isEmpty, | ||
| 14 | !GrantAccess.reach([DocumentSession.resolve(link.path, from: session.path)], workspace: workspace) { return nil } | ||
| 15 | #endif | ||
| 11 | switch session.follow(link, workspace: workspace, isText: FileTypes.isText) { | 16 | switch session.follow(link, workspace: workspace, isText: FileTypes.isText) { |
| 12 | case .shown: return nil | 17 | case .shown: return nil |
| 13 | case .openExternally(let url): | 18 | case .openExternally(let url): |
Sources/Orgstar/OrgstarApp.swift +4
| @@ -39,6 +39,10 @@ final class AppCommands { | |||
| 39 | /// Files and images pasted or dropped on an editor; the main window sets them. | 39 | /// Files and images pasted or dropped on an editor; the main window sets them. |
| 40 | var filesHandler: (([URL]) -> Void)? | 40 | var filesHandler: (([URL]) -> Void)? |
| 41 | var imageHandler: ((Data, String) -> Void)? | 41 | var imageHandler: ((Data, String) -> Void)? |
| 42 | #if APPSTORE | ||
| 43 | /// Asks for the folders outside the sidebar's folders that paths need; the main window sets it. | ||
| 44 | var reach: ([String]) -> Bool = { _ in true } | ||
| 45 | #endif | ||
| 42 | /// Tags used across the workspace, for tag completion; the main window sets it. | 46 | /// Tags used across the workspace, for tag completion; the main window sets it. |
| 43 | var knownTags: () -> [String] = { [] } | 47 | var knownTags: () -> [String] = { [] } |
| 44 | /// The pending key prefix, and what can follow it. | 48 | /// The pending key prefix, and what can follow it. |
Sources/Orgstar/PaneView.swift +3
| @@ -112,6 +112,9 @@ struct PaneView: NSViewRepresentable { | |||
| 112 | let expanded = OrgPaths.expandingTilde(typed) | 112 | let expanded = OrgPaths.expandingTilde(typed) |
| 113 | let base = URL(fileURLWithPath: path).deletingLastPathComponent() | 113 | let base = URL(fileURLWithPath: path).deletingLastPathComponent() |
| 114 | let target = expanded.hasPrefix("/") ? expanded : base.appendingPathComponent(expanded).standardizedFileURL.path | 114 | let target = expanded.hasPrefix("/") ? expanded : base.appendingPathComponent(expanded).standardizedFileURL.path |
| 115 | #if APPSTORE | ||
| 116 | guard commands?.reach([target]) ?? false else { return } | ||
| 117 | #endif | ||
| 115 | guard FileManager.default.fileExists(atPath: target) else { | 118 | guard FileManager.default.fileExists(atPath: target) else { |
| 116 | commands?.show("No file \(typed)") | 119 | commands?.show("No file \(typed)") |
| 117 | return | 120 | return |
Sources/Orgstar/Sidebar.swift +21
| @@ -49,6 +49,27 @@ struct Sidebar: View { | |||
| 49 | .contextMenu { folderMenu(root) } | 49 | .contextMenu { folderMenu(root) } |
| 50 | } | 50 | } |
| 51 | } | 51 | } |
| 52 | #if APPSTORE | ||
| 53 | if !workspace.unresolvedRoots.isEmpty { | ||
| 54 | Section("Can't Open") { | ||
| 55 | ForEach(workspace.unresolvedRoots, id: \.path) { root in | ||
| 56 | HStack { | ||
| 57 | Label((root.path as NSString).lastPathComponent, systemImage: "exclamationmark.triangle") | ||
| 58 | .foregroundStyle(.secondary) | ||
| 59 | Spacer() | ||
| 60 | Button("Grant Access…") { GrantAccess.regrant(root, workspace: workspace) } | ||
| 61 | .buttonStyle(.borderless) | ||
| 62 | .controlSize(.small) | ||
| 63 | } | ||
| 64 | .help(root.path) | ||
| 65 | .contextMenu { | ||
| 66 | Button("Grant Access…") { GrantAccess.regrant(root, workspace: workspace) } | ||
| 67 | Button("Remove from Sidebar…") { removing = root.path } | ||
| 68 | } | ||
| 69 | } | ||
| 70 | } | ||
| 71 | } | ||
| 72 | #endif | ||
| 52 | } | 73 | } |
| 53 | .listStyle(.sidebar) | 74 | .listStyle(.sidebar) |
| 54 | .themedListBackground(theme.color("sidebar-background", in: colorScheme)) | 75 | .themedListBackground(theme.color("sidebar-background", in: colorScheme)) |
Sources/Orgstar/WelcomeView.swift +30 −3
| @@ -1,5 +1,6 @@ | |||
| 1 | import OrgApp | 1 | import OrgApp |
| 2 | import OrgCore | 2 | import OrgCore |
| 3 | import OrgWorkspace | ||
| 3 | import SwiftUI | 4 | import SwiftUI |
| 4 | 5 | ||
| 5 | /// The first launch, with no folder added: add a folder or start one, and pick the keys. | 6 | /// The first launch, with no folder added: add a folder or start one, and pick the keys. |
| @@ -13,11 +14,12 @@ struct WelcomeView: View { | |||
| 13 | @State private var error: String? | 14 | @State private var error: String? |
| 14 | @Environment(\.dismiss) private var dismiss | 15 | @Environment(\.dismiss) private var dismiss |
| 15 | 16 | ||
| 17 | /// iCloud Drive's folder in the real home folder. | ||
| 18 | static let iCloudDriveFolder = URL(fileURLWithPath: OrgPaths.home).appendingPathComponent("Library/Mobile Documents/com~apple~CloudDocs") | ||
| 19 | |||
| 16 | /// iCloud Drive's folder, when iCloud Drive is on for this user. | 20 | /// iCloud Drive's folder, when iCloud Drive is on for this user. |
| 17 | static var iCloudDrive: URL? { | 21 | static var iCloudDrive: URL? { |
| 18 | let url = FileManager.default.homeDirectoryForCurrentUser | 22 | FileManager.default.fileExists(atPath: iCloudDriveFolder.path) ? iCloudDriveFolder : nil |
| 19 | .appendingPathComponent("Library/Mobile Documents/com~apple~CloudDocs") | ||
| 20 | return FileManager.default.fileExists(atPath: url.path) ? url : nil | ||
| 21 | } | 23 | } |
| 22 | 24 | ||
| 23 | var body: some View { | 25 | var body: some View { |
| @@ -28,14 +30,30 @@ struct WelcomeView: View { | |||
| 28 | ForEach(KeymapPreset.allCases, id: \.self) { Text($0.title).tag($0) } | 30 | ForEach(KeymapPreset.allCases, id: \.self) { Text($0.title).tag($0) } |
| 29 | } | 31 | } |
| 30 | Text(presetNote).font(.callout).foregroundStyle(.secondary) | 32 | Text(presetNote).font(.callout).foregroundStyle(.secondary) |
| 33 | #if APPSTORE | ||
| 34 | ForEach(workspace.unresolvedRoots, id: \.path) { root in | ||
| 35 | HStack { | ||
| 36 | Label(OrgPaths.abbreviatingWithTilde(root.path), systemImage: "exclamationmark.triangle") | ||
| 37 | .help("orgstar can't open this folder") | ||
| 38 | Spacer() | ||
| 39 | Button("Grant Access…") { GrantAccess.regrant(root, workspace: workspace) } | ||
| 40 | } | ||
| 41 | } | ||
| 42 | #endif | ||
| 31 | if let error { Text(error).foregroundStyle(.red) } | 43 | if let error { Text(error).foregroundStyle(.red) } |
| 32 | HStack { | 44 | HStack { |
| 33 | Button("Not Now") { dismiss() } | 45 | Button("Not Now") { dismiss() } |
| 34 | Spacer() | 46 | Spacer() |
| 47 | #if APPSTORE | ||
| 48 | // The sandbox reaches iCloud Drive only through a folder chosen there. | ||
| 49 | Button("New Folder in iCloud Drive…") { chooseInICloudDrive() } | ||
| 50 | .help("Makes notes.org in a folder you choose or make in iCloud Drive and adds the folder") | ||
| 51 | #else | ||
| 35 | if let drive = Self.iCloudDrive { | 52 | if let drive = Self.iCloudDrive { |
| 36 | Button("New Folder in iCloud Drive") { start(in: drive.appendingPathComponent("org")) } | 53 | Button("New Folder in iCloud Drive") { start(in: drive.appendingPathComponent("org")) } |
| 37 | .help("Makes org/notes.org in iCloud Drive and adds the folder") | 54 | .help("Makes org/notes.org in iCloud Drive and adds the folder") |
| 38 | } | 55 | } |
| 56 | #endif | ||
| 39 | Button("Choose Folder…") { | 57 | Button("Choose Folder…") { |
| 40 | dismiss() | 58 | dismiss() |
| 41 | chooseFolder() | 59 | chooseFolder() |
| @@ -55,6 +73,15 @@ struct WelcomeView: View { | |||
| 55 | } | 73 | } |
| 56 | } | 74 | } |
| 57 | 75 | ||
| 76 | #if APPSTORE | ||
| 77 | /// An open panel in iCloud Drive; the folder chosen or made there becomes the notes folder. | ||
| 78 | private func chooseInICloudDrive() { | ||
| 79 | let message = String(localized: "Choose or make the folder for your notes in iCloud Drive.", comment: "Open panel on the welcome sheet") | ||
| 80 | guard let folder = GrantAccess.choose(at: Self.iCloudDriveFolder, message: message, prompt: String(localized: "Use Folder", comment: "Open panel button on the welcome sheet")) else { return } | ||
| 81 | start(in: folder) | ||
| 82 | } | ||
| 83 | #endif | ||
| 84 | |||
| 58 | /// Makes `folder` with a notes file in it, adds it, and opens the file. | 85 | /// Makes `folder` with a notes file in it, adds it, and opens the file. |
| 59 | private func start(in folder: URL) { | 86 | private func start(in folder: URL) { |
| 60 | Task { | 87 | Task { |
Tests/OrgAppTests/AppTests.swift +31
| @@ -95,6 +95,37 @@ struct WorkspaceModelTests { | |||
| 95 | #expect(reopened.roots.count == 1) | 95 | #expect(reopened.roots.count == 1) |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | @Test func aFolderThatDoesntResolveCanBeChosenAgain() async throws { | ||
| 99 | let parent = try Folder() | ||
| 100 | let gone = parent.url.appendingPathComponent("gone") | ||
| 101 | try FileManager.default.createDirectory(at: gone, withIntermediateDirectories: true) | ||
| 102 | let data = parent.url.appendingPathComponent("data") | ||
| 103 | let model = try WorkspaceModel(directory: data) | ||
| 104 | try await model.addRoot(gone) | ||
| 105 | #expect(model.unresolvedRoots.isEmpty) | ||
| 106 | try FileManager.default.removeItem(at: gone) | ||
| 107 | |||
| 108 | let reopened = try WorkspaceModel(directory: data) | ||
| 109 | let root = try #require(reopened.unresolvedRoots.first) | ||
| 110 | #expect(reopened.rootPaths.isEmpty && root.path == gone.path) | ||
| 111 | let found = try parent.write("found/a.org", "* Plumber\n").deletingLastPathComponent() | ||
| 112 | try await reopened.regrant(root, with: found) | ||
| 113 | #expect(reopened.unresolvedRoots.isEmpty) | ||
| 114 | #expect(reopened.roots.map(\.path) == [found.path]) | ||
| 115 | #expect(reopened.search("plumber").count == 1) | ||
| 116 | #expect(try WorkspaceModel(directory: data).roots.map(\.path) == [found.path]) | ||
| 117 | |||
| 118 | // Chosen again as a folder already in the sidebar, the old one just goes. | ||
| 119 | let other = parent.url.appendingPathComponent("other") | ||
| 120 | try FileManager.default.createDirectory(at: other, withIntermediateDirectories: true) | ||
| 121 | try await reopened.addRoot(other) | ||
| 122 | try FileManager.default.removeItem(at: other) | ||
| 123 | let third = try WorkspaceModel(directory: data) | ||
| 124 | let stale = try #require(third.unresolvedRoots.first) | ||
| 125 | try await third.regrant(stale, with: found) | ||
| 126 | #expect(third.roots.map(\.path) == [found.path] && third.unresolvedRoots.isEmpty) | ||
| 127 | } | ||
| 128 | |||
| 98 | @Test func listsDownloadsInTheTree() { | 129 | @Test func listsDownloadsInTheTree() { |
| 99 | let files = [FileEntry(path: "/r/a.org", root: "/r", kind: .org)] | 130 | let files = [FileEntry(path: "/r/a.org", root: "/r", kind: .org)] |
| 100 | let tree = FileTreeNode.build(root: "/r", files: files, downloading: ["/r/b.org", "/r/sub/c.org"]) | 131 | let tree = FileTreeNode.build(root: "/r", files: files, downloading: ["/r/b.org", "/r/sub/c.org"]) |
Tests/OrgAppTests/EmacsImportFoldersTests.swift added +68
| @@ -0,0 +1,68 @@ | |||
| 1 | import Foundation | ||
| 2 | import OrgCore | ||
| 3 | import Testing | ||
| 4 | @testable import OrgApp | ||
| 5 | |||
| 6 | @MainActor | ||
| 7 | struct EmacsImportFoldersTests { | ||
| 8 | func items(_ paths: [String]) -> [EmacsImport.Item] { | ||
| 9 | paths.enumerated().map { EmacsImport.Item(id: $0.offset, name: "org-directory", summary: $0.element, source: "config.el:1", change: .folder($0.element)) } | ||
| 10 | } | ||
| 11 | |||
| 12 | func defaults() -> UserDefaults { | ||
| 13 | let name = "orgstar-import-folders-\(UUID().uuidString)" | ||
| 14 | let defaults = UserDefaults(suiteName: name)! | ||
| 15 | defaults.removePersistentDomain(forName: name) | ||
| 16 | return defaults | ||
| 17 | } | ||
| 18 | |||
| 19 | @Test func addsOnlyTheFoldersChosen() async throws { | ||
| 20 | let notes = try Folder() | ||
| 21 | let picked = try Folder() | ||
| 22 | let config = try Folder() | ||
| 23 | let model = try WorkspaceModel(directory: nil) | ||
| 24 | try await model.addRoot(notes.url) | ||
| 25 | let first = "~/nowhere-\(UUID().uuidString)", second = "~/also-nowhere-\(UUID().uuidString)" | ||
| 26 | let all = items([notes.url.path, first, second]) | ||
| 27 | // The folder already in the sidebar isn't asked for. | ||
| 28 | #expect(EmacsImport.foldersToAdd(all, workspace: model) == [first, second]) | ||
| 29 | let summary = await EmacsImport.apply(all, defaults: defaults(), workspace: model, directory: config.url, chosenFolders: [first: picked.url]) | ||
| 30 | #expect(Set(model.roots.map(\.path)) == [notes.url.path, picked.url.path]) | ||
| 31 | #expect(summary.contains("wasn't added"), "\(summary)") | ||
| 32 | #expect(!summary.contains(first), "\(summary)") | ||
| 33 | } | ||
| 34 | |||
| 35 | @Test func withoutChosenFoldersAddsWhatsWritten() async throws { | ||
| 36 | let notes = try Folder() | ||
| 37 | let config = try Folder() | ||
| 38 | let model = try WorkspaceModel(directory: nil) | ||
| 39 | let summary = await EmacsImport.apply(items([notes.url.path, "/nowhere-\(UUID().uuidString)"]), defaults: defaults(), workspace: model, directory: config.url) | ||
| 40 | #expect(model.roots.map(\.path) == [notes.url.path]) | ||
| 41 | #expect(summary.contains("doesn't exist"), "\(summary)") | ||
| 42 | } | ||
| 43 | |||
| 44 | @Test func readsDoomDefaultsFromAChosenInstall() throws { | ||
| 45 | let install = try Folder() | ||
| 46 | let user = try Folder() | ||
| 47 | try user.write("init.el", "(doom! :lang (org +pretty))") | ||
| 48 | try user.write("config.el", "(setq org-directory \"~/notes/\")") | ||
| 49 | #expect(EmacsImport.doomDefaultFiles(in: install.url).isEmpty) | ||
| 50 | try install.write("lisp/doom.el", ";; doom") | ||
| 51 | try install.write("lisp/doom-emacs.el", "(setq fill-column 80)") | ||
| 52 | try install.write("modules/lang/org/config.el", "(after! org (setq org-log-done 'time))") | ||
| 53 | let files = EmacsImport.doomDefaultFiles(in: install.url) | ||
| 54 | #expect(files.map(\.lastPathComponent) == ["config.el", "doom-emacs.el"]) | ||
| 55 | |||
| 56 | let without = EmacsImport.scan(EmacsImport.files(in: user.url), doomDefaults: []) | ||
| 57 | #expect(without.isDoom && !without.doomDefaultsRead) | ||
| 58 | let with = EmacsImport.scan(EmacsImport.files(in: user.url), doomDefaults: files) | ||
| 59 | #expect(with.isDoom && with.doomDefaultsRead) | ||
| 60 | #expect(with.items.contains { if case .setting(let key, _) = $0.change { key == "org-log-done" } else { false } }) | ||
| 61 | } | ||
| 62 | |||
| 63 | @Test func doomInstallsStartWithTheHomeFolders() { | ||
| 64 | let home = URL(fileURLWithPath: OrgPaths.home) | ||
| 65 | #expect(EmacsImport.doomInstallLocations().suffix(2) == [".config/emacs", ".emacs.d"].map { home.appendingPathComponent($0) }) | ||
| 66 | #expect(EmacsImport.pickerLocation() == EmacsImport.defaultLocations().first ?? home) | ||
| 67 | } | ||
| 68 | } | ||
l10n/Localizable.xcstrings +414
| @@ -4707,6 +4707,41 @@ | |||
| 4707 | } | 4707 | } |
| 4708 | } | 4708 | } |
| 4709 | }, | 4709 | }, |
| 4710 | "Can't Open": { | ||
| 4711 | "comment": "Sidebar section for folders orgstar can't open", | ||
| 4712 | "localizations": { | ||
| 4713 | "de": { | ||
| 4714 | "stringUnit": { | ||
| 4715 | "state": "translated", | ||
| 4716 | "value": "Kann nicht geöffnet werden" | ||
| 4717 | } | ||
| 4718 | }, | ||
| 4719 | "es": { | ||
| 4720 | "stringUnit": { | ||
| 4721 | "state": "translated", | ||
| 4722 | "value": "No se pueden abrir" | ||
| 4723 | } | ||
| 4724 | }, | ||
| 4725 | "fr": { | ||
| 4726 | "stringUnit": { | ||
| 4727 | "state": "translated", | ||
| 4728 | "value": "Impossible d'ouvrir" | ||
| 4729 | } | ||
| 4730 | }, | ||
| 4731 | "ja": { | ||
| 4732 | "stringUnit": { | ||
| 4733 | "state": "translated", | ||
| 4734 | "value": "開けません" | ||
| 4735 | } | ||
| 4736 | }, | ||
| 4737 | "pt-BR": { | ||
| 4738 | "stringUnit": { | ||
| 4739 | "state": "translated", | ||
| 4740 | "value": "Não É Possível Abrir" | ||
| 4741 | } | ||
| 4742 | } | ||
| 4743 | } | ||
| 4744 | }, | ||
| 4710 | "Can't include %@.": { | 4745 | "Can't include %@.": { |
| 4711 | "comment": "Export stopped by an #+INCLUDE file that can't be read", | 4746 | "comment": "Export stopped by an #+INCLUDE file that can't be read", |
| 4712 | "localizations": { | 4747 | "localizations": { |
| @@ -5566,6 +5601,40 @@ | |||
| 5566 | } | 5601 | } |
| 5567 | } | 5602 | } |
| 5568 | }, | 5603 | }, |
| 5604 | "Choose": { | ||
| 5605 | "localizations": { | ||
| 5606 | "de": { | ||
| 5607 | "stringUnit": { | ||
| 5608 | "state": "translated", | ||
| 5609 | "value": "Wählen" | ||
| 5610 | } | ||
| 5611 | }, | ||
| 5612 | "es": { | ||
| 5613 | "stringUnit": { | ||
| 5614 | "state": "translated", | ||
| 5615 | "value": "Elegir" | ||
| 5616 | } | ||
| 5617 | }, | ||
| 5618 | "fr": { | ||
| 5619 | "stringUnit": { | ||
| 5620 | "state": "translated", | ||
| 5621 | "value": "Choisir" | ||
| 5622 | } | ||
| 5623 | }, | ||
| 5624 | "ja": { | ||
| 5625 | "stringUnit": { | ||
| 5626 | "state": "translated", | ||
| 5627 | "value": "選択" | ||
| 5628 | } | ||
| 5629 | }, | ||
| 5630 | "pt-BR": { | ||
| 5631 | "stringUnit": { | ||
| 5632 | "state": "translated", | ||
| 5633 | "value": "Escolher" | ||
| 5634 | } | ||
| 5635 | } | ||
| 5636 | } | ||
| 5637 | }, | ||
| 5569 | "Choose %@ or a folder that contains it.": { | 5638 | "Choose %@ or a folder that contains it.": { |
| 5570 | "comment": "Open panel for giving orgstar access to a folder", | 5639 | "comment": "Open panel for giving orgstar access to a folder", |
| 5571 | "localizations": { | 5640 | "localizations": { |
| @@ -5601,6 +5670,76 @@ | |||
| 5601 | } | 5670 | } |
| 5602 | } | 5671 | } |
| 5603 | }, | 5672 | }, |
| 5673 | "Choose %@ to add it to the sidebar.": { | ||
| 5674 | "comment": "Open panel for a folder imported from Emacs", | ||
| 5675 | "localizations": { | ||
| 5676 | "de": { | ||
| 5677 | "stringUnit": { | ||
| 5678 | "state": "translated", | ||
| 5679 | "value": "Wähle %@, um ihn zur Seitenleiste hinzuzufügen." | ||
| 5680 | } | ||
| 5681 | }, | ||
| 5682 | "es": { | ||
| 5683 | "stringUnit": { | ||
| 5684 | "state": "translated", | ||
| 5685 | "value": "Elige %@ para añadirla a la barra lateral." | ||
| 5686 | } | ||
| 5687 | }, | ||
| 5688 | "fr": { | ||
| 5689 | "stringUnit": { | ||
| 5690 | "state": "translated", | ||
| 5691 | "value": "Choisissez %@ pour l'ajouter à la barre latérale." | ||
| 5692 | } | ||
| 5693 | }, | ||
| 5694 | "ja": { | ||
| 5695 | "stringUnit": { | ||
| 5696 | "state": "translated", | ||
| 5697 | "value": "%@ を選択してサイドバーに追加してください。" | ||
| 5698 | } | ||
| 5699 | }, | ||
| 5700 | "pt-BR": { | ||
| 5701 | "stringUnit": { | ||
| 5702 | "state": "translated", | ||
| 5703 | "value": "Escolha %@ para adicioná-la à barra lateral." | ||
| 5704 | } | ||
| 5705 | } | ||
| 5706 | } | ||
| 5707 | }, | ||
| 5708 | "Choose %@ to give orgstar access to it again.": { | ||
| 5709 | "comment": "Open panel for a sidebar folder orgstar can't open", | ||
| 5710 | "localizations": { | ||
| 5711 | "de": { | ||
| 5712 | "stringUnit": { | ||
| 5713 | "state": "translated", | ||
| 5714 | "value": "Wähle %@, um orgstar wieder Zugriff darauf zu geben." | ||
| 5715 | } | ||
| 5716 | }, | ||
| 5717 | "es": { | ||
| 5718 | "stringUnit": { | ||
| 5719 | "state": "translated", | ||
| 5720 | "value": "Elige %@ para volver a dar acceso a orgstar." | ||
| 5721 | } | ||
| 5722 | }, | ||
| 5723 | "fr": { | ||
| 5724 | "stringUnit": { | ||
| 5725 | "state": "translated", | ||
| 5726 | "value": "Choisissez %@ pour redonner l'accès à orgstar." | ||
| 5727 | } | ||
| 5728 | }, | ||
| 5729 | "ja": { | ||
| 5730 | "stringUnit": { | ||
| 5731 | "state": "translated", | ||
| 5732 | "value": "%@ を選択して、orgstarに再度アクセスを許可してください。" | ||
| 5733 | } | ||
| 5734 | }, | ||
| 5735 | "pt-BR": { | ||
| 5736 | "stringUnit": { | ||
| 5737 | "state": "translated", | ||
| 5738 | "value": "Escolha %@ para dar acesso ao orgstar novamente." | ||
| 5739 | } | ||
| 5740 | } | ||
| 5741 | } | ||
| 5742 | }, | ||
| 5604 | "Choose Another Folder…": { | 5743 | "Choose Another Folder…": { |
| 5605 | "localizations": { | 5744 | "localizations": { |
| 5606 | "de": { | 5745 | "de": { |
| @@ -5669,6 +5808,40 @@ | |||
| 5669 | } | 5808 | } |
| 5670 | } | 5809 | } |
| 5671 | }, | 5810 | }, |
| 5811 | "Choose Doom Folder…": { | ||
| 5812 | "localizations": { | ||
| 5813 | "de": { | ||
| 5814 | "stringUnit": { | ||
| 5815 | "state": "translated", | ||
| 5816 | "value": "Doom-Ordner wählen …" | ||
| 5817 | } | ||
| 5818 | }, | ||
| 5819 | "es": { | ||
| 5820 | "stringUnit": { | ||
| 5821 | "state": "translated", | ||
| 5822 | "value": "Elegir carpeta de Doom…" | ||
| 5823 | } | ||
| 5824 | }, | ||
| 5825 | "fr": { | ||
| 5826 | "stringUnit": { | ||
| 5827 | "state": "translated", | ||
| 5828 | "value": "Choisir le dossier de Doom…" | ||
| 5829 | } | ||
| 5830 | }, | ||
| 5831 | "ja": { | ||
| 5832 | "stringUnit": { | ||
| 5833 | "state": "translated", | ||
| 5834 | "value": "Doomフォルダを選択…" | ||
| 5835 | } | ||
| 5836 | }, | ||
| 5837 | "pt-BR": { | ||
| 5838 | "stringUnit": { | ||
| 5839 | "state": "translated", | ||
| 5840 | "value": "Escolher Pasta do Doom…" | ||
| 5841 | } | ||
| 5842 | } | ||
| 5843 | } | ||
| 5844 | }, | ||
| 5672 | "Choose Folder": { | 5845 | "Choose Folder": { |
| 5673 | "localizations": { | 5846 | "localizations": { |
| 5674 | "de": { | 5847 | "de": { |
| @@ -5839,6 +6012,76 @@ | |||
| 5839 | } | 6012 | } |
| 5840 | } | 6013 | } |
| 5841 | }, | 6014 | }, |
| 6015 | "Choose or make the folder for your notes in iCloud Drive.": { | ||
| 6016 | "comment": "Open panel on the welcome sheet", | ||
| 6017 | "localizations": { | ||
| 6018 | "de": { | ||
| 6019 | "stringUnit": { | ||
| 6020 | "state": "translated", | ||
| 6021 | "value": "Wähle oder erstelle in iCloud Drive den Ordner für deine Notizen." | ||
| 6022 | } | ||
| 6023 | }, | ||
| 6024 | "es": { | ||
| 6025 | "stringUnit": { | ||
| 6026 | "state": "translated", | ||
| 6027 | "value": "Elige o crea en iCloud Drive la carpeta para tus notas." | ||
| 6028 | } | ||
| 6029 | }, | ||
| 6030 | "fr": { | ||
| 6031 | "stringUnit": { | ||
| 6032 | "state": "translated", | ||
| 6033 | "value": "Choisissez ou créez dans iCloud Drive le dossier de vos notes." | ||
| 6034 | } | ||
| 6035 | }, | ||
| 6036 | "ja": { | ||
| 6037 | "stringUnit": { | ||
| 6038 | "state": "translated", | ||
| 6039 | "value": "iCloud Driveでメモ用のフォルダを選択または作成してください。" | ||
| 6040 | } | ||
| 6041 | }, | ||
| 6042 | "pt-BR": { | ||
| 6043 | "stringUnit": { | ||
| 6044 | "state": "translated", | ||
| 6045 | "value": "Escolha ou crie no iCloud Drive a pasta para suas notas." | ||
| 6046 | } | ||
| 6047 | } | ||
| 6048 | } | ||
| 6049 | }, | ||
| 6050 | "Choose the folder Doom is installed in (~/.config/emacs or ~/.emacs.d) to read Doom's own org defaults.": { | ||
| 6051 | "comment": "Open panel for Doom's install folder when importing from Emacs", | ||
| 6052 | "localizations": { | ||
| 6053 | "de": { | ||
| 6054 | "stringUnit": { | ||
| 6055 | "state": "translated", | ||
| 6056 | "value": "Wähle den Ordner, in dem Doom installiert ist (~/.config/emacs oder ~/.emacs.d), um Dooms eigene Org-Voreinstellungen zu lesen." | ||
| 6057 | } | ||
| 6058 | }, | ||
| 6059 | "es": { | ||
| 6060 | "stringUnit": { | ||
| 6061 | "state": "translated", | ||
| 6062 | "value": "Elige la carpeta donde está instalado Doom (~/.config/emacs o ~/.emacs.d) para leer los valores predeterminados de org de Doom." | ||
| 6063 | } | ||
| 6064 | }, | ||
| 6065 | "fr": { | ||
| 6066 | "stringUnit": { | ||
| 6067 | "state": "translated", | ||
| 6068 | "value": "Choisissez le dossier où Doom est installé (~/.config/emacs ou ~/.emacs.d) pour lire les réglages org par défaut de Doom." | ||
| 6069 | } | ||
| 6070 | }, | ||
| 6071 | "ja": { | ||
| 6072 | "stringUnit": { | ||
| 6073 | "state": "translated", | ||
| 6074 | "value": "Doomのorg既定値を読み込むには、Doomがインストールされているフォルダ(~/.config/emacs または ~/.emacs.d)を選択してください。" | ||
| 6075 | } | ||
| 6076 | }, | ||
| 6077 | "pt-BR": { | ||
| 6078 | "stringUnit": { | ||
| 6079 | "state": "translated", | ||
| 6080 | "value": "Escolha a pasta onde o Doom está instalado (~/.config/emacs ou ~/.emacs.d) para ler os padrões de org do próprio Doom." | ||
| 6081 | } | ||
| 6082 | } | ||
| 6083 | } | ||
| 6084 | }, | ||
| 5842 | "Choose the folder for config.toml and orgstar's other configuration files.": { | 6085 | "Choose the folder for config.toml and orgstar's other configuration files.": { |
| 5843 | "comment": "Choose Configuration Folder panel", | 6086 | "comment": "Choose Configuration Folder panel", |
| 5844 | "localizations": { | 6087 | "localizations": { |
| @@ -9605,6 +9848,40 @@ | |||
| 9605 | } | 9848 | } |
| 9606 | } | 9849 | } |
| 9607 | }, | 9850 | }, |
| 9851 | "Doom's own org defaults are read from the folder Doom is installed in": { | ||
| 9852 | "localizations": { | ||
| 9853 | "de": { | ||
| 9854 | "stringUnit": { | ||
| 9855 | "state": "translated", | ||
| 9856 | "value": "Dooms eigene Org-Voreinstellungen werden aus dem Ordner gelesen, in dem Doom installiert ist" | ||
| 9857 | } | ||
| 9858 | }, | ||
| 9859 | "es": { | ||
| 9860 | "stringUnit": { | ||
| 9861 | "state": "translated", | ||
| 9862 | "value": "Los valores predeterminados de org de Doom se leen de la carpeta donde está instalado Doom" | ||
| 9863 | } | ||
| 9864 | }, | ||
| 9865 | "fr": { | ||
| 9866 | "stringUnit": { | ||
| 9867 | "state": "translated", | ||
| 9868 | "value": "Les réglages org par défaut de Doom sont lus dans le dossier où Doom est installé" | ||
| 9869 | } | ||
| 9870 | }, | ||
| 9871 | "ja": { | ||
| 9872 | "stringUnit": { | ||
| 9873 | "state": "translated", | ||
| 9874 | "value": "Doomのorg既定値は、Doomがインストールされているフォルダから読み込まれます" | ||
| 9875 | } | ||
| 9876 | }, | ||
| 9877 | "pt-BR": { | ||
| 9878 | "stringUnit": { | ||
| 9879 | "state": "translated", | ||
| 9880 | "value": "Os padrões de org do próprio Doom são lidos da pasta onde o Doom está instalado" | ||
| 9881 | } | ||
| 9882 | } | ||
| 9883 | } | ||
| 9884 | }, | ||
| 9608 | "Downloading from iCloud": { | 9885 | "Downloading from iCloud": { |
| 9609 | "localizations": { | 9886 | "localizations": { |
| 9610 | "de": { | 9887 | "de": { |
| @@ -16817,6 +17094,40 @@ | |||
| 16817 | } | 17094 | } |
| 16818 | } | 17095 | } |
| 16819 | }, | 17096 | }, |
| 17097 | "Makes notes.org in a folder you choose or make in iCloud Drive and adds the folder": { | ||
| 17098 | "localizations": { | ||
| 17099 | "de": { | ||
| 17100 | "stringUnit": { | ||
| 17101 | "state": "translated", | ||
| 17102 | "value": "Legt notes.org in einem Ordner an, den du in iCloud Drive wählst oder erstellst, und fügt den Ordner hinzu" | ||
| 17103 | } | ||
| 17104 | }, | ||
| 17105 | "es": { | ||
| 17106 | "stringUnit": { | ||
| 17107 | "state": "translated", | ||
| 17108 | "value": "Crea notes.org en una carpeta que eliges o creas en iCloud Drive y añade la carpeta" | ||
| 17109 | } | ||
| 17110 | }, | ||
| 17111 | "fr": { | ||
| 17112 | "stringUnit": { | ||
| 17113 | "state": "translated", | ||
| 17114 | "value": "Crée notes.org dans un dossier que vous choisissez ou créez dans iCloud Drive et ajoute le dossier" | ||
| 17115 | } | ||
| 17116 | }, | ||
| 17117 | "ja": { | ||
| 17118 | "stringUnit": { | ||
| 17119 | "state": "translated", | ||
| 17120 | "value": "iCloud Driveで選択または作成したフォルダにnotes.orgを作成し、フォルダを追加します" | ||
| 17121 | } | ||
| 17122 | }, | ||
| 17123 | "pt-BR": { | ||
| 17124 | "stringUnit": { | ||
| 17125 | "state": "translated", | ||
| 17126 | "value": "Cria notes.org em uma pasta que você escolhe ou cria no iCloud Drive e adiciona a pasta" | ||
| 17127 | } | ||
| 17128 | } | ||
| 17129 | } | ||
| 17130 | }, | ||
| 16820 | "Makes org/notes.org in iCloud Drive and adds the folder": { | 17131 | "Makes org/notes.org in iCloud Drive and adds the folder": { |
| 16821 | "localizations": { | 17132 | "localizations": { |
| 16822 | "de": { | 17133 | "de": { |
| @@ -18261,6 +18572,40 @@ | |||
| 18261 | } | 18572 | } |
| 18262 | } | 18573 | } |
| 18263 | }, | 18574 | }, |
| 18575 | "New Folder in iCloud Drive…": { | ||
| 18576 | "localizations": { | ||
| 18577 | "de": { | ||
| 18578 | "stringUnit": { | ||
| 18579 | "state": "translated", | ||
| 18580 | "value": "Neuer Ordner in iCloud Drive …" | ||
| 18581 | } | ||
| 18582 | }, | ||
| 18583 | "es": { | ||
| 18584 | "stringUnit": { | ||
| 18585 | "state": "translated", | ||
| 18586 | "value": "Nueva carpeta en iCloud Drive…" | ||
| 18587 | } | ||
| 18588 | }, | ||
| 18589 | "fr": { | ||
| 18590 | "stringUnit": { | ||
| 18591 | "state": "translated", | ||
| 18592 | "value": "Nouveau dossier dans iCloud Drive…" | ||
| 18593 | } | ||
| 18594 | }, | ||
| 18595 | "ja": { | ||
| 18596 | "stringUnit": { | ||
| 18597 | "state": "translated", | ||
| 18598 | "value": "iCloud Driveに新規フォルダ…" | ||
| 18599 | } | ||
| 18600 | }, | ||
| 18601 | "pt-BR": { | ||
| 18602 | "stringUnit": { | ||
| 18603 | "state": "translated", | ||
| 18604 | "value": "Nova Pasta no iCloud Drive…" | ||
| 18605 | } | ||
| 18606 | } | ||
| 18607 | } | ||
| 18608 | }, | ||
| 18264 | "New Folder…": { | 18609 | "New Folder…": { |
| 18265 | "localizations": { | 18610 | "localizations": { |
| 18266 | "de": { | 18611 | "de": { |
| @@ -32371,6 +32716,41 @@ | |||
| 32371 | } | 32716 | } |
| 32372 | } | 32717 | } |
| 32373 | }, | 32718 | }, |
| 32719 | "Use Folder": { | ||
| 32720 | "comment": "Open panel button on the welcome sheet", | ||
| 32721 | "localizations": { | ||
| 32722 | "de": { | ||
| 32723 | "stringUnit": { | ||
| 32724 | "state": "translated", | ||
| 32725 | "value": "Ordner verwenden" | ||
| 32726 | } | ||
| 32727 | }, | ||
| 32728 | "es": { | ||
| 32729 | "stringUnit": { | ||
| 32730 | "state": "translated", | ||
| 32731 | "value": "Usar carpeta" | ||
| 32732 | } | ||
| 32733 | }, | ||
| 32734 | "fr": { | ||
| 32735 | "stringUnit": { | ||
| 32736 | "state": "translated", | ||
| 32737 | "value": "Utiliser le dossier" | ||
| 32738 | } | ||
| 32739 | }, | ||
| 32740 | "ja": { | ||
| 32741 | "stringUnit": { | ||
| 32742 | "state": "translated", | ||
| 32743 | "value": "フォルダを使用" | ||
| 32744 | } | ||
| 32745 | }, | ||
| 32746 | "pt-BR": { | ||
| 32747 | "stringUnit": { | ||
| 32748 | "state": "translated", | ||
| 32749 | "value": "Usar Pasta" | ||
| 32750 | } | ||
| 32751 | } | ||
| 32752 | } | ||
| 32753 | }, | ||
| 32374 | "Use Selection for Find": { | 32754 | "Use Selection for Find": { |
| 32375 | "comment": "Command title", | 32755 | "comment": "Command title", |
| 32376 | "localizations": { | 32756 | "localizations": { |
| @@ -34821,6 +35201,40 @@ | |||
| 34821 | } | 35201 | } |
| 34822 | } | 35202 | } |
| 34823 | }, | 35203 | }, |
| 35204 | "orgstar can't open this folder": { | ||
| 35205 | "localizations": { | ||
| 35206 | "de": { | ||
| 35207 | "stringUnit": { | ||
| 35208 | "state": "translated", | ||
| 35209 | "value": "orgstar kann diesen Ordner nicht öffnen" | ||
| 35210 | } | ||
| 35211 | }, | ||
| 35212 | "es": { | ||
| 35213 | "stringUnit": { | ||
| 35214 | "state": "translated", | ||
| 35215 | "value": "orgstar no puede abrir esta carpeta" | ||
| 35216 | } | ||
| 35217 | }, | ||
| 35218 | "fr": { | ||
| 35219 | "stringUnit": { | ||
| 35220 | "state": "translated", | ||
| 35221 | "value": "orgstar ne peut pas ouvrir ce dossier" | ||
| 35222 | } | ||
| 35223 | }, | ||
| 35224 | "ja": { | ||
| 35225 | "stringUnit": { | ||
| 35226 | "state": "translated", | ||
| 35227 | "value": "orgstarはこのフォルダを開けません" | ||
| 35228 | } | ||
| 35229 | }, | ||
| 35230 | "pt-BR": { | ||
| 35231 | "stringUnit": { | ||
| 35232 | "state": "translated", | ||
| 35233 | "value": "O orgstar não consegue abrir esta pasta" | ||
| 35234 | } | ||
| 35235 | } | ||
| 35236 | } | ||
| 35237 | }, | ||
| 34824 | "orgstar can't reach %@.": { | 35238 | "orgstar can't reach %@.": { |
| 34825 | "comment": "Alert for a folder outside the sidebar's folders", | 35239 | "comment": "Alert for a folder outside the sidebar's folders", |
| 34826 | "localizations": { | 35240 | "localizations": { |