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