Git auto-commit and file history !486
14 files changed, +358 −34
Changed files (14)
- Sources/OrgApp/CommandTitles.swift +1
- Sources/OrgApp/DocumentSession.swift +8 −1
- Sources/OrgApp/FileHistory.swift added +42
- Sources/OrgEditorAppKit/EditorCommands.swift +1 −1
- Sources/OrgPrograms/GitHistory.swift added +33
- Sources/Orgstar/ContentView.swift +1 −1
- Sources/Orgstar/OrgstarApp.swift +1 −1
- Sources/Orgstar/VersionViews.swift +66 −24
- Tests/OrgProgramsTests/FileHistoryTests.swift added +59
- docs/manual/guide/01-files-and-folders.org +5 −2
- docs/manual/guide/03-keys.org +2 −2
- docs/manual/guide/15-alongside-emacs.org +1 −1
- docs/manual/install.org +1 −1
- l10n/Localizable.xcstrings +137
Sources/OrgApp/CommandTitles.swift +1 · view
| @@ -128,6 +128,7 @@ enum CommandTitles { | |||
| 128 | String(localized: "Go to Tomorrow's Daily Note", comment: "Command title"), | 128 | String(localized: "Go to Tomorrow's Daily Note", comment: "Command title"), |
| 129 | String(localized: "Go to Yesterday's Daily Note", comment: "Command title"), | 129 | String(localized: "Go to Yesterday's Daily Note", comment: "Command title"), |
| 130 | String(localized: "Hide Next Fold Level", comment: "Command title"), | 130 | String(localized: "Hide Next Fold Level", comment: "Command title"), |
| 131 | String(localized: "History…", comment: "Command title"), | ||
| 131 | String(localized: "Import Table from File…", comment: "Command title"), | 132 | String(localized: "Import Table from File…", comment: "Command title"), |
| 132 | String(localized: "Import from Emacs…", comment: "Command title"), | 133 | String(localized: "Import from Emacs…", comment: "Command title"), |
| 133 | String(localized: "Increase Timestamp Part", comment: "Command title"), | 134 | String(localized: "Increase Timestamp Part", comment: "Command title"), |
Sources/OrgApp/DocumentSession.swift +8 −1 · view
| @@ -594,7 +594,14 @@ public final class DocumentSession { | |||
| 594 | /// Puts a kept version's text in the buffer, as an edit that can be undone; the buffer as it | 594 | /// Puts a kept version's text in the buffer, as an edit that can be undone; the buffer as it |
| 595 | /// was goes to recovery. | 595 | /// was goes to recovery. |
| 596 | public func restore(_ version: URL) -> String? { | 596 | public func restore(_ version: URL) -> String? { |
| 597 | guard let buffer, let url, let text = recoveryText(version) else { return "Can't read that version" } | 597 | guard let text = recoveryText(version) else { return "Can't read that version" } |
| 598 | return restore(text: text) | ||
| 599 | } | ||
| 600 | |||
| 601 | /// Puts `text`, an earlier version of the file, in the buffer as an edit that can be undone; | ||
| 602 | /// the buffer as it was goes to recovery. | ||
| 603 | public func restore(text: String) -> String? { | ||
| 604 | guard let buffer, let url else { return "Can't read that version" } | ||
| 598 | do { | 605 | do { |
| 599 | try recovery.keep(try buffer.document.encodedText(), for: url, label: "local") | 606 | try recovery.keep(try buffer.document.encodedText(), for: url, label: "local") |
| 600 | } catch { | 607 | } catch { |
Sources/OrgApp/FileHistory.swift added +42 · view
| @@ -0,0 +1,42 @@ | |||
| 1 | import Foundation | ||
| 2 | |||
| 3 | /// The versions of a file the History view lists: those kept in the recovery folder and, in the | ||
| 4 | /// download version where the folder is a git repository, the commits that changed it. | ||
| 5 | public enum FileHistory { | ||
| 6 | /// A commit that changed the file, with the file's path in it relative to `repository`. | ||
| 7 | public struct Commit: Hashable, Sendable { | ||
| 8 | public let hash: String | ||
| 9 | public let date: Date | ||
| 10 | public let author: String | ||
| 11 | public let subject: String | ||
| 12 | public let path: String | ||
| 13 | public let repository: URL | ||
| 14 | |||
| 15 | public init(hash: String, date: Date, author: String, subject: String, path: String, repository: URL) { | ||
| 16 | self.hash = hash | ||
| 17 | self.date = date | ||
| 18 | self.author = author | ||
| 19 | self.subject = subject | ||
| 20 | self.path = path | ||
| 21 | self.repository = repository | ||
| 22 | } | ||
| 23 | } | ||
| 24 | |||
| 25 | public enum Entry: Hashable, Sendable { | ||
| 26 | case recovery(url: URL, date: Date, label: String) | ||
| 27 | case commit(Commit) | ||
| 28 | |||
| 29 | public var date: Date { | ||
| 30 | switch self { | ||
| 31 | case .recovery(_, let date, _): date | ||
| 32 | case .commit(let commit): commit.date | ||
| 33 | } | ||
| 34 | } | ||
| 35 | } | ||
| 36 | |||
| 37 | /// Recovery versions and commits together, newest first. | ||
| 38 | public static func merged(recovery: [(url: URL, date: Date, label: String)], commits: [Commit]) -> [Entry] { | ||
| 39 | (recovery.map { Entry.recovery(url: $0.url, date: $0.date, label: $0.label) } + commits.map(Entry.commit)) | ||
| 40 | .sorted { $0.date > $1.date } | ||
| 41 | } | ||
| 42 | } | ||
Sources/OrgEditorAppKit/EditorCommands.swift +1 −1 · view
| @@ -184,7 +184,7 @@ public enum EditorCommands { | |||
| 184 | EditorCommand(id: "app.export-body-only", title: "Turn Body-Only Export On or Off", action: .app), | 184 | EditorCommand(id: "app.export-body-only", title: "Turn Body-Only Export On or Off", action: .app), |
| 185 | EditorCommand(id: "app.sync-conflicts", title: "Resolve Sync Conflicts…", action: .app), | 185 | EditorCommand(id: "app.sync-conflicts", title: "Resolve Sync Conflicts…", action: .app), |
| 186 | EditorCommand(id: "app.revert", title: "Revert to File on Disk", action: .app), | 186 | EditorCommand(id: "app.revert", title: "Revert to File on Disk", action: .app), |
| 187 | EditorCommand(id: "app.recovery", title: "Recovery Versions…", action: .app), | 187 | EditorCommand(id: "app.recovery", title: "History…", action: .app), |
| 188 | EditorCommand(id: "app.export.html", title: "Export to HTML", action: .app), | 188 | EditorCommand(id: "app.export.html", title: "Export to HTML", action: .app), |
| 189 | EditorCommand(id: "app.export.html-open", title: "Export to HTML and Open", action: .app), | 189 | EditorCommand(id: "app.export.html-open", title: "Export to HTML and Open", action: .app), |
| 190 | EditorCommand(id: "app.export.markdown", title: "Export to Markdown", action: .app), | 190 | EditorCommand(id: "app.export.markdown", title: "Export to Markdown", action: .app), |
Sources/OrgPrograms/GitHistory.swift added +33 · view
| @@ -0,0 +1,33 @@ | |||
| 1 | #if os(macOS) | ||
| 2 | import Foundation | ||
| 3 | import OrgApp | ||
| 4 | import OrgCore | ||
| 5 | |||
| 6 | /// A file's commits, read with the system git. | ||
| 7 | public enum GitHistory { | ||
| 8 | /// The commits that changed `file`, newest first, following renames (`git log --follow`); | ||
| 9 | /// each with the file's path in that commit. Empty outside a repository or without git. | ||
| 10 | public static func commits(for file: URL, git: Git? = Git.find(), limit: Int = 200) async -> [FileHistory.Commit] { | ||
| 11 | guard let git, let repository = await git.repository(containing: file.deletingLastPathComponent()), | ||
| 12 | let path = Git.relativePath(file, in: repository.top) else { return [] } | ||
| 13 | let arguments = ["log", "--follow", "-n", String(limit), "--name-only", "--format=%x1e%H%x1f%at%x1f%an%x1f%s", "--", path] | ||
| 14 | guard let output = try? await git.run(arguments, in: repository.top), output.succeeded else { return [] } | ||
| 15 | return output.stdout.split(separator: "\u{1e}").compactMap { record in | ||
| 16 | let lines = record.split(separator: "\n", omittingEmptySubsequences: true) | ||
| 17 | guard let header = lines.first, let name = lines.dropFirst().last else { return nil } | ||
| 18 | let fields = header.split(separator: "\u{1f}", omittingEmptySubsequences: false).map(String.init) | ||
| 19 | guard fields.count == 4, let seconds = TimeInterval(fields[1]) else { return nil } | ||
| 20 | return FileHistory.Commit( | ||
| 21 | hash: fields[0], date: Date(timeIntervalSince1970: seconds), author: fields[2], subject: fields[3], | ||
| 22 | path: String(name), repository: repository.top | ||
| 23 | ) | ||
| 24 | } | ||
| 25 | } | ||
| 26 | |||
| 27 | /// The file's text in `commit`. | ||
| 28 | public static func text(of commit: FileHistory.Commit, git: Git? = Git.find()) async -> String? { | ||
| 29 | guard let git, let output = try? await git.run(["show", "\(commit.hash):\(commit.path)"], in: commit.repository), output.succeeded else { return nil } | ||
| 30 | return SourceText(bytes: Array(output.stdout.utf8)).text | ||
| 31 | } | ||
| 32 | } | ||
| 33 | #endif | ||
Sources/Orgstar/ContentView.swift +1 −1 · view
| @@ -982,7 +982,7 @@ struct ContentView: View { | |||
| 982 | case .syncCopies: | 982 | case .syncCopies: |
| 983 | SyncConflictSheet(session: session) { commands.show($0) } | 983 | SyncConflictSheet(session: session) { commands.show($0) } |
| 984 | case .recovery: | 984 | case .recovery: |
| 985 | RecoverySheet(session: session) { commands.show($0) } | 985 | HistorySheet(session: session) { commands.show($0) } |
| 986 | } | 986 | } |
| 987 | } | 987 | } |
| 988 | 988 | ||
Sources/Orgstar/OrgstarApp.swift +1 −1 · view
| @@ -527,7 +527,7 @@ struct OrgstarApp: App { | |||
| 527 | .disabled(session.path == nil) | 527 | .disabled(session.path == nil) |
| 528 | Button("Resolve Sync Conflicts…") { commands.run("app.sync-conflicts") } | 528 | Button("Resolve Sync Conflicts…") { commands.run("app.sync-conflicts") } |
| 529 | .disabled(session.path == nil) | 529 | .disabled(session.path == nil) |
| 530 | Button("Recovery Versions…") { commands.run("app.recovery") } | 530 | Button("History…") { commands.run("app.recovery") } |
| 531 | .disabled(session.path == nil) | 531 | .disabled(session.path == nil) |
| 532 | } | 532 | } |
| 533 | CommandGroup(replacing: .saveItem) { | 533 | CommandGroup(replacing: .saveItem) { |
Sources/Orgstar/VersionViews.swift +66 −24 · view
| @@ -2,6 +2,9 @@ import AppKit | |||
| 2 | import OrgApp | 2 | import OrgApp |
| 3 | import OrgDocument | 3 | import OrgDocument |
| 4 | import OrgPresentation | 4 | import OrgPresentation |
| 5 | #if !APPSTORE | ||
| 6 | import OrgPrograms | ||
| 7 | #endif | ||
| 5 | import SwiftUI | 8 | import SwiftUI |
| 6 | 9 | ||
| 7 | /// A diff in the theme's colours: removed lines in its TODO red, added ones in its DONE green. | 10 | /// A diff in the theme's colours: removed lines in its TODO red, added ones in its DONE green. |
| @@ -100,20 +103,24 @@ struct SyncConflictSheet: View { | |||
| 100 | } | 103 | } |
| 101 | } | 104 | } |
| 102 | 105 | ||
| 103 | /// Versions of the open file kept in the recovery folder, newest first, against the buffer. | 106 | /// The open file's history, newest first, each version against the buffer: the versions kept |
| 104 | struct RecoverySheet: View { | 107 | /// in the recovery folder and, in the download version where the folder is a git repository, |
| 108 | /// the commits that changed the file (`git log --follow`). | ||
| 109 | struct HistorySheet: View { | ||
| 105 | let session: DocumentSession | 110 | let session: DocumentSession |
| 106 | let report: (String) -> Void | 111 | let report: (String) -> Void |
| 107 | @State private var versions: [(url: URL, date: Date, label: String)] = [] | 112 | @State private var entries: [FileHistory.Entry] = [] |
| 108 | @State private var selected: URL? | 113 | @State private var selected: FileHistory.Entry? |
| 114 | /// The selected version's text, once read. | ||
| 115 | @State private var text: String? | ||
| 109 | @Environment(\.dismiss) private var dismiss | 116 | @Environment(\.dismiss) private var dismiss |
| 110 | 117 | ||
| 111 | var body: some View { | 118 | var body: some View { |
| 112 | Group { | 119 | Group { |
| 113 | if versions.isEmpty { | 120 | if entries.isEmpty { |
| 114 | VStack { | 121 | VStack { |
| 115 | ContentUnavailableView( | 122 | ContentUnavailableView( |
| 116 | "No Recovery Versions", systemImage: "clock.arrow.circlepath", | 123 | "No History", systemImage: "clock.arrow.circlepath", |
| 117 | description: Text("orgstar keeps a copy of this file here when it replaces a version, and a snapshot before a save at most once an hour.") | 124 | description: Text("orgstar keeps a copy of this file here when it replaces a version, and a snapshot before a save at most once an hour.") |
| 118 | ) | 125 | ) |
| 119 | HStack { | 126 | HStack { |
| @@ -127,39 +134,60 @@ struct RecoverySheet: View { | |||
| 127 | } | 134 | } |
| 128 | } | 135 | } |
| 129 | .frame(minWidth: 760, minHeight: 460) | 136 | .frame(minWidth: 760, minHeight: 460) |
| 130 | .onAppear { | 137 | .task { |
| 131 | versions = session.recoveryVersions() | 138 | let recovery = session.recoveryVersions() |
| 132 | selected = versions.first?.url | 139 | entries = FileHistory.merged(recovery: recovery, commits: []) |
| 140 | selected = entries.first | ||
| 141 | #if !APPSTORE | ||
| 142 | guard let path = session.path else { return } | ||
| 143 | let commits = await GitHistory.commits(for: URL(fileURLWithPath: path)) | ||
| 144 | guard !commits.isEmpty else { return } | ||
| 145 | entries = FileHistory.merged(recovery: recovery, commits: commits) | ||
| 146 | if selected == nil { selected = entries.first } | ||
| 147 | #endif | ||
| 148 | } | ||
| 149 | .task(id: selected) { | ||
| 150 | text = nil | ||
| 151 | if let selected { text = await load(selected) } | ||
| 152 | } | ||
| 153 | } | ||
| 154 | |||
| 155 | /// The text of `entry`: a kept file, or the file in a commit. | ||
| 156 | private func load(_ entry: FileHistory.Entry) async -> String? { | ||
| 157 | switch entry { | ||
| 158 | case .recovery(let url, _, _): return session.recoveryText(url) | ||
| 159 | case .commit(let commit): | ||
| 160 | #if APPSTORE | ||
| 161 | return nil | ||
| 162 | #else | ||
| 163 | return await GitHistory.text(of: commit) | ||
| 164 | #endif | ||
| 133 | } | 165 | } |
| 134 | } | 166 | } |
| 135 | 167 | ||
| 136 | private var versionList: some View { | 168 | private var versionList: some View { |
| 137 | HSplitView { | 169 | HSplitView { |
| 138 | List(versions, id: \.url, selection: $selected) { version in | 170 | List(entries, id: \.self, selection: $selected) { entry in |
| 139 | VStack(alignment: .leading) { | 171 | row(entry).tag(entry) |
| 140 | Text(version.date.formatted(date: .abbreviated, time: .standard)) | ||
| 141 | Text(Self.describe(version.label)).font(.caption).foregroundStyle(.secondary) | ||
| 142 | } | ||
| 143 | .tag(version.url) | ||
| 144 | } | 172 | } |
| 145 | .frame(minWidth: 200, idealWidth: 220) | 173 | .frame(minWidth: 220, idealWidth: 260) |
| 146 | VStack(alignment: .leading, spacing: 10) { | 174 | VStack(alignment: .leading, spacing: 10) { |
| 147 | Text("Recovery Versions").font(.headline) | 175 | Text("History").font(.headline) |
| 148 | Text("Lines marked - are in the buffer, + in the kept version.").foregroundStyle(.secondary) | 176 | Text("Lines marked - are in the buffer, + in the selected version.").foregroundStyle(.secondary) |
| 149 | if let selected, let kept = session.recoveryText(selected), let mine = session.document?.text { | 177 | if let text, let mine = session.document?.text { |
| 150 | ThemedDiff(old: mine, new: kept) | 178 | ThemedDiff(old: mine, new: text) |
| 151 | } else { | 179 | } else { |
| 152 | Spacer() | 180 | Spacer() |
| 153 | } | 181 | } |
| 154 | HStack { | 182 | HStack { |
| 155 | Button("Cancel") { dismiss() }.keyboardShortcut(.cancelAction) | 183 | Button("Cancel") { dismiss() }.keyboardShortcut(.cancelAction) |
| 156 | if let selected { | 184 | if case .recovery(let url, _, _) = selected { |
| 157 | Button("Show in Finder") { NSWorkspace.shared.activateFileViewerSelecting([selected]) } | 185 | Button("Show in Finder") { NSWorkspace.shared.activateFileViewerSelecting([url]) } |
| 158 | } | 186 | } |
| 159 | Spacer() | 187 | Spacer() |
| 160 | if let selected { | 188 | if let text { |
| 161 | Button("Restore") { | 189 | Button("Restore") { |
| 162 | if let message = session.restore(selected) { report(message) } else { report("Restored; undo brings back what was there.") } | 190 | if let message = session.restore(text: text) { report(message) } else { report("Restored; undo brings back what was there.") } |
| 163 | dismiss() | 191 | dismiss() |
| 164 | } | 192 | } |
| 165 | .keyboardShortcut(.defaultAction) | 193 | .keyboardShortcut(.defaultAction) |
| @@ -170,6 +198,20 @@ struct RecoverySheet: View { | |||
| 170 | } | 198 | } |
| 171 | } | 199 | } |
| 172 | 200 | ||
| 201 | @ViewBuilder | ||
| 202 | private func row(_ entry: FileHistory.Entry) -> some View { | ||
| 203 | VStack(alignment: .leading) { | ||
| 204 | Text(entry.date.formatted(date: .abbreviated, time: .standard)) | ||
| 205 | switch entry { | ||
| 206 | case .recovery(_, _, let label): | ||
| 207 | Text(Self.describe(label)).font(.caption).foregroundStyle(.secondary) | ||
| 208 | case .commit(let commit): | ||
| 209 | Text(verbatim: commit.subject).font(.caption).lineLimit(1) | ||
| 210 | Text(verbatim: "\(commit.hash.prefix(7)) · \(commit.author)").font(.caption.monospaced()).foregroundStyle(.secondary) | ||
| 211 | } | ||
| 212 | } | ||
| 213 | } | ||
| 214 | |||
| 173 | static func describe(_ label: String) -> String { | 215 | static func describe(_ label: String) -> String { |
| 174 | switch label { | 216 | switch label { |
| 175 | case "local": "Your version, replaced" | 217 | case "local": "Your version, replaced" |
Tests/OrgProgramsTests/FileHistoryTests.swift added +59 · view
| @@ -0,0 +1,59 @@ | |||
| 1 | import Foundation | ||
| 2 | import OrgCore | ||
| 3 | import OrgDocument | ||
| 4 | import Testing | ||
| 5 | @testable import OrgApp | ||
| 6 | @testable import OrgPrograms | ||
| 7 | |||
| 8 | @Suite(.enabled(if: git != nil, "git isn't installed")) | ||
| 9 | struct FileHistoryTests { | ||
| 10 | @Test func commitsFollowARename() async throws { | ||
| 11 | let repo = try await Repository() | ||
| 12 | try repo.folder.write("old.org", "* One\n") | ||
| 13 | try await repo.commitAll("First") | ||
| 14 | try await repo.run("mv", "old.org", "new.org") | ||
| 15 | try await repo.commitAll("Rename") | ||
| 16 | try repo.folder.write("new.org", "* One\n* Two\n") | ||
| 17 | try repo.folder.write("other.org", "x\n") | ||
| 18 | try await repo.commitAll("Second") | ||
| 19 | |||
| 20 | let commits = await GitHistory.commits(for: repo.url.appendingPathComponent("new.org"), git: git) | ||
| 21 | #expect(commits.map(\.subject) == ["Second", "Rename", "First"]) | ||
| 22 | #expect(commits.map(\.path) == ["new.org", "new.org", "old.org"]) | ||
| 23 | #expect(commits.allSatisfy { $0.author == "Test" && $0.hash.count == 40 }) | ||
| 24 | #expect(await GitHistory.text(of: commits[2], git: git) == "* One\n") | ||
| 25 | #expect(await GitHistory.commits(for: repo.url.appendingPathComponent("missing.org"), git: git).isEmpty) | ||
| 26 | let outside = try Folder() | ||
| 27 | #expect(await GitHistory.commits(for: outside.url.appendingPathComponent("a.org"), git: git).isEmpty) | ||
| 28 | } | ||
| 29 | |||
| 30 | @Test func recoveryVersionsAndCommitsByDate() { | ||
| 31 | let commit = { (hash: String, seconds: TimeInterval) in | ||
| 32 | FileHistory.Commit(hash: hash, date: Date(timeIntervalSince1970: seconds), author: "A", subject: hash, path: "a.org", repository: URL(fileURLWithPath: "/r")) | ||
| 33 | } | ||
| 34 | let recovery = [(url: URL(fileURLWithPath: "/k/2"), date: Date(timeIntervalSince1970: 200), label: "snapshot"), | ||
| 35 | (url: URL(fileURLWithPath: "/k/1"), date: Date(timeIntervalSince1970: 50), label: "local")] | ||
| 36 | let merged = FileHistory.merged(recovery: recovery, commits: [commit("c3", 300), commit("c1", 100)]) | ||
| 37 | #expect(merged.map(\.date.timeIntervalSince1970) == [300, 200, 100, 50]) | ||
| 38 | #expect(merged[1] == .recovery(url: URL(fileURLWithPath: "/k/2"), date: Date(timeIntervalSince1970: 200), label: "snapshot")) | ||
| 39 | } | ||
| 40 | |||
| 41 | @MainActor | ||
| 42 | @Test func restoringACommitIsAnEdit() async throws { | ||
| 43 | let repo = try await Repository() | ||
| 44 | try repo.folder.write("a.org", "* A\nfirst\n") | ||
| 45 | try await repo.commitAll("First") | ||
| 46 | let file = try repo.folder.write("a.org", "* A\nnow\n") | ||
| 47 | let session = DocumentSession(recovery: FileRecoveryStore(directory: repo.url.appendingPathComponent(".git/r"))) | ||
| 48 | session.open(file.path) | ||
| 49 | let commits = await GitHistory.commits(for: file, git: git) | ||
| 50 | let first = try #require(commits.first) | ||
| 51 | let text = try #require(await GitHistory.text(of: first, git: git)) | ||
| 52 | #expect(session.restore(text: text) == nil) | ||
| 53 | #expect(session.document?.text == "* A\nfirst\n") | ||
| 54 | #expect(session.isDirty) | ||
| 55 | // The buffer as it was went to recovery; the file on disk is unchanged until saved. | ||
| 56 | #expect(session.recoveryVersions().contains { session.recoveryText($0.url) == "* A\nnow\n" }) | ||
| 57 | #expect(try String(contentsOf: file, encoding: .utf8) == "* A\nnow\n") | ||
| 58 | } | ||
| 59 | } | ||
docs/manual/guide/01-files-and-folders.org +5 −2 · view
| @@ -291,15 +291,18 @@ Each choice moves the copy to recovery and deletes it from the folder. The buffe | |||
| 291 | 291 | ||
| 292 | Whenever orgstar replaces a version of a file, it keeps a copy: your buffer when you take the disk version, the disk version when you keep yours, a version another program wrote while orgstar saved, and resolved Syncthing copies. It also keeps a snapshot of the file as it was before a save, at most once an hour, so there is a version of your own writing to go back to. orgstar keeps the last 20 replaced versions and the last 10 snapshots per file in =~/Library/Application Support/Orgstar/Recovery= (in the Mac App Store version, the same folder inside its container). | 292 | Whenever orgstar replaces a version of a file, it keeps a copy: your buffer when you take the disk version, the disk version when you keep yours, a version another program wrote while orgstar saved, and resolved Syncthing copies. It also keeps a snapshot of the file as it was before a save, at most once an hour, so there is a version of your own writing to go back to. orgstar keeps the last 20 replaced versions and the last 10 snapshots per file in =~/Library/Application Support/Orgstar/Recovery= (in the Mac App Store version, the same folder inside its container). |
| 293 | 293 | ||
| 294 | Choose File ▸ Recovery Versions… to see the open file's versions, newest first, each with its date and why it was kept: | 294 | Choose File ▸ History… to see the open file's versions, newest first, each with its date and why it was kept: |
| 295 | 295 | ||
| 296 | | Label | Meaning | | 296 | | Label | Meaning | |
| 297 | |-------------------------+-------------------------------------------------| | 297 | |-------------------------+-------------------------------------------------| |
| 298 | | Your version, replaced | Your buffer, before it was replaced | | 298 | | Your version, replaced | Your buffer, before it was replaced | |
| 299 | | Disk version, replaced | The file on disk, before orgstar wrote over it | | 299 | | Disk version, replaced | The file on disk, before orgstar wrote over it | |
| 300 | | Sync conflict copy | A Syncthing conflict copy you resolved | | 300 | | Sync conflict copy | A Syncthing conflict copy you resolved | |
| 301 | | Snapshot, before a save | The file as it was before a save | | ||
| 301 | 302 | ||
| 302 | Select a version to see how it differs from the buffer (=-= in the buffer, =+= in the kept version). =Restore= puts the kept version's text in the buffer as one edit, which undo reverses; the buffer as it was goes to recovery first. =Show in Finder= reveals the kept file. For a file with no kept versions the sheet says so. | 303 | In the download version, when the file is in a git repository, the list also has the commits that changed it, found with =git log --follow= so they reach past a rename, among the kept versions by date. A commit shows its subject, its short hash and its author. |
| 304 | |||
| 305 | Select a version to see how it differs from the buffer (=-= in the buffer, =+= in the selected version). =Restore= puts that version's text in the buffer as one edit, which undo reverses; the buffer as it was goes to recovery first. Restoring a commit changes only the buffer: nothing is checked out, and the file is written by the next save as usual. =Show in Finder= reveals a kept file. For a file with no versions the sheet says so. | ||
| 303 | 306 | ||
| 304 | ** Committing to git | 307 | ** Committing to git |
| 305 | 308 | ||
docs/manual/guide/03-keys.org +2 −2 · view
| @@ -96,7 +96,7 @@ The palette lists every command by title with its keys in the current keymap. Op | |||
| 96 | 96 | ||
| 97 | Type part of a title; matching is fuzzy and the best matches come first. =↑= and =↓= (or =C-p= and =C-n=) move the highlight, =Return= runs the highlighted command, a click runs any row, and =Esc= closes the palette. Quick Open (=⌘P=) works the same way. Each row shows up to two key sequences; in the Doom preset these are normal-state keys first, then insert-state keys. | 97 | Type part of a title; matching is fuzzy and the best matches come first. =↑= and =↓= (or =C-p= and =C-n=) move the highlight, =Return= runs the highlighted command, a click runs any row, and =Esc= closes the palette. Quick Open (=⌘P=) works the same way. Each row shows up to two key sequences; in the Doom preset these are normal-state keys first, then insert-state keys. |
| 98 | 98 | ||
| 99 | The palette leaves out text-system movement and editing commands (Forward Character, Kill Line, Set Mark and the like), which only make sense from keys. Every other command is in it, including the ones no preset binds, such as Show or Hide Backlinks, Import Table from File…, Recovery Versions… and Delete Property…. The Mac App Store version leaves out the Emacs exports and Attach File as Hard Link… and as Symbolic Link…; a key bound to Export to PDF with Emacs runs Export to PDF. Commands that cannot run at the caret show a message instead. | 99 | The palette leaves out text-system movement and editing commands (Forward Character, Kill Line, Set Mark and the like), which only make sense from keys. Every other command is in it, including the ones no preset binds, such as Show or Hide Backlinks, Import Table from File…, History… and Delete Property…. The Mac App Store version leaves out the Emacs exports and Attach File as Hard Link… and as Symbolic Link…; a key bound to Export to PDF with Emacs runs Export to PDF. Commands that cannot run at the caret show a message instead. |
| 100 | 100 | ||
| 101 | The Org menu in the menu bar lists every =org.= command with its keys in the current keymap, and is a way to find a key without the palette. Act at Point and Update at Point come first; the rest are in submenus by subject: Visibility, Headings, TODO and Tags, Properties and Columns, Dates and Timers, Lists, Tables, Links and Footnotes, Blocks and Text, followed by Attachments, Notes and Encryption, which hold the attachment, note and encryption commands. Its Clock submenu lists the clock commands the same way, followed by the recently clocked entries. The search field in the Help menu finds any menu item by name. | 101 | The Org menu in the menu bar lists every =org.= command with its keys in the current keymap, and is a way to find a key without the palette. Act at Point and Update at Point come first; the rest are in submenus by subject: Visibility, Headings, TODO and Tags, Properties and Columns, Dates and Timers, Lists, Tables, Links and Footnotes, Blocks and Text, followed by Attachments, Notes and Encryption, which hold the attachment, note and encryption commands. Its Clock submenu lists the clock commands the same way, followed by the recently clocked entries. The search field in the Help menu finds any menu item by name. |
| 102 | 102 | ||
| @@ -1197,7 +1197,7 @@ No preset binds these. Run them from the palette or a menu, or bind them in =key | |||
| 1197 | | Import from Emacs… (=app.import-emacs=) | Opens Import from Emacs…. | | 1197 | | Import from Emacs… (=app.import-emacs=) | Opens Import from Emacs…. | |
| 1198 | | Revert to File on Disk (=app.revert=) | Replaces the buffer with the file on disk; unsaved changes go to recovery (=revert-buffer=). | | 1198 | | Revert to File on Disk (=app.revert=) | Replaces the buffer with the file on disk; unsaved changes go to recovery (=revert-buffer=). | |
| 1199 | | Run Macro… (=macro.run=) | Asks for a named keyboard macro and plays it. Edit ▸ Macros ▸ Run Macro…. | | 1199 | | Run Macro… (=macro.run=) | Asks for a named keyboard macro and plays it. Edit ▸ Macros ▸ Run Macro…. | |
| 1200 | | Recovery Versions… (=app.recovery=) | Shows the recovery versions of the file. | | 1200 | | History… (=app.recovery=) | Shows the file's recovery versions and, in the download version, its git commits. Recovery Versions… on iOS. | |
| 1201 | | Resolve Sync Conflicts… (=app.sync-conflicts=) | Shows the file's sync conflict copies to resolve them. | | 1201 | | Resolve Sync Conflicts… (=app.sync-conflicts=) | Shows the file's sync conflict copies to resolve them. | |
| 1202 | | Import Table from File… (=app.table-import=) | Asks for a CSV, TSV or space-separated file and inserts it as a table (=org-table-import=). | | 1202 | | Import Table from File… (=app.table-import=) | Asks for a CSV, TSV or space-separated file and inserts it as a table (=org-table-import=). | |
| 1203 | | Export Table to File… (=app.table-export=) | Writes the table at point to a CSV or TSV file (=org-table-export=). | | 1203 | | Export Table to File… (=app.table-export=) | Writes the table at point to a CSV or TSV file (=org-table-export=). | |
docs/manual/guide/15-alongside-emacs.org +1 −1 · view
| @@ -111,7 +111,7 @@ Each file has a subfolder named from a hash of its path, holding its last 20 rep | |||
| 111 | | =sync-conflict= | A Syncthing conflict copy was resolved | | 111 | | =sync-conflict= | A Syncthing conflict copy was resolved | |
| 112 | | =snapshot= | A save changed the file and the last snapshot was more than an hour before | | 112 | | =snapshot= | A save changed the file and the last snapshot was more than an hour before | |
| 113 | 113 | ||
| 114 | File ▸ Recovery Versions… (on iOS, a toolbar button while there are versions, and in Commands) lists the open file's kept versions, newest first, each compared with the buffer (lines marked - in the buffer, + in the kept version). Restore puts a version's text in the buffer as an edit you can undo; the buffer as it was goes to the recovery folder first. On the Mac, Show in Finder selects the version's file. | 114 | File ▸ History… on the Mac, and Recovery Versions… on iOS (a toolbar button while there are versions, and in Commands), lists the open file's kept versions, newest first, each compared with the buffer (lines marked - in the buffer, + in the kept version). In the download version, History also lists the commits that changed the file when it is in a git repository. Restore puts a version's text in the buffer as an edit you can undo; the buffer as it was goes to the recovery folder first. On the Mac, Show in Finder selects the version's file. See [[file:01-files-and-folders.org::*Recovery versions][Recovery versions]] and, for committing to git as you save, [[file:01-files-and-folders.org::*Committing to git][Committing to git]]. |
| 115 | 115 | ||
| 116 | * Features that use Emacs on the Mac | 116 | * Features that use Emacs on the Mac |
| 117 | 117 | ||
docs/manual/install.org +1 −1 · view
| @@ -63,7 +63,7 @@ App Store version. | |||
| 63 | | Settings | In the app's container, or a folder you choose | =~/.config/orgstar= | | 63 | | Settings | In the app's container, or a folder you choose | =~/.config/orgstar= | |
| 64 | | Files outside your folders | After you grant access to their folder | Directly | | 64 | | Files outside your folders | After you grant access to their folder | Directly | |
| 65 | | Attachments | Copied, or moved from inside your folders | Copied, moved, linked or symlinked | | 65 | | Attachments | Copied, or moved from inside your folders | Copied, moved, linked or symlinked | |
| 66 | | Git | No | Commits as you save, with pull and push | | 66 | | Git | No | Commits as you save, with pull and push; commits in File ▸ History… | |
| 67 | | Updates | The Mac App Store | Built in, or Homebrew | | 67 | | Updates | The Mac App Store | Built in, or Homebrew | |
| 68 | | orgstar+ | In-app purchase, shared with iPhone and iPad | License key | | 68 | | orgstar+ | In-app purchase, shared with iPhone and iPad | License key | |
| 69 | 69 | ||
l10n/Localizable.xcstrings +137 · view
| @@ -19107,6 +19107,75 @@ | |||
| 19107 | } | 19107 | } |
| 19108 | } | 19108 | } |
| 19109 | }, | 19109 | }, |
| 19110 | "History": { | ||
| 19111 | "localizations": { | ||
| 19112 | "de": { | ||
| 19113 | "stringUnit": { | ||
| 19114 | "state": "translated", | ||
| 19115 | "value": "Verlauf" | ||
| 19116 | } | ||
| 19117 | }, | ||
| 19118 | "es": { | ||
| 19119 | "stringUnit": { | ||
| 19120 | "state": "translated", | ||
| 19121 | "value": "Historial" | ||
| 19122 | } | ||
| 19123 | }, | ||
| 19124 | "fr": { | ||
| 19125 | "stringUnit": { | ||
| 19126 | "state": "translated", | ||
| 19127 | "value": "Historique" | ||
| 19128 | } | ||
| 19129 | }, | ||
| 19130 | "ja": { | ||
| 19131 | "stringUnit": { | ||
| 19132 | "state": "translated", | ||
| 19133 | "value": "履歴" | ||
| 19134 | } | ||
| 19135 | }, | ||
| 19136 | "pt-BR": { | ||
| 19137 | "stringUnit": { | ||
| 19138 | "state": "translated", | ||
| 19139 | "value": "Histórico" | ||
| 19140 | } | ||
| 19141 | } | ||
| 19142 | } | ||
| 19143 | }, | ||
| 19144 | "History…": { | ||
| 19145 | "comment": "Command title", | ||
| 19146 | "localizations": { | ||
| 19147 | "de": { | ||
| 19148 | "stringUnit": { | ||
| 19149 | "state": "translated", | ||
| 19150 | "value": "Verlauf …" | ||
| 19151 | } | ||
| 19152 | }, | ||
| 19153 | "es": { | ||
| 19154 | "stringUnit": { | ||
| 19155 | "state": "translated", | ||
| 19156 | "value": "Historial…" | ||
| 19157 | } | ||
| 19158 | }, | ||
| 19159 | "fr": { | ||
| 19160 | "stringUnit": { | ||
| 19161 | "state": "translated", | ||
| 19162 | "value": "Historique…" | ||
| 19163 | } | ||
| 19164 | }, | ||
| 19165 | "ja": { | ||
| 19166 | "stringUnit": { | ||
| 19167 | "state": "translated", | ||
| 19168 | "value": "履歴…" | ||
| 19169 | } | ||
| 19170 | }, | ||
| 19171 | "pt-BR": { | ||
| 19172 | "stringUnit": { | ||
| 19173 | "state": "translated", | ||
| 19174 | "value": "Histórico…" | ||
| 19175 | } | ||
| 19176 | } | ||
| 19177 | } | ||
| 19178 | }, | ||
| 19110 | "Import": { | 19179 | "Import": { |
| 19111 | "localizations": { | 19180 | "localizations": { |
| 19112 | "de": { | 19181 | "de": { |
| @@ -21915,6 +21984,40 @@ | |||
| 21915 | } | 21984 | } |
| 21916 | } | 21985 | } |
| 21917 | }, | 21986 | }, |
| 21987 | "Lines marked - are in the buffer, + in the selected version.": { | ||
| 21988 | "localizations": { | ||
| 21989 | "de": { | ||
| 21990 | "stringUnit": { | ||
| 21991 | "state": "translated", | ||
| 21992 | "value": "Mit - markierte Zeilen stehen im Puffer, mit + in der ausgewählten Version." | ||
| 21993 | } | ||
| 21994 | }, | ||
| 21995 | "es": { | ||
| 21996 | "stringUnit": { | ||
| 21997 | "state": "translated", | ||
| 21998 | "value": "Las líneas marcadas con - están en el búfer, y con + en la versión seleccionada." | ||
| 21999 | } | ||
| 22000 | }, | ||
| 22001 | "fr": { | ||
| 22002 | "stringUnit": { | ||
| 22003 | "state": "translated", | ||
| 22004 | "value": "Les lignes marquées - sont dans le tampon, celles marquées + dans la version sélectionnée." | ||
| 22005 | } | ||
| 22006 | }, | ||
| 22007 | "ja": { | ||
| 22008 | "stringUnit": { | ||
| 22009 | "state": "translated", | ||
| 22010 | "value": "- の行はバッファに、+ の行は選択したバージョンにあります。" | ||
| 22011 | } | ||
| 22012 | }, | ||
| 22013 | "pt-BR": { | ||
| 22014 | "stringUnit": { | ||
| 22015 | "state": "translated", | ||
| 22016 | "value": "Linhas marcadas com - estão no buffer, com + na versão selecionada." | ||
| 22017 | } | ||
| 22018 | } | ||
| 22019 | } | ||
| 22020 | }, | ||
| 21918 | "Lines marked - are in the file, + in the copy. The copy goes to the recovery folder when it's resolved.": { | 22021 | "Lines marked - are in the file, + in the copy. The copy goes to the recovery folder when it's resolved.": { |
| 21919 | "localizations": { | 22022 | "localizations": { |
| 21920 | "de": { | 22023 | "de": { |
| @@ -25707,6 +25810,40 @@ | |||
| 25707 | } | 25810 | } |
| 25708 | } | 25811 | } |
| 25709 | }, | 25812 | }, |
| 25813 | "No History": { | ||
| 25814 | "localizations": { | ||
| 25815 | "de": { | ||
| 25816 | "stringUnit": { | ||
| 25817 | "state": "translated", | ||
| 25818 | "value": "Kein Verlauf" | ||
| 25819 | } | ||
| 25820 | }, | ||
| 25821 | "es": { | ||
| 25822 | "stringUnit": { | ||
| 25823 | "state": "translated", | ||
| 25824 | "value": "Sin historial" | ||
| 25825 | } | ||
| 25826 | }, | ||
| 25827 | "fr": { | ||
| 25828 | "stringUnit": { | ||
| 25829 | "state": "translated", | ||
| 25830 | "value": "Aucun historique" | ||
| 25831 | } | ||
| 25832 | }, | ||
| 25833 | "ja": { | ||
| 25834 | "stringUnit": { | ||
| 25835 | "state": "translated", | ||
| 25836 | "value": "履歴なし" | ||
| 25837 | } | ||
| 25838 | }, | ||
| 25839 | "pt-BR": { | ||
| 25840 | "stringUnit": { | ||
| 25841 | "state": "translated", | ||
| 25842 | "value": "Sem Histórico" | ||
| 25843 | } | ||
| 25844 | } | ||
| 25845 | } | ||
| 25846 | }, | ||
| 25710 | "No Keyword": { | 25847 | "No Keyword": { |
| 25711 | "localizations": { | 25848 | "localizations": { |
| 25712 | "de": { | 25849 | "de": { |