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