Sources/OrgCore/Keymap/Presets.swift
1041 lines · 28718 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 h"
194 command = "org.heading.toggle"
195 mode = "normal"
196 [[bind]]
197 keys = "SPC m i"
198 command = "org.item.toggle"
199 mode = "normal"
200 [[bind]]
201 keys = "SPC m l l"
202 command = "org.link.insert"
203 mode = "normal"
204 [[bind]]
205 keys = "SPC m l s"
206 command = "org.link.store"
207 mode = "normal"
208 [[bind]]
209 keys = "SPC m l i"
210 command = "org.id.store-link"
211 mode = "normal"
212 [[bind]]
213 keys = "SPC n l"
214 command = "org.link.store"
215 mode = "normal"
216 [[bind]]
217 keys = "SPC m t"
218 command = "org.todo.cycle"
219 mode = "normal"
220 [[bind]]
221 keys = "SPC m q"
222 command = "org.tags.set"
223 mode = "normal"
224 [[bind]]
225 keys = "SPC m x"
226 command = "org.checkbox.toggle"
227 mode = "normal"
228 [[bind]]
229 keys = "SPC m A"
230 command = "app.archive"
231 mode = "normal"
232 [[bind]]
233 keys = "SPC m e h h"
234 command = "app.export.html"
235 mode = "normal"
236 [[bind]]
237 keys = "SPC m e h o"
238 command = "app.export.html-open"
239 mode = "normal"
240 [[bind]]
241 keys = "SPC m e m m"
242 command = "app.export.markdown"
243 mode = "normal"
244 [[bind]]
245 keys = "SPC m e l p"
246 command = "app.export.pdf"
247 mode = "normal"
248 [[bind]]
249 keys = "SPC m d d"
250 command = "org.deadline"
251 mode = "normal"
252 [[bind]]
253 keys = "SPC m d s"
254 command = "org.schedule"
255 mode = "normal"
256 [[bind]]
257 keys = "SPC m d t"
258 command = "org.timestamp.active"
259 mode = "normal"
260 [[bind]]
261 keys = "SPC m d T"
262 command = "org.timestamp.inactive"
263 mode = "normal"
264 [[bind]]
265 keys = "SPC m r r"
266 command = "app.refile"
267 mode = "normal"
268 [[bind]]
269 keys = "SPC m s r"
270 command = "app.refile"
271 mode = "normal"
272 [[bind]]
273 keys = "SPC m s A"
274 command = "app.archive"
275 mode = "normal"
276 [[bind]]
277 keys = "SPC m s h"
278 command = "org.subtree.promote"
279 mode = "normal"
280 [[bind]]
281 keys = "SPC m s l"
282 command = "org.subtree.demote"
283 mode = "normal"
284 [[bind]]
285 keys = "SPC m s j"
286 command = "org.subtree.down"
287 mode = "normal"
288 [[bind]]
289 keys = "SPC m s k"
290 command = "org.subtree.up"
291 mode = "normal"
292 [[bind]]
293 keys = "SPC m c i"
294 command = "app.clock.in"
295 mode = "normal"
296 [[bind]]
297 keys = "SPC m c o"
298 command = "app.clock.out"
299 mode = "normal"
300 [[bind]]
301 keys = "SPC m c c"
302 command = "app.clock.cancel"
303 mode = "normal"
304 [[bind]]
305 keys = "SPC m c g"
306 command = "app.clock.goto"
307 mode = "normal"
308 [[bind]]
309 keys = "SPC m c R"
310 command = "app.clock.report"
311 mode = "normal"
312 [[bind]]
313 keys = "SPC m p u"
314 command = "org.priority.up"
315 mode = "normal"
316 [[bind]]
317 keys = "SPC m p d"
318 command = "org.priority.down"
319 mode = "normal"
320 [[bind]]
321 keys = "SPC m b -"
322 command = "org.table.insert-hline"
323 mode = "normal"
324 [[bind]]
325 keys = "SPC m b a"
326 command = "org.table.align"
327 mode = "normal"
328 [[bind]]
329 keys = "SPC m b r"
330 command = "org.table.recalc-all"
331 mode = "normal"
332 [[bind]]
333 keys = "SPC m b d c"
334 command = "org.table.delete-column"
335 mode = "normal"
336 [[bind]]
337 keys = "SPC m b d r"
338 command = "org.table.kill-row"
339 mode = "normal"
340 [[bind]]
341 keys = "SPC m b i c"
342 command = "org.table.insert-column"
343 mode = "normal"
344 [[bind]]
345 keys = "SPC m b i r"
346 command = "org.table.insert-row"
347 mode = "normal"
348 [[bind]]
349 keys = "SPC m b i h"
350 command = "org.table.insert-hline"
351 mode = "normal"
352
353 # evil-org and Doom's org keys
354 [[bind]]
355 keys = "TAB"
356 command = "org.cycle"
357 mode = "normal"
358 [[bind]]
359 keys = "S-TAB"
360 command = "org.cycle-global"
361 mode = "normal"
362 [[bind]]
363 keys = "RET"
364 command = "org.dwim"
365 mode = "normal"
366 [[bind]]
367 keys = "z a"
368 command = "org.cycle"
369 mode = "normal"
370 [[bind]]
371 keys = "z c"
372 command = "org.cycle"
373 mode = "normal"
374 [[bind]]
375 keys = "z o"
376 command = "org.cycle"
377 mode = "normal"
378 [[bind]]
379 keys = "z A"
380 command = "org.cycle-global"
381 mode = "normal"
382 [[bind]]
383 keys = "g h"
384 command = "org.heading.up"
385 mode = "normal"
386 [[bind]]
387 keys = "g j"
388 command = "org.heading.forward-same-level"
389 mode = "normal"
390 [[bind]]
391 keys = "g k"
392 command = "org.heading.backward-same-level"
393 mode = "normal"
394 [[bind]]
395 keys = "] h"
396 command = "org.heading.forward-same-level"
397 mode = "normal"
398 [[bind]]
399 keys = "[ h"
400 command = "org.heading.backward-same-level"
401 mode = "normal"
402 [[bind]]
403 keys = "RET"
404 command = "org.table.next-row"
405 when = "table"
406 mode = "insert"
407 [[bind]]
408 keys = "TAB"
409 command = "org.cycle"
410 mode = "visual"
411 [[bind]]
412 keys = "S-TAB"
413 command = "org.cycle-global"
414 mode = "visual"
415
416 # Insert state: org-cycle and org-shifttab with Doom's +org-indent-maybe-h, which
417 # demotes or promotes a heading and indents or outdents an item tree.
418 [[bind]]
419 keys = "S-TAB"
420 command = "org.cycle-global"
421 mode = "insert"
422 [[bind]]
423 keys = "TAB"
424 command = "org.table.next-field"
425 when = "table"
426 mode = "insert"
427 [[bind]]
428 keys = "S-TAB"
429 command = "org.table.previous-field"
430 when = "table"
431 mode = "insert"
432 [[bind]]
433 keys = "TAB"
434 command = "org.item.indent-tree"
435 when = "item"
436 mode = "insert"
437 [[bind]]
438 keys = "S-TAB"
439 command = "org.item.outdent-tree"
440 when = "item"
441 mode = "insert"
442 [[bind]]
443 keys = "TAB"
444 command = "org.heading.demote"
445 when = "heading"
446 mode = "insert"
447 [[bind]]
448 keys = "S-TAB"
449 command = "org.heading.promote"
450 when = "heading"
451 mode = "insert"
452
453 """
454
455
456 static let common = """
457 [[bind]]
458 keys = "TAB"
459 command = "org.cycle"
460 when = "heading"
461 [[bind]]
462 keys = "TAB"
463 command = "org.cycle"
464 when = "fold-line"
465
466 [[bind]]
467 keys = "S-TAB"
468 command = "org.cycle-global"
469 [[bind]]
470 keys = "TAB"
471 command = "org.table.next-field"
472 when = "table"
473 [[bind]]
474 keys = "S-TAB"
475 command = "org.table.previous-field"
476 when = "table"
477 [[bind]]
478 keys = "RET"
479 command = "org.table.next-row"
480 when = "table"
481
482 """
483
484 static let emacsBindings = """
485 # Movement and editing. With a mark set (C-SPC), movement extends the region.
486 [[bind]]
487 keys = "C-f"
488 command = "edit.forward-char"
489 [[bind]]
490 keys = "C-b"
491 command = "edit.backward-char"
492 [[bind]]
493 keys = "C-n"
494 command = "edit.next-line"
495 [[bind]]
496 keys = "C-p"
497 command = "edit.previous-line"
498 [[bind]]
499 keys = "C-a"
500 command = "edit.beginning-of-line"
501 [[bind]]
502 keys = "C-e"
503 command = "edit.end-of-line"
504 [[bind]]
505 keys = "M-f"
506 command = "edit.forward-word"
507 [[bind]]
508 keys = "M-b"
509 command = "edit.backward-word"
510 [[bind]]
511 keys = "M-<"
512 command = "edit.beginning-of-buffer"
513 [[bind]]
514 keys = "M->"
515 command = "edit.end-of-buffer"
516 [[bind]]
517 keys = "C-v"
518 command = "edit.scroll-up"
519 [[bind]]
520 keys = "M-v"
521 command = "edit.scroll-down"
522 [[bind]]
523 keys = "C-l"
524 command = "edit.recenter"
525 [[bind]]
526 keys = "C-d"
527 command = "edit.delete-char"
528 [[bind]]
529 keys = "M-d"
530 command = "edit.kill-word"
531 [[bind]]
532 keys = "M-DEL"
533 command = "edit.backward-kill-word"
534 [[bind]]
535 keys = "C-k"
536 command = "edit.kill-line"
537 [[bind]]
538 keys = "C-y"
539 command = "edit.yank"
540 [[bind]]
541 keys = "C-SPC"
542 command = "edit.set-mark"
543 [[bind]]
544 keys = "C-x h"
545 command = "edit.select-all"
546 [[bind]]
547 keys = "C-w"
548 command = "edit.kill-region"
549 [[bind]]
550 keys = "M-w"
551 command = "edit.copy-region"
552 [[bind]]
553 keys = "C-/"
554 command = "edit.undo"
555 [[bind]]
556 keys = "C-_"
557 command = "edit.undo"
558 [[bind]]
559 keys = "C-x u"
560 command = "edit.undo"
561 [[bind]]
562 keys = "C-g"
563 command = "edit.keyboard-quit"
564 [[bind]]
565 keys = "C-t"
566 command = "edit.transpose-chars"
567 [[bind]]
568 keys = "C-s"
569 command = "edit.find"
570 [[bind]]
571 keys = "C-r"
572 command = "edit.find"
573 [[bind]]
574 keys = "M-%"
575 command = "edit.replace"
576
577 # Files and commands
578 [[bind]]
579 keys = "C-x C-s"
580 command = "app.save"
581 [[bind]]
582 keys = "C-c C-o"
583 command = "org.link.open"
584 [[bind]]
585 keys = "C-c C-l"
586 command = "org.link.insert"
587 [[bind]]
588 keys = "C-c l"
589 command = "org.link.store"
590 [[bind]]
591 keys = "C-c ;"
592 command = "org.heading.toggle-comment"
593 [[bind]]
594 keys = "C-c *"
595 command = "org.heading.toggle"
596 [[bind]]
597 keys = "C-c -"
598 command = "org.item.toggle"
599 [[bind]]
600 keys = "C-c @"
601 command = "org.subtree.mark"
602 [[bind]]
603 keys = "C-x b"
604 command = "app.buffer.switch"
605 [[bind]]
606 keys = "C-x C-b"
607 command = "app.buffer.switch"
608 [[bind]]
609 keys = "C-x k"
610 command = "app.buffer.kill"
611 [[bind]]
612 keys = "C-x <right>"
613 command = "app.buffer.next"
614 [[bind]]
615 keys = "C-x <left>"
616 command = "app.buffer.previous"
617 [[bind]]
618 keys = "C-x s"
619 command = "app.save-all"
620 [[bind]]
621 keys = "C-x C-f"
622 command = "app.quick-open"
623 [[bind]]
624 keys = "M-x"
625 command = "app.palette"
626 [[bind]]
627 keys = "C-c a"
628 command = "app.agenda"
629 [[bind]]
630 keys = "C-c c"
631 command = "app.capture"
632 [[bind]]
633 keys = "C-c C-x C-i"
634 command = "app.clock.in"
635 [[bind]]
636 keys = "C-c C-x C-o"
637 command = "app.clock.out"
638 [[bind]]
639 keys = "C-c C-x C-q"
640 command = "app.clock.cancel"
641 [[bind]]
642 keys = "C-c C-x C-j"
643 command = "app.clock.goto"
644 [[bind]]
645 keys = "C-c C-e h h"
646 command = "app.export.html"
647 [[bind]]
648 keys = "C-c C-e h o"
649 command = "app.export.html-open"
650 [[bind]]
651 keys = "C-c C-e m m"
652 command = "app.export.markdown"
653 [[bind]]
654 keys = "C-c C-e l p"
655 command = "app.export.pdf"
656 [[bind]]
657 keys = "C-c C-e l l"
658 command = "app.export.latex"
659 [[bind]]
660 keys = "C-c C-e o o"
661 command = "app.export.odt"
662 [[bind]]
663 keys = "C-c C-e t u"
664 command = "app.export.text"
665
666 # Org
667 [[bind]]
668 keys = "C-c C-t"
669 command = "org.todo.cycle"
670 [[bind]]
671 keys = "S-<right>"
672 command = "org.todo.next"
673 when = "heading"
674 [[bind]]
675 keys = "S-<left>"
676 command = "org.todo.previous"
677 when = "heading"
678 [[bind]]
679 keys = "S-<up>"
680 command = "org.priority.up"
681 when = "heading"
682 [[bind]]
683 keys = "S-<down>"
684 command = "org.priority.down"
685 when = "heading"
686 [[bind]]
687 keys = "M-<left>"
688 command = "org.heading.promote"
689 when = "heading"
690 [[bind]]
691 keys = "M-<right>"
692 command = "org.heading.demote"
693 when = "heading"
694 [[bind]]
695 keys = "M-S-<left>"
696 command = "org.subtree.promote"
697 when = "heading"
698 [[bind]]
699 keys = "M-S-<right>"
700 command = "org.subtree.demote"
701 when = "heading"
702 [[bind]]
703 keys = "M-<up>"
704 command = "org.subtree.up"
705 when = "heading"
706 [[bind]]
707 keys = "M-<down>"
708 command = "org.subtree.down"
709 when = "heading"
710 [[bind]]
711 keys = "M-RET"
712 command = "org.heading.insert"
713 [[bind]]
714 keys = "C-RET"
715 command = "org.heading.insert-after-subtree"
716 [[bind]]
717 keys = "M-S-RET"
718 command = "org.heading.insert-todo"
719 [[bind]]
720 keys = "C-c C-n"
721 command = "org.heading.next"
722 [[bind]]
723 keys = "C-c C-p"
724 command = "org.heading.previous"
725 [[bind]]
726 keys = "C-c C-f"
727 command = "org.heading.forward-same-level"
728 [[bind]]
729 keys = "C-c C-b"
730 command = "org.heading.backward-same-level"
731 [[bind]]
732 keys = "C-c C-u"
733 command = "org.heading.up"
734 [[bind]]
735 keys = "C-c C-q"
736 command = "org.tags.set"
737 [[bind]]
738 keys = "M-RET"
739 command = "org.item.insert"
740 when = "item"
741 [[bind]]
742 keys = "M-S-RET"
743 command = "org.item.insert-checkbox"
744 when = "item"
745 [[bind]]
746 keys = "M-<left>"
747 command = "org.item.outdent"
748 when = "item"
749 [[bind]]
750 keys = "M-<right>"
751 command = "org.item.indent"
752 when = "item"
753 [[bind]]
754 keys = "M-S-<left>"
755 command = "org.item.outdent-tree"
756 when = "item"
757 [[bind]]
758 keys = "M-S-<right>"
759 command = "org.item.indent-tree"
760 when = "item"
761 [[bind]]
762 keys = "M-<up>"
763 command = "org.item.up"
764 when = "item"
765 [[bind]]
766 keys = "M-<down>"
767 command = "org.item.down"
768 when = "item"
769 [[bind]]
770 keys = "C-c C-c"
771 command = "org.checkbox.toggle"
772 when = "item"
773 [[bind]]
774 keys = "C-c C-x C-b"
775 command = "org.checkbox.toggle"
776 [[bind]]
777 keys = "C-c C-w"
778 command = "app.refile"
779 [[bind]]
780 keys = "C-c C-x C-s"
781 command = "app.archive"
782 [[bind]]
783 keys = "C-c $"
784 command = "app.archive"
785 [[bind]]
786 keys = "C-c ."
787 command = "org.timestamp.active"
788 [[bind]]
789 keys = "C-c !"
790 command = "org.timestamp.inactive"
791 [[bind]]
792 keys = "C-c C-s"
793 command = "org.schedule"
794 [[bind]]
795 keys = "C-c C-d"
796 command = "org.deadline"
797 [[bind]]
798 keys = "M-q"
799 command = "org.fill-paragraph"
800 [[bind]]
801 keys = "C-c C-c"
802 command = "org.table.align"
803 when = "table"
804 [[bind]]
805 keys = "C-c C-c"
806 command = "org.table.recalc-all"
807 when = "tblfm"
808 [[bind]]
809 keys = "C-c *"
810 command = "org.table.recalc"
811 when = "table"
812 [[bind]]
813 keys = "C-c C-c"
814 command = "org.babel.execute"
815 when = "src"
816 [[bind]]
817 keys = "M-<up>"
818 command = "org.table.row-up"
819 when = "table"
820 [[bind]]
821 keys = "M-<down>"
822 command = "org.table.row-down"
823 when = "table"
824 [[bind]]
825 keys = "M-<left>"
826 command = "org.table.column-left"
827 when = "table"
828 [[bind]]
829 keys = "M-<right>"
830 command = "org.table.column-right"
831 when = "table"
832 [[bind]]
833 keys = "M-S-<right>"
834 command = "org.table.insert-column"
835 when = "table"
836 [[bind]]
837 keys = "M-S-<left>"
838 command = "org.table.delete-column"
839 when = "table"
840 [[bind]]
841 keys = "M-S-<up>"
842 command = "org.table.kill-row"
843 when = "table"
844 [[bind]]
845 keys = "M-S-<down>"
846 command = "org.table.insert-row"
847 when = "table"
848 [[bind]]
849 keys = "C-c -"
850 command = "org.table.insert-hline"
851 when = "table"
852 [[bind]]
853 keys = "C-c |"
854 command = "org.table.create"
855 [[bind]]
856 keys = "S-<up>"
857 command = "org.timestamp.up"
858 when = "timestamp"
859 [[bind]]
860 keys = "S-<down>"
861 command = "org.timestamp.down"
862 when = "timestamp"
863 [[bind]]
864 keys = "S-<right>"
865 command = "org.timestamp.day-later"
866 when = "timestamp"
867 [[bind]]
868 keys = "S-<left>"
869 command = "org.timestamp.day-earlier"
870 when = "timestamp"
871
872 """
873
874 /// Standard Mac text keys stay as they are; org commands use Control-Command chords, which
875 /// macOS text editing leaves free.
876 static let macBindings = """
877 [[bind]]
878 keys = "C-TAB"
879 command = "app.buffer.next"
880 [[bind]]
881 keys = "C-S-TAB"
882 command = "app.buffer.previous"
883 [[bind]]
884 keys = "C-s-t"
885 command = "org.todo.cycle"
886 [[bind]]
887 keys = "C-s-<up>"
888 command = "org.priority.up"
889 [[bind]]
890 keys = "C-s-<down>"
891 command = "org.priority.down"
892 [[bind]]
893 keys = "C-s-<left>"
894 command = "org.heading.promote"
895 [[bind]]
896 keys = "C-s-<right>"
897 command = "org.heading.demote"
898 [[bind]]
899 keys = "C-M-s-<left>"
900 command = "org.subtree.promote"
901 [[bind]]
902 keys = "C-M-s-<right>"
903 command = "org.subtree.demote"
904 [[bind]]
905 keys = "C-M-s-<up>"
906 command = "org.subtree.up"
907 [[bind]]
908 keys = "C-M-s-<down>"
909 command = "org.subtree.down"
910 [[bind]]
911 keys = "s-RET"
912 command = "org.heading.insert"
913 [[bind]]
914 keys = "C-s-RET"
915 command = "org.heading.insert-after-subtree"
916 [[bind]]
917 keys = "s-S-RET"
918 command = "org.heading.insert-todo"
919 [[bind]]
920 keys = "M-s-<down>"
921 command = "org.heading.next"
922 [[bind]]
923 keys = "M-s-<up>"
924 command = "org.heading.previous"
925 [[bind]]
926 keys = "C-s-q"
927 command = "org.tags.set"
928 [[bind]]
929 keys = "s-RET"
930 command = "org.item.insert"
931 when = "item"
932 [[bind]]
933 keys = "s-S-RET"
934 command = "org.item.insert-checkbox"
935 when = "item"
936 [[bind]]
937 keys = "C-s-<left>"
938 command = "org.item.outdent"
939 when = "item"
940 [[bind]]
941 keys = "C-s-<right>"
942 command = "org.item.indent"
943 when = "item"
944 [[bind]]
945 keys = "C-M-s-<left>"
946 command = "org.item.outdent-tree"
947 when = "item"
948 [[bind]]
949 keys = "C-M-s-<right>"
950 command = "org.item.indent-tree"
951 when = "item"
952 [[bind]]
953 keys = "C-M-s-<up>"
954 command = "org.item.up"
955 when = "item"
956 [[bind]]
957 keys = "C-M-s-<down>"
958 command = "org.item.down"
959 when = "item"
960 [[bind]]
961 keys = "C-s-c"
962 command = "org.checkbox.toggle"
963 [[bind]]
964 keys = "C-s-w"
965 command = "app.refile"
966 [[bind]]
967 keys = "C-s-a"
968 command = "app.archive"
969 [[bind]]
970 keys = "C-s-."
971 command = "org.timestamp.active"
972 [[bind]]
973 keys = "C-M-s-."
974 command = "org.timestamp.inactive"
975 [[bind]]
976 keys = "C-s-s"
977 command = "org.schedule"
978 [[bind]]
979 keys = "C-s-d"
980 command = "org.deadline"
981 [[bind]]
982 keys = "C-s-p"
983 command = "org.fill-paragraph"
984 [[bind]]
985 keys = "C-s-<up>"
986 command = "org.table.row-up"
987 when = "table"
988 [[bind]]
989 keys = "C-s-<down>"
990 command = "org.table.row-down"
991 when = "table"
992 [[bind]]
993 keys = "C-s-<left>"
994 command = "org.table.column-left"
995 when = "table"
996 [[bind]]
997 keys = "C-s-<right>"
998 command = "org.table.column-right"
999 when = "table"
1000 [[bind]]
1001 keys = "C-M-s-<right>"
1002 command = "org.table.insert-column"
1003 when = "table"
1004 [[bind]]
1005 keys = "C-M-s-<left>"
1006 command = "org.table.delete-column"
1007 when = "table"
1008 [[bind]]
1009 keys = "C-M-s-<up>"
1010 command = "org.table.kill-row"
1011 when = "table"
1012 [[bind]]
1013 keys = "C-M-s-<down>"
1014 command = "org.table.insert-row"
1015 when = "table"
1016 [[bind]]
1017 keys = "C-s--"
1018 command = "org.table.insert-hline"
1019 when = "table"
1020 [[bind]]
1021 keys = "C-s-\\\\"
1022 command = "org.table.create"
1023 [[bind]]
1024 keys = "C-s-<up>"
1025 command = "org.timestamp.up"
1026 when = "timestamp"
1027 [[bind]]
1028 keys = "C-s-<down>"
1029 command = "org.timestamp.down"
1030 when = "timestamp"
1031 [[bind]]
1032 keys = "C-s-<right>"
1033 command = "org.timestamp.day-later"
1034 when = "timestamp"
1035 [[bind]]
1036 keys = "C-s-<left>"
1037 command = "org.timestamp.day-earlier"
1038 when = "timestamp"
1039
1040 """
1041}