Sources/OrgCore/Keymap/Presets.swift
1107 lines · 30481 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 C-x C-r"
651 command = "org.clock.report"
652 [[bind]]
653 keys = "C-c C-x C-u"
654 command = "org.dblock.update"
655 [[bind]]
656 keys = "C-c C-x e"
657 command = "org.effort.set"
658 [[bind]]
659 keys = "C-c C-c"
660 command = "org.dblock.update"
661 when = "dblock"
662 [[bind]]
663 keys = "C-c C-,"
664 command = "org.structure-template"
665 [[bind]]
666 keys = "C-c '"
667 command = "org.edit-special"
668 [[bind]]
669 keys = "C-x b"
670 command = "app.buffer.switch"
671 [[bind]]
672 keys = "C-x C-b"
673 command = "app.buffer.switch"
674 [[bind]]
675 keys = "C-x k"
676 command = "app.buffer.kill"
677 [[bind]]
678 keys = "C-x <right>"
679 command = "app.buffer.next"
680 [[bind]]
681 keys = "C-x <left>"
682 command = "app.buffer.previous"
683 [[bind]]
684 keys = "C-x s"
685 command = "app.save-all"
686 [[bind]]
687 keys = "C-x C-f"
688 command = "app.quick-open"
689 [[bind]]
690 keys = "M-x"
691 command = "app.palette"
692 [[bind]]
693 keys = "C-c a"
694 command = "app.agenda"
695 [[bind]]
696 keys = "C-c c"
697 command = "app.capture"
698 [[bind]]
699 keys = "C-c C-x C-i"
700 command = "app.clock.in"
701 [[bind]]
702 keys = "C-c C-x C-o"
703 command = "app.clock.out"
704 [[bind]]
705 keys = "C-c C-x C-q"
706 command = "app.clock.cancel"
707 [[bind]]
708 keys = "C-c C-x C-j"
709 command = "app.clock.goto"
710 [[bind]]
711 keys = "C-c C-e h h"
712 command = "app.export.html"
713 [[bind]]
714 keys = "C-c C-e h o"
715 command = "app.export.html-open"
716 [[bind]]
717 keys = "C-c C-e m m"
718 command = "app.export.markdown"
719 [[bind]]
720 keys = "C-c C-e l p"
721 command = "app.export.pdf"
722 [[bind]]
723 keys = "C-c C-e l l"
724 command = "app.export.latex"
725 [[bind]]
726 keys = "C-c C-e o o"
727 command = "app.export.odt"
728 [[bind]]
729 keys = "C-c C-e t u"
730 command = "app.export.text"
731
732 # Org
733 [[bind]]
734 keys = "C-c C-t"
735 command = "org.todo.cycle"
736 [[bind]]
737 keys = "S-<right>"
738 command = "org.todo.next"
739 when = "heading"
740 [[bind]]
741 keys = "S-<left>"
742 command = "org.todo.previous"
743 when = "heading"
744 [[bind]]
745 keys = "S-<up>"
746 command = "org.priority.up"
747 when = "heading"
748 [[bind]]
749 keys = "S-<down>"
750 command = "org.priority.down"
751 when = "heading"
752 [[bind]]
753 keys = "M-<left>"
754 command = "org.heading.promote"
755 when = "heading"
756 [[bind]]
757 keys = "M-<right>"
758 command = "org.heading.demote"
759 when = "heading"
760 [[bind]]
761 keys = "M-S-<left>"
762 command = "org.subtree.promote"
763 when = "heading"
764 [[bind]]
765 keys = "M-S-<right>"
766 command = "org.subtree.demote"
767 when = "heading"
768 [[bind]]
769 keys = "M-<up>"
770 command = "org.subtree.up"
771 when = "heading"
772 [[bind]]
773 keys = "M-<down>"
774 command = "org.subtree.down"
775 when = "heading"
776 [[bind]]
777 keys = "M-RET"
778 command = "org.heading.insert"
779 [[bind]]
780 keys = "C-RET"
781 command = "org.heading.insert-after-subtree"
782 [[bind]]
783 keys = "M-S-RET"
784 command = "org.heading.insert-todo"
785 [[bind]]
786 keys = "C-c C-n"
787 command = "org.heading.next"
788 [[bind]]
789 keys = "C-c C-p"
790 command = "org.heading.previous"
791 [[bind]]
792 keys = "C-c C-f"
793 command = "org.heading.forward-same-level"
794 [[bind]]
795 keys = "C-c C-b"
796 command = "org.heading.backward-same-level"
797 [[bind]]
798 keys = "C-c C-u"
799 command = "org.heading.up"
800 [[bind]]
801 keys = "C-c C-q"
802 command = "org.tags.set"
803 [[bind]]
804 keys = "M-RET"
805 command = "org.item.insert"
806 when = "item"
807 [[bind]]
808 keys = "M-S-RET"
809 command = "org.item.insert-checkbox"
810 when = "item"
811 [[bind]]
812 keys = "M-<left>"
813 command = "org.item.outdent"
814 when = "item"
815 [[bind]]
816 keys = "M-<right>"
817 command = "org.item.indent"
818 when = "item"
819 [[bind]]
820 keys = "M-S-<left>"
821 command = "org.item.outdent-tree"
822 when = "item"
823 [[bind]]
824 keys = "M-S-<right>"
825 command = "org.item.indent-tree"
826 when = "item"
827 [[bind]]
828 keys = "M-<up>"
829 command = "org.item.up"
830 when = "item"
831 [[bind]]
832 keys = "M-<down>"
833 command = "org.item.down"
834 when = "item"
835 [[bind]]
836 keys = "C-c C-c"
837 command = "org.ctrl-c-ctrl-c"
838 when = "item"
839 [[bind]]
840 keys = "C-c C-x C-b"
841 command = "org.checkbox.toggle"
842 [[bind]]
843 keys = "C-c C-w"
844 command = "app.refile"
845 [[bind]]
846 keys = "C-c C-x C-s"
847 command = "app.archive"
848 [[bind]]
849 keys = "C-c $"
850 command = "app.archive"
851 [[bind]]
852 keys = "C-c ."
853 command = "org.timestamp.active"
854 [[bind]]
855 keys = "C-c !"
856 command = "org.timestamp.inactive"
857 [[bind]]
858 keys = "C-c C-s"
859 command = "org.schedule"
860 [[bind]]
861 keys = "C-c C-d"
862 command = "org.deadline"
863 [[bind]]
864 keys = "M-q"
865 command = "org.fill-paragraph"
866 [[bind]]
867 keys = "C-c C-c"
868 command = "org.table.align"
869 when = "table"
870 [[bind]]
871 keys = "C-c C-c"
872 command = "org.table.recalc-all"
873 when = "tblfm"
874 [[bind]]
875 keys = "C-c *"
876 command = "org.table.recalc"
877 when = "table"
878 [[bind]]
879 keys = "C-c C-c"
880 command = "org.babel.execute"
881 when = "src"
882 [[bind]]
883 keys = "M-<up>"
884 command = "org.table.row-up"
885 when = "table"
886 [[bind]]
887 keys = "M-<down>"
888 command = "org.table.row-down"
889 when = "table"
890 [[bind]]
891 keys = "M-<left>"
892 command = "org.table.column-left"
893 when = "table"
894 [[bind]]
895 keys = "M-<right>"
896 command = "org.table.column-right"
897 when = "table"
898 [[bind]]
899 keys = "M-S-<right>"
900 command = "org.table.insert-column"
901 when = "table"
902 [[bind]]
903 keys = "M-S-<left>"
904 command = "org.table.delete-column"
905 when = "table"
906 [[bind]]
907 keys = "M-S-<up>"
908 command = "org.table.kill-row"
909 when = "table"
910 [[bind]]
911 keys = "M-S-<down>"
912 command = "org.table.insert-row"
913 when = "table"
914 [[bind]]
915 keys = "C-c -"
916 command = "org.table.insert-hline"
917 when = "table"
918 [[bind]]
919 keys = "C-c |"
920 command = "org.table.create"
921 [[bind]]
922 keys = "S-<up>"
923 command = "org.timestamp.up"
924 when = "timestamp"
925 [[bind]]
926 keys = "S-<down>"
927 command = "org.timestamp.down"
928 when = "timestamp"
929 [[bind]]
930 keys = "S-<right>"
931 command = "org.timestamp.day-later"
932 when = "timestamp"
933 [[bind]]
934 keys = "S-<left>"
935 command = "org.timestamp.day-earlier"
936 when = "timestamp"
937
938 """
939
940 /// Standard Mac text keys stay as they are; org commands use Control-Command chords, which
941 /// macOS text editing leaves free.
942 static let macBindings = """
943 [[bind]]
944 keys = "C-TAB"
945 command = "app.buffer.next"
946 [[bind]]
947 keys = "C-S-TAB"
948 command = "app.buffer.previous"
949 [[bind]]
950 keys = "C-s-t"
951 command = "org.todo.cycle"
952 [[bind]]
953 keys = "C-s-<up>"
954 command = "org.priority.up"
955 [[bind]]
956 keys = "C-s-<down>"
957 command = "org.priority.down"
958 [[bind]]
959 keys = "C-s-<left>"
960 command = "org.heading.promote"
961 [[bind]]
962 keys = "C-s-<right>"
963 command = "org.heading.demote"
964 [[bind]]
965 keys = "C-M-s-<left>"
966 command = "org.subtree.promote"
967 [[bind]]
968 keys = "C-M-s-<right>"
969 command = "org.subtree.demote"
970 [[bind]]
971 keys = "C-M-s-<up>"
972 command = "org.subtree.up"
973 [[bind]]
974 keys = "C-M-s-<down>"
975 command = "org.subtree.down"
976 [[bind]]
977 keys = "s-RET"
978 command = "org.heading.insert"
979 [[bind]]
980 keys = "C-s-RET"
981 command = "org.heading.insert-after-subtree"
982 [[bind]]
983 keys = "s-S-RET"
984 command = "org.heading.insert-todo"
985 [[bind]]
986 keys = "M-s-<down>"
987 command = "org.heading.next"
988 [[bind]]
989 keys = "M-s-<up>"
990 command = "org.heading.previous"
991 [[bind]]
992 keys = "C-s-q"
993 command = "org.tags.set"
994 [[bind]]
995 keys = "s-RET"
996 command = "org.item.insert"
997 when = "item"
998 [[bind]]
999 keys = "s-S-RET"
1000 command = "org.item.insert-checkbox"
1001 when = "item"
1002 [[bind]]
1003 keys = "C-s-<left>"
1004 command = "org.item.outdent"
1005 when = "item"
1006 [[bind]]
1007 keys = "C-s-<right>"
1008 command = "org.item.indent"
1009 when = "item"
1010 [[bind]]
1011 keys = "C-M-s-<left>"
1012 command = "org.item.outdent-tree"
1013 when = "item"
1014 [[bind]]
1015 keys = "C-M-s-<right>"
1016 command = "org.item.indent-tree"
1017 when = "item"
1018 [[bind]]
1019 keys = "C-M-s-<up>"
1020 command = "org.item.up"
1021 when = "item"
1022 [[bind]]
1023 keys = "C-M-s-<down>"
1024 command = "org.item.down"
1025 when = "item"
1026 [[bind]]
1027 keys = "C-s-c"
1028 command = "org.checkbox.toggle"
1029 [[bind]]
1030 keys = "C-s-w"
1031 command = "app.refile"
1032 [[bind]]
1033 keys = "C-s-a"
1034 command = "app.archive"
1035 [[bind]]
1036 keys = "C-s-."
1037 command = "org.timestamp.active"
1038 [[bind]]
1039 keys = "C-M-s-."
1040 command = "org.timestamp.inactive"
1041 [[bind]]
1042 keys = "C-s-s"
1043 command = "org.schedule"
1044 [[bind]]
1045 keys = "C-s-d"
1046 command = "org.deadline"
1047 [[bind]]
1048 keys = "C-s-p"
1049 command = "org.fill-paragraph"
1050 [[bind]]
1051 keys = "C-s-<up>"
1052 command = "org.table.row-up"
1053 when = "table"
1054 [[bind]]
1055 keys = "C-s-<down>"
1056 command = "org.table.row-down"
1057 when = "table"
1058 [[bind]]
1059 keys = "C-s-<left>"
1060 command = "org.table.column-left"
1061 when = "table"
1062 [[bind]]
1063 keys = "C-s-<right>"
1064 command = "org.table.column-right"
1065 when = "table"
1066 [[bind]]
1067 keys = "C-M-s-<right>"
1068 command = "org.table.insert-column"
1069 when = "table"
1070 [[bind]]
1071 keys = "C-M-s-<left>"
1072 command = "org.table.delete-column"
1073 when = "table"
1074 [[bind]]
1075 keys = "C-M-s-<up>"
1076 command = "org.table.kill-row"
1077 when = "table"
1078 [[bind]]
1079 keys = "C-M-s-<down>"
1080 command = "org.table.insert-row"
1081 when = "table"
1082 [[bind]]
1083 keys = "C-s--"
1084 command = "org.table.insert-hline"
1085 when = "table"
1086 [[bind]]
1087 keys = "C-s-\\\\"
1088 command = "org.table.create"
1089 [[bind]]
1090 keys = "C-s-<up>"
1091 command = "org.timestamp.up"
1092 when = "timestamp"
1093 [[bind]]
1094 keys = "C-s-<down>"
1095 command = "org.timestamp.down"
1096 when = "timestamp"
1097 [[bind]]
1098 keys = "C-s-<right>"
1099 command = "org.timestamp.day-later"
1100 when = "timestamp"
1101 [[bind]]
1102 keys = "C-s-<left>"
1103 command = "org.timestamp.day-earlier"
1104 when = "timestamp"
1105
1106 """
1107}