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