Sources/OrgCore/Keymap/Presets.swift

3c38fb3fdcea0beb6b78f8548bfa8170debe1da4
orgstar/Sources/OrgCore/Keymap/Presets.swift history · blame · raw

988 lines · 27349 bytes

  1/// The keymaps the app ships. The user's `keymap.toml` is layered on top of the chosen one.
  2public enum KeymapPreset: String, Sendable, CaseIterable {
  3    case emacs, mac, doom
  4
  5    public var title: String {
  6        switch self {
  7        case .emacs: "Emacs"
  8        case .mac: "Mac"
  9        case .doom: "Doom (Vim keys)"
 10        }
 11    }
 12
 13    /// Whether the preset edits modally.
 14    public var isModal: Bool { self == .doom }
 15
 16    public var keymap: Keymap {
 17        var problems: [String] = []
 18        let map = try! Keymap(toml: toml, problems: &problems)
 19        precondition(problems.isEmpty, "preset \(rawValue): \(problems)")
 20        return map
 21    }
 22
 23    public var toml: String {
 24        switch self {
 25        case .emacs: Self.common + Self.emacsBindings
 26        case .mac: Self.common + Self.macBindings
 27        case .doom: Self.doomToml
 28        }
 29    }
 30
 31    /// Doom: the Emacs preset's org bindings in every evil state (as org-mode-map's are), with
 32    /// evil-org's `M-h/j/k/l` forms, then Doom's leader, localleader and evil-org keys.
 33    static var doomToml: String {
 34        var problems: [String] = []
 35        let emacs = try! Keymap(toml: common + emacsBindings, problems: &problems)
 36        let translations: [String: String] = ["<left>": "h", "<right>": "l", "<up>": "k", "<down>": "j"]
 37        var out = ""
 38        func bind(_ keys: String, _ command: String, when: String?, mode: String) {
 39            out += "[[bind]]\nkeys = \"\(keys.replacingOccurrences(of: "\\", with: "\\\\"))\"\ncommand = \"\(command)\"\n"
 40            if let when { out += "when = \"\(when)\"\n" }
 41            out += "mode = \"\(mode)\"\n"
 42        }
 43        for binding in emacs.bindings {
 44            let first = binding.keys[0]
 45            let keys = KeySequence.format(binding.keys)
 46            let orgKey = first.key == "c" && first.modifiers == [.control] || first.key == "x" && first.modifiers == [.control]
 47                || (first.modifiers.contains(.meta) && ["<left>", "<right>", "<up>", "<down>", "RET"].contains(first.key))
 48                || (first.modifiers.contains(.shift) && ["<left>", "<right>", "<up>", "<down>"].contains(first.key))
 49                || (first.modifiers == [.control] && first.key == "RET")
 50                || keys == "M-x"
 51            guard orgKey else { continue }
 52            for mode in ["normal", "insert", "visual"] { bind(keys, binding.command, when: binding.when, mode: mode) }
 53            // evil-org: M-h/j/k/l and M-H/J/K/L in normal, visual and insert.
 54            if binding.keys.count == 1, first.modifiers.contains(.meta), let letter = translations[first.key] {
 55                let shifted = first.modifiers.contains(.shift)
 56                let key = "M-" + (shifted ? letter.uppercased() : letter)
 57                for mode in ["normal", "insert", "visual"] { bind(key, binding.command, when: binding.when, mode: mode) }
 58            }
 59            // Doom: C-S-h/j/k/l are org-shift* in normal and insert.
 60            if binding.keys.count == 1, first.modifiers == [.shift], let letter = translations[first.key] {
 61                for mode in ["normal", "insert"] { bind("C-" + letter.uppercased(), binding.command, when: binding.when, mode: mode) }
 62            }
 63            // evil-org insert state: C-t demotes, C-d promotes.
 64            if binding.keys.count == 1, first.modifiers == [.meta], first.key == "<right>" || first.key == "<left>" {
 65                bind(first.key == "<right>" ? "C-t" : "C-d", binding.command, when: binding.when, mode: "insert")
 66            }
 67        }
 68        return out + doomBindings
 69    }
 70
 71    static let doomBindings = """
 72        # Leader
 73        [[bind]]
 74        keys = "SPC SPC"
 75        command = "app.quick-open"
 76        mode = "normal"
 77        [[bind]]
 78        keys = "SPC q q"
 79        command = "app.quit"
 80        mode = "normal"
 81        [[bind]]
 82        keys = "SPC ."
 83        command = "app.quick-open"
 84        mode = "normal"
 85        [[bind]]
 86        keys = "SPC f f"
 87        command = "app.quick-open"
 88        mode = "normal"
 89        [[bind]]
 90        keys = "SPC f s"
 91        command = "app.save"
 92        mode = "normal"
 93        # Buffers
 94        [[bind]]
 95        keys = "SPC b b"
 96        command = "app.buffer.switch"
 97        mode = "normal"
 98        [[bind]]
 99        keys = "SPC b B"
100        command = "app.buffer.switch"
101        mode = "normal"
102        [[bind]]
103        keys = "SPC ,"
104        command = "app.buffer.switch"
105        mode = "normal"
106        [[bind]]
107        keys = "SPC `"
108        command = "app.buffer.last"
109        mode = "normal"
110        [[bind]]
111        keys = "SPC b k"
112        command = "app.buffer.kill"
113        mode = "normal"
114        [[bind]]
115        keys = "SPC b d"
116        command = "app.buffer.kill"
117        mode = "normal"
118        [[bind]]
119        keys = "SPC b K"
120        command = "app.buffer.kill-all"
121        mode = "normal"
122        [[bind]]
123        keys = "SPC b O"
124        command = "app.buffer.kill-others"
125        mode = "normal"
126        [[bind]]
127        keys = "SPC b n"
128        command = "app.buffer.next"
129        mode = "normal"
130        [[bind]]
131        keys = "SPC b p"
132        command = "app.buffer.previous"
133        mode = "normal"
134        [[bind]]
135        keys = "SPC b ]"
136        command = "app.buffer.next"
137        mode = "normal"
138        [[bind]]
139        keys = "SPC b ["
140        command = "app.buffer.previous"
141        mode = "normal"
142        [[bind]]
143        keys = "] b"
144        command = "app.buffer.next"
145        mode = "normal"
146        [[bind]]
147        keys = "[ b"
148        command = "app.buffer.previous"
149        mode = "normal"
150        [[bind]]
151        keys = "SPC b s"
152        command = "app.save"
153        mode = "normal"
154        [[bind]]
155        keys = "SPC b S"
156        command = "app.save-all"
157        mode = "normal"
158        [[bind]]
159        keys = "SPC s s"
160        command = "edit.find"
161        mode = "normal"
162        [[bind]]
163        keys = "SPC /"
164        command = "app.search"
165        mode = "normal"
166        [[bind]]
167        keys = "SPC s p"
168        command = "app.search"
169        mode = "normal"
170        [[bind]]
171        keys = "SPC :"
172        command = "app.palette"
173        mode = "normal"
174        [[bind]]
175        keys = "SPC o a"
176        command = "app.agenda"
177        mode = "normal"
178        [[bind]]
179        keys = "SPC X"
180        command = "app.capture"
181        mode = "normal"
182        [[bind]]
183        keys = "SPC z t"
184        command = "app.clock.report"
185        mode = "normal"
186        [[bind]]
187        keys = "SPC h r r"
188        command = "app.reload-keymap"
189        mode = "normal"
190
191        # Localleader (SPC m)
192        [[bind]]
193        keys = "SPC m t"
194        command = "org.todo.cycle"
195        mode = "normal"
196        [[bind]]
197        keys = "SPC m q"
198        command = "org.tags.set"
199        mode = "normal"
200        [[bind]]
201        keys = "SPC m x"
202        command = "org.checkbox.toggle"
203        mode = "normal"
204        [[bind]]
205        keys = "SPC m A"
206        command = "app.archive"
207        mode = "normal"
208        [[bind]]
209        keys = "SPC m e h h"
210        command = "app.export.html"
211        mode = "normal"
212        [[bind]]
213        keys = "SPC m e h o"
214        command = "app.export.html-open"
215        mode = "normal"
216        [[bind]]
217        keys = "SPC m e m m"
218        command = "app.export.markdown"
219        mode = "normal"
220        [[bind]]
221        keys = "SPC m e l p"
222        command = "app.export.pdf"
223        mode = "normal"
224        [[bind]]
225        keys = "SPC m d d"
226        command = "org.deadline"
227        mode = "normal"
228        [[bind]]
229        keys = "SPC m d s"
230        command = "org.schedule"
231        mode = "normal"
232        [[bind]]
233        keys = "SPC m d t"
234        command = "org.timestamp.active"
235        mode = "normal"
236        [[bind]]
237        keys = "SPC m d T"
238        command = "org.timestamp.inactive"
239        mode = "normal"
240        [[bind]]
241        keys = "SPC m r r"
242        command = "app.refile"
243        mode = "normal"
244        [[bind]]
245        keys = "SPC m s r"
246        command = "app.refile"
247        mode = "normal"
248        [[bind]]
249        keys = "SPC m s A"
250        command = "app.archive"
251        mode = "normal"
252        [[bind]]
253        keys = "SPC m s h"
254        command = "org.subtree.promote"
255        mode = "normal"
256        [[bind]]
257        keys = "SPC m s l"
258        command = "org.subtree.demote"
259        mode = "normal"
260        [[bind]]
261        keys = "SPC m s j"
262        command = "org.subtree.down"
263        mode = "normal"
264        [[bind]]
265        keys = "SPC m s k"
266        command = "org.subtree.up"
267        mode = "normal"
268        [[bind]]
269        keys = "SPC m c i"
270        command = "app.clock.in"
271        mode = "normal"
272        [[bind]]
273        keys = "SPC m c o"
274        command = "app.clock.out"
275        mode = "normal"
276        [[bind]]
277        keys = "SPC m c c"
278        command = "app.clock.cancel"
279        mode = "normal"
280        [[bind]]
281        keys = "SPC m c g"
282        command = "app.clock.goto"
283        mode = "normal"
284        [[bind]]
285        keys = "SPC m c R"
286        command = "app.clock.report"
287        mode = "normal"
288        [[bind]]
289        keys = "SPC m p u"
290        command = "org.priority.up"
291        mode = "normal"
292        [[bind]]
293        keys = "SPC m p d"
294        command = "org.priority.down"
295        mode = "normal"
296        [[bind]]
297        keys = "SPC m b -"
298        command = "org.table.insert-hline"
299        mode = "normal"
300        [[bind]]
301        keys = "SPC m b a"
302        command = "org.table.align"
303        mode = "normal"
304        [[bind]]
305        keys = "SPC m b r"
306        command = "org.table.recalc-all"
307        mode = "normal"
308        [[bind]]
309        keys = "SPC m b d c"
310        command = "org.table.delete-column"
311        mode = "normal"
312        [[bind]]
313        keys = "SPC m b d r"
314        command = "org.table.kill-row"
315        mode = "normal"
316        [[bind]]
317        keys = "SPC m b i c"
318        command = "org.table.insert-column"
319        mode = "normal"
320        [[bind]]
321        keys = "SPC m b i r"
322        command = "org.table.insert-row"
323        mode = "normal"
324        [[bind]]
325        keys = "SPC m b i h"
326        command = "org.table.insert-hline"
327        mode = "normal"
328
329        # evil-org and Doom's org keys
330        [[bind]]
331        keys = "TAB"
332        command = "org.cycle"
333        mode = "normal"
334        [[bind]]
335        keys = "S-TAB"
336        command = "org.cycle-global"
337        mode = "normal"
338        [[bind]]
339        keys = "RET"
340        command = "org.dwim"
341        mode = "normal"
342        [[bind]]
343        keys = "z a"
344        command = "org.cycle"
345        mode = "normal"
346        [[bind]]
347        keys = "z c"
348        command = "org.cycle"
349        mode = "normal"
350        [[bind]]
351        keys = "z o"
352        command = "org.cycle"
353        mode = "normal"
354        [[bind]]
355        keys = "z A"
356        command = "org.cycle-global"
357        mode = "normal"
358        [[bind]]
359        keys = "g h"
360        command = "org.heading.up"
361        mode = "normal"
362        [[bind]]
363        keys = "g j"
364        command = "org.heading.forward-same-level"
365        mode = "normal"
366        [[bind]]
367        keys = "g k"
368        command = "org.heading.backward-same-level"
369        mode = "normal"
370        [[bind]]
371        keys = "] h"
372        command = "org.heading.forward-same-level"
373        mode = "normal"
374        [[bind]]
375        keys = "[ h"
376        command = "org.heading.backward-same-level"
377        mode = "normal"
378        [[bind]]
379        keys = "RET"
380        command = "org.table.next-row"
381        when = "table"
382        mode = "insert"
383        [[bind]]
384        keys = "TAB"
385        command = "org.cycle"
386        mode = "visual"
387        [[bind]]
388        keys = "S-TAB"
389        command = "org.cycle-global"
390        mode = "visual"
391
392        # Insert state: org-cycle and org-shifttab with Doom's +org-indent-maybe-h, which
393        # demotes or promotes a heading and indents or outdents an item tree.
394        [[bind]]
395        keys = "S-TAB"
396        command = "org.cycle-global"
397        mode = "insert"
398        [[bind]]
399        keys = "TAB"
400        command = "org.table.next-field"
401        when = "table"
402        mode = "insert"
403        [[bind]]
404        keys = "S-TAB"
405        command = "org.table.previous-field"
406        when = "table"
407        mode = "insert"
408        [[bind]]
409        keys = "TAB"
410        command = "org.item.indent-tree"
411        when = "item"
412        mode = "insert"
413        [[bind]]
414        keys = "S-TAB"
415        command = "org.item.outdent-tree"
416        when = "item"
417        mode = "insert"
418        [[bind]]
419        keys = "TAB"
420        command = "org.heading.demote"
421        when = "heading"
422        mode = "insert"
423        [[bind]]
424        keys = "S-TAB"
425        command = "org.heading.promote"
426        when = "heading"
427        mode = "insert"
428
429        """
430
431
432    static let common = """
433        [[bind]]
434        keys = "TAB"
435        command = "org.cycle"
436        when = "heading"
437
438        [[bind]]
439        keys = "S-TAB"
440        command = "org.cycle-global"
441        [[bind]]
442        keys = "TAB"
443        command = "org.table.next-field"
444        when = "table"
445        [[bind]]
446        keys = "S-TAB"
447        command = "org.table.previous-field"
448        when = "table"
449        [[bind]]
450        keys = "RET"
451        command = "org.table.next-row"
452        when = "table"
453
454        """
455
456    static let emacsBindings = """
457        # Movement and editing. With a mark set (C-SPC), movement extends the region.
458        [[bind]]
459        keys = "C-f"
460        command = "edit.forward-char"
461        [[bind]]
462        keys = "C-b"
463        command = "edit.backward-char"
464        [[bind]]
465        keys = "C-n"
466        command = "edit.next-line"
467        [[bind]]
468        keys = "C-p"
469        command = "edit.previous-line"
470        [[bind]]
471        keys = "C-a"
472        command = "edit.beginning-of-line"
473        [[bind]]
474        keys = "C-e"
475        command = "edit.end-of-line"
476        [[bind]]
477        keys = "M-f"
478        command = "edit.forward-word"
479        [[bind]]
480        keys = "M-b"
481        command = "edit.backward-word"
482        [[bind]]
483        keys = "M-<"
484        command = "edit.beginning-of-buffer"
485        [[bind]]
486        keys = "M->"
487        command = "edit.end-of-buffer"
488        [[bind]]
489        keys = "C-v"
490        command = "edit.scroll-up"
491        [[bind]]
492        keys = "M-v"
493        command = "edit.scroll-down"
494        [[bind]]
495        keys = "C-l"
496        command = "edit.recenter"
497        [[bind]]
498        keys = "C-d"
499        command = "edit.delete-char"
500        [[bind]]
501        keys = "M-d"
502        command = "edit.kill-word"
503        [[bind]]
504        keys = "M-DEL"
505        command = "edit.backward-kill-word"
506        [[bind]]
507        keys = "C-k"
508        command = "edit.kill-line"
509        [[bind]]
510        keys = "C-y"
511        command = "edit.yank"
512        [[bind]]
513        keys = "C-SPC"
514        command = "edit.set-mark"
515        [[bind]]
516        keys = "C-x h"
517        command = "edit.select-all"
518        [[bind]]
519        keys = "C-w"
520        command = "edit.kill-region"
521        [[bind]]
522        keys = "M-w"
523        command = "edit.copy-region"
524        [[bind]]
525        keys = "C-/"
526        command = "edit.undo"
527        [[bind]]
528        keys = "C-_"
529        command = "edit.undo"
530        [[bind]]
531        keys = "C-x u"
532        command = "edit.undo"
533        [[bind]]
534        keys = "C-g"
535        command = "edit.keyboard-quit"
536        [[bind]]
537        keys = "C-t"
538        command = "edit.transpose-chars"
539        [[bind]]
540        keys = "C-s"
541        command = "edit.find"
542        [[bind]]
543        keys = "C-r"
544        command = "edit.find"
545        [[bind]]
546        keys = "M-%"
547        command = "edit.replace"
548
549        # Files and commands
550        [[bind]]
551        keys = "C-x C-s"
552        command = "app.save"
553        [[bind]]
554        keys = "C-x b"
555        command = "app.buffer.switch"
556        [[bind]]
557        keys = "C-x C-b"
558        command = "app.buffer.switch"
559        [[bind]]
560        keys = "C-x k"
561        command = "app.buffer.kill"
562        [[bind]]
563        keys = "C-x <right>"
564        command = "app.buffer.next"
565        [[bind]]
566        keys = "C-x <left>"
567        command = "app.buffer.previous"
568        [[bind]]
569        keys = "C-x s"
570        command = "app.save-all"
571        [[bind]]
572        keys = "C-x C-f"
573        command = "app.quick-open"
574        [[bind]]
575        keys = "M-x"
576        command = "app.palette"
577        [[bind]]
578        keys = "C-c a"
579        command = "app.agenda"
580        [[bind]]
581        keys = "C-c c"
582        command = "app.capture"
583        [[bind]]
584        keys = "C-c C-x C-i"
585        command = "app.clock.in"
586        [[bind]]
587        keys = "C-c C-x C-o"
588        command = "app.clock.out"
589        [[bind]]
590        keys = "C-c C-x C-q"
591        command = "app.clock.cancel"
592        [[bind]]
593        keys = "C-c C-x C-j"
594        command = "app.clock.goto"
595        [[bind]]
596        keys = "C-c C-e h h"
597        command = "app.export.html"
598        [[bind]]
599        keys = "C-c C-e h o"
600        command = "app.export.html-open"
601        [[bind]]
602        keys = "C-c C-e m m"
603        command = "app.export.markdown"
604        [[bind]]
605        keys = "C-c C-e l p"
606        command = "app.export.pdf"
607        [[bind]]
608        keys = "C-c C-e l l"
609        command = "app.export.latex"
610        [[bind]]
611        keys = "C-c C-e o o"
612        command = "app.export.odt"
613        [[bind]]
614        keys = "C-c C-e t u"
615        command = "app.export.text"
616
617        # Org
618        [[bind]]
619        keys = "C-c C-t"
620        command = "org.todo.cycle"
621        [[bind]]
622        keys = "S-<right>"
623        command = "org.todo.cycle"
624        when = "heading"
625        [[bind]]
626        keys = "S-<up>"
627        command = "org.priority.up"
628        when = "heading"
629        [[bind]]
630        keys = "S-<down>"
631        command = "org.priority.down"
632        when = "heading"
633        [[bind]]
634        keys = "M-<left>"
635        command = "org.heading.promote"
636        when = "heading"
637        [[bind]]
638        keys = "M-<right>"
639        command = "org.heading.demote"
640        when = "heading"
641        [[bind]]
642        keys = "M-S-<left>"
643        command = "org.subtree.promote"
644        when = "heading"
645        [[bind]]
646        keys = "M-S-<right>"
647        command = "org.subtree.demote"
648        when = "heading"
649        [[bind]]
650        keys = "M-<up>"
651        command = "org.subtree.up"
652        when = "heading"
653        [[bind]]
654        keys = "M-<down>"
655        command = "org.subtree.down"
656        when = "heading"
657        [[bind]]
658        keys = "M-RET"
659        command = "org.heading.insert"
660        [[bind]]
661        keys = "C-RET"
662        command = "org.heading.insert-after-subtree"
663        [[bind]]
664        keys = "M-S-RET"
665        command = "org.heading.insert-todo"
666        [[bind]]
667        keys = "C-c C-n"
668        command = "org.heading.next"
669        [[bind]]
670        keys = "C-c C-p"
671        command = "org.heading.previous"
672        [[bind]]
673        keys = "C-c C-f"
674        command = "org.heading.forward-same-level"
675        [[bind]]
676        keys = "C-c C-b"
677        command = "org.heading.backward-same-level"
678        [[bind]]
679        keys = "C-c C-u"
680        command = "org.heading.up"
681        [[bind]]
682        keys = "C-c C-q"
683        command = "org.tags.set"
684        [[bind]]
685        keys = "M-RET"
686        command = "org.item.insert"
687        when = "item"
688        [[bind]]
689        keys = "M-S-RET"
690        command = "org.item.insert-checkbox"
691        when = "item"
692        [[bind]]
693        keys = "M-<left>"
694        command = "org.item.outdent"
695        when = "item"
696        [[bind]]
697        keys = "M-<right>"
698        command = "org.item.indent"
699        when = "item"
700        [[bind]]
701        keys = "M-S-<left>"
702        command = "org.item.outdent-tree"
703        when = "item"
704        [[bind]]
705        keys = "M-S-<right>"
706        command = "org.item.indent-tree"
707        when = "item"
708        [[bind]]
709        keys = "M-<up>"
710        command = "org.item.up"
711        when = "item"
712        [[bind]]
713        keys = "M-<down>"
714        command = "org.item.down"
715        when = "item"
716        [[bind]]
717        keys = "C-c C-c"
718        command = "org.checkbox.toggle"
719        when = "item"
720        [[bind]]
721        keys = "C-c C-x C-b"
722        command = "org.checkbox.toggle"
723        [[bind]]
724        keys = "C-c C-w"
725        command = "app.refile"
726        [[bind]]
727        keys = "C-c C-x C-s"
728        command = "app.archive"
729        [[bind]]
730        keys = "C-c $"
731        command = "app.archive"
732        [[bind]]
733        keys = "C-c ."
734        command = "org.timestamp.active"
735        [[bind]]
736        keys = "C-c !"
737        command = "org.timestamp.inactive"
738        [[bind]]
739        keys = "C-c C-s"
740        command = "org.schedule"
741        [[bind]]
742        keys = "C-c C-d"
743        command = "org.deadline"
744        [[bind]]
745        keys = "M-q"
746        command = "org.fill-paragraph"
747        [[bind]]
748        keys = "C-c C-c"
749        command = "org.table.align"
750        when = "table"
751        [[bind]]
752        keys = "C-c C-c"
753        command = "org.table.recalc-all"
754        when = "tblfm"
755        [[bind]]
756        keys = "C-c *"
757        command = "org.table.recalc"
758        when = "table"
759        [[bind]]
760        keys = "C-c C-c"
761        command = "org.babel.execute"
762        when = "src"
763        [[bind]]
764        keys = "M-<up>"
765        command = "org.table.row-up"
766        when = "table"
767        [[bind]]
768        keys = "M-<down>"
769        command = "org.table.row-down"
770        when = "table"
771        [[bind]]
772        keys = "M-<left>"
773        command = "org.table.column-left"
774        when = "table"
775        [[bind]]
776        keys = "M-<right>"
777        command = "org.table.column-right"
778        when = "table"
779        [[bind]]
780        keys = "M-S-<right>"
781        command = "org.table.insert-column"
782        when = "table"
783        [[bind]]
784        keys = "M-S-<left>"
785        command = "org.table.delete-column"
786        when = "table"
787        [[bind]]
788        keys = "M-S-<up>"
789        command = "org.table.kill-row"
790        when = "table"
791        [[bind]]
792        keys = "M-S-<down>"
793        command = "org.table.insert-row"
794        when = "table"
795        [[bind]]
796        keys = "C-c -"
797        command = "org.table.insert-hline"
798        when = "table"
799        [[bind]]
800        keys = "C-c |"
801        command = "org.table.create"
802        [[bind]]
803        keys = "S-<up>"
804        command = "org.timestamp.up"
805        when = "timestamp"
806        [[bind]]
807        keys = "S-<down>"
808        command = "org.timestamp.down"
809        when = "timestamp"
810        [[bind]]
811        keys = "S-<right>"
812        command = "org.timestamp.day-later"
813        when = "timestamp"
814        [[bind]]
815        keys = "S-<left>"
816        command = "org.timestamp.day-earlier"
817        when = "timestamp"
818
819        """
820
821    /// Standard Mac text keys stay as they are; org commands use Control-Command chords, which
822    /// macOS text editing leaves free.
823    static let macBindings = """
824        [[bind]]
825        keys = "C-TAB"
826        command = "app.buffer.next"
827        [[bind]]
828        keys = "C-S-TAB"
829        command = "app.buffer.previous"
830        [[bind]]
831        keys = "C-s-t"
832        command = "org.todo.cycle"
833        [[bind]]
834        keys = "C-s-<up>"
835        command = "org.priority.up"
836        [[bind]]
837        keys = "C-s-<down>"
838        command = "org.priority.down"
839        [[bind]]
840        keys = "C-s-<left>"
841        command = "org.heading.promote"
842        [[bind]]
843        keys = "C-s-<right>"
844        command = "org.heading.demote"
845        [[bind]]
846        keys = "C-M-s-<left>"
847        command = "org.subtree.promote"
848        [[bind]]
849        keys = "C-M-s-<right>"
850        command = "org.subtree.demote"
851        [[bind]]
852        keys = "C-M-s-<up>"
853        command = "org.subtree.up"
854        [[bind]]
855        keys = "C-M-s-<down>"
856        command = "org.subtree.down"
857        [[bind]]
858        keys = "s-RET"
859        command = "org.heading.insert"
860        [[bind]]
861        keys = "C-s-RET"
862        command = "org.heading.insert-after-subtree"
863        [[bind]]
864        keys = "s-S-RET"
865        command = "org.heading.insert-todo"
866        [[bind]]
867        keys = "M-s-<down>"
868        command = "org.heading.next"
869        [[bind]]
870        keys = "M-s-<up>"
871        command = "org.heading.previous"
872        [[bind]]
873        keys = "C-s-q"
874        command = "org.tags.set"
875        [[bind]]
876        keys = "s-RET"
877        command = "org.item.insert"
878        when = "item"
879        [[bind]]
880        keys = "s-S-RET"
881        command = "org.item.insert-checkbox"
882        when = "item"
883        [[bind]]
884        keys = "C-s-<left>"
885        command = "org.item.outdent"
886        when = "item"
887        [[bind]]
888        keys = "C-s-<right>"
889        command = "org.item.indent"
890        when = "item"
891        [[bind]]
892        keys = "C-M-s-<left>"
893        command = "org.item.outdent-tree"
894        when = "item"
895        [[bind]]
896        keys = "C-M-s-<right>"
897        command = "org.item.indent-tree"
898        when = "item"
899        [[bind]]
900        keys = "C-M-s-<up>"
901        command = "org.item.up"
902        when = "item"
903        [[bind]]
904        keys = "C-M-s-<down>"
905        command = "org.item.down"
906        when = "item"
907        [[bind]]
908        keys = "C-s-c"
909        command = "org.checkbox.toggle"
910        [[bind]]
911        keys = "C-s-w"
912        command = "app.refile"
913        [[bind]]
914        keys = "C-s-a"
915        command = "app.archive"
916        [[bind]]
917        keys = "C-s-."
918        command = "org.timestamp.active"
919        [[bind]]
920        keys = "C-M-s-."
921        command = "org.timestamp.inactive"
922        [[bind]]
923        keys = "C-s-s"
924        command = "org.schedule"
925        [[bind]]
926        keys = "C-s-d"
927        command = "org.deadline"
928        [[bind]]
929        keys = "C-s-p"
930        command = "org.fill-paragraph"
931        [[bind]]
932        keys = "C-s-<up>"
933        command = "org.table.row-up"
934        when = "table"
935        [[bind]]
936        keys = "C-s-<down>"
937        command = "org.table.row-down"
938        when = "table"
939        [[bind]]
940        keys = "C-s-<left>"
941        command = "org.table.column-left"
942        when = "table"
943        [[bind]]
944        keys = "C-s-<right>"
945        command = "org.table.column-right"
946        when = "table"
947        [[bind]]
948        keys = "C-M-s-<right>"
949        command = "org.table.insert-column"
950        when = "table"
951        [[bind]]
952        keys = "C-M-s-<left>"
953        command = "org.table.delete-column"
954        when = "table"
955        [[bind]]
956        keys = "C-M-s-<up>"
957        command = "org.table.kill-row"
958        when = "table"
959        [[bind]]
960        keys = "C-M-s-<down>"
961        command = "org.table.insert-row"
962        when = "table"
963        [[bind]]
964        keys = "C-s--"
965        command = "org.table.insert-hline"
966        when = "table"
967        [[bind]]
968        keys = "C-s-\\\\"
969        command = "org.table.create"
970        [[bind]]
971        keys = "C-s-<up>"
972        command = "org.timestamp.up"
973        when = "timestamp"
974        [[bind]]
975        keys = "C-s-<down>"
976        command = "org.timestamp.down"
977        when = "timestamp"
978        [[bind]]
979        keys = "C-s-<right>"
980        command = "org.timestamp.day-later"
981        when = "timestamp"
982        [[bind]]
983        keys = "C-s-<left>"
984        command = "org.timestamp.day-earlier"
985        when = "timestamp"
986
987        """
988}