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