Sources/OrgCore/Commands/OrgOnlyCommands.swift
28 lines · 1799 bytes
3 symbols in this file
1/// Commands that read or write org syntax in the open file, refused in Markdown and other
2/// text files so none of them writes org into one.
3public enum OrgOnlyCommands {
4 /// Visibility commands, which fold Markdown headings as they fold org ones.
5 public static func folds(_ id: String) -> Bool {
6 id == "org.cycle" || id == "org.cycle-global" || id.hasPrefix("org.fold.")
7 }
8
9 /// Whether `id` is refused in a file that isn't org; `markdown` lets the fold commands run.
10 public static func refuses(_ id: String, markdown: Bool) -> Bool {
11 if markdown, folds(id) { return false }
12 if id.hasPrefix("org.") || id.hasPrefix("app.attach.") { return true }
13 if id.hasPrefix("app.export.") { return !id.hasPrefix("app.export.icalendar-") }
14 return appCommands.contains(id)
15 }
16
17 /// App commands that act on the open file's entries, tables, links or Denote front matter.
18 static let appCommands: Set<String> = [
19 "app.refile", "app.refile.copy", "app.archive", "app.clock.in", "app.clock.default", "app.copy-rich-text",
20 "app.export-dialog", "app.export-subtree-dialog", "app.export-subtree", "app.export-body-only", "app.share-subtree",
21 "app.table-import", "app.table-export", "app.table-export.tsv", "app.plot",
22 "app.crypt.encrypt-entry", "app.crypt.encrypt-entries", "app.crypt.open-entry", "app.crypt.decrypt-entry",
23 "app.node.insert", "app.node.rename", "app.node.rename-from-front-matter",
24 "app.node.sequence-convert", "app.node.sequence-link", "app.node.sequence-rename-as-parent", "app.node.sequence-reparent",
25 "app.node.sequence-reparent-recursive", "app.node.sequence-new-child-of-current", "app.node.sequence-new-sibling-of-current",
26 "app.publish.current-file",
27 ]
28}