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