Commit 53e00edef7

53e00edef707f97e790c6ab760329429b565e714

parent: 848c7b1302

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-11 09:24 UTC

iOS: refile from the editor

Refile… in the editor's Commands (C-c C-w on a hardware keyboard) opens the agenda's refile sheet for the entry at the caret.

Closes #55

Layout: unified · split

Sources/OrgstarMobile/EditorScreen.swift +25 −2
@@ -32,12 +32,13 @@ struct EditorScreen: View {
3232
3333 /// One sheet at a time: two presenters on this screen interfere.
3434 enum Sheet: Identifiable {
35 case palette, conflict, syncCopies, recovery
35 case palette, conflict, syncCopies, recovery, refile
3636 case block(BlockEdit)
3737
3838 var id: String {
3939 switch self {
4040 case .palette: "palette"
41 case .refile: "refile"
4142 case .conflict: "conflict"
4243 case .syncCopies: "syncCopies"
4344 case .recovery: "recovery"
@@ -105,6 +106,11 @@ struct EditorScreen: View {
105106 case .conflict: ConflictSheet(session: session)
106107 case .syncCopies: SyncConflictSheet(session: session) { message = $0 }
107108 case .recovery: RecoverySheet(session: session) { message = $0 }
109 case .refile:
110 RefileSheet(targets: workspace.refileTargets(openPath: session.path, document: session.document)) { target in
111 self.sheet = nil
112 if let target { refile(to: target) }
113 }
108114 case .block(let edit):
109115 BlockEditSheet(edit: edit, theme: MobileTheme(model.theme)) { content in
110116 self.sheet = nil
@@ -192,7 +198,9 @@ struct EditorScreen: View {
192198 editor.onRefreshSetup = { session.refreshSetup() }
193199 editor.onAgenda = { start, count in model.agendaRequest = .init(start: start, count: count) }
194200 editor.onAppCommand = { id in
195 if id == "app.toggle-markup" {
201 if id == "app.refile" {
202 sheet = .refile
203 } else if id == "app.toggle-markup" {
196204 model.showMarkup.toggle()
197205 } else if MobileEditor.linkCommands.contains(id) {
198206 link(id)
@@ -212,6 +220,20 @@ struct EditorScreen: View {
212220 }
213221}
214222
223extension EditorScreen {
224 /// `org-refile` of the entry at the caret, to a target worked out again from the files
225 /// now, as the agenda's Refile… does.
226 func refile(to target: RefileTarget) {
227 guard let editor, let path = session.path else { return }
228 let caret = editor.editContext().caret
229 guard let current = workspace.refileTargets(openPath: path, document: session.document).first(where: { $0.label == target.label }) else {
230 message = "Can't find \(target.label) any more."
231 return
232 }
233 message = session.refile(to: current, from: (path, caret))
234 }
235}
236
215237/// The editor's text view, with the Org key bar over the keyboard.
216238struct EditorTextView: UIViewRepresentable {
217239 let editor: MobileEditor
@@ -486,6 +508,7 @@ struct CommandPalette: View {
486508 ("app.clock.goto", "Go to Clocked Entry"), ("app.clock.in-recent", "Clock In to Recent Entry…"),
487509 ("app.clock.in-last", "Clock In to Last Entry"), ("app.clock.goto-recent", "Go to Recent Clocked Entry…"),
488510 ("app.clock.default", "Mark as Default Clock Task"), ("app.clock.resolve", "Resolve Open Clocks…"),
511 ("app.refile", "Refile…"),
489512 ("app.toggle-markup", "Show or Hide Markup"),
490513 ("org.toggle-inline-images", "Show or Hide Inline Images"), ("editor.toggle-truncate-lines", "Truncate or Wrap Long Lines"),
491514 ("org.table.toggle-column-width", "Shrink or Expand Table Column"), ("org.table.shrink", "Shrink Table Columns with Widths"),
Sources/OrgstarMobile/MobileEditor.swift +1
@@ -269,6 +269,7 @@ final class MobileEditor: NSObject, DocumentBuffer {
269269 case "org.cycle-global", "edit.undo", "edit.redo", "org.toggle-inline-images", "editor.toggle-truncate-lines": return true
270270 case "app.clock.in", "app.clock.out", "app.clock.cancel", "app.clock.goto", "app.clock.in-recent", "app.clock.in-last",
271271 "app.clock.goto-recent", "app.clock.default", "app.clock.resolve", "app.toggle-markup": return onAppCommand != nil
272 case "app.refile": return onAppCommand != nil && Presentation.heading(containing: context.caret, in: context.tree) != nil
272273 case _ where Self.linkCommands.contains(id): return onAppCommand != nil
273274 case "org.link.open": return OpenLinkAtPoint().applies(in: context)
274275 case "org.table.toggle-column-width", "org.table.shrink", "org.table.expand":
docs/manual/guide/14-ios.org +1 −1
@@ -376,4 +376,4 @@ Quick Look in the Files app shows org files as the HTML export renders them.
376376- The global capture hotkey and the Settings window.
377377- Explicit saving.
378378
379Commands the iOS app can't carry out show a message instead, such as "Not available on iOS yet" or "/Command/ isn't available on iPhone and iPad." Only tables that need Emacs say that Emacs is needed. Commands that only appear on the Mac, such as Refile from the editor, aren't listed in Commands; refile and archive from the agenda instead.
379Commands the iOS app can't carry out show a message instead, such as "Not available on iOS yet" or "/Command/ isn't available on iPhone and iPad." Only tables that need Emacs say that Emacs is needed. Commands that only appear on the Mac aren't listed in Commands. Refile… in Commands (or =C-c C-w= with a hardware keyboard) refiles the entry at the caret, choosing the target as the agenda's Refile… does.