Sources/OrgCore/Keymap/Presets.swift
1169 lines · 33134 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.speedBindings(mode: nil) + Self.emacsBindings
26 case .mac: Self.common + Self.speedBindings(mode: nil) + Self.macBindings
27 case .doom: Self.doomToml + Self.speedBindings(mode: "insert")
28 }
29 }
30
31 /// `org-speed-commands`, for the start of a heading line when `org-use-speed-commands` is on.
32 static let speedCommands: [(key: String, command: String)] = [
33 ("n", "org.heading.next"), ("p", "org.heading.previous"), ("f", "org.heading.forward-same-level"),
34 ("b", "org.heading.backward-same-level"), ("u", "org.heading.up"), ("j", "org.goto"),
35 ("c", "org.cycle"), ("C", "org.cycle-global"), ("s", "org.narrow.toggle"), ("k", "org.subtree.cut"),
36 ("U", "org.subtree.up"), ("D", "org.subtree.down"), ("r", "org.heading.demote"), ("l", "org.heading.promote"),
37 ("R", "org.subtree.demote"), ("L", "org.subtree.promote"), ("i", "org.heading.insert-after-subtree"),
38 ("^", "org.sort"), ("w", "app.refile"), ("a", "app.archive"), ("@", "org.subtree.mark"),
39 ("#", "org.heading.toggle-comment"), ("I", "app.clock.in"), ("O", "app.clock.out"), ("t", "org.todo.cycle"),
40 (",", "org.priority.set"), ("0", "org.priority.remove"), ("1", "org.priority.set-a"), ("2", "org.priority.set-b"),
41 ("3", "org.priority.set-c"), (":", "org.tags.set"), ("e", "org.effort.set"), ("v", "app.agenda"),
42 ("/", "org.sparse-tree"), ("o", "org.link.open"),
43 ]
44
45 static func speedBindings(mode: String?) -> String {
46 speedCommands.map { key, command in
47 "[[bind]]\nkeys = \"\(key)\"\ncommand = \"\(command)\"\nwhen = \"speed\"\n" + (mode.map { "mode = \"\($0)\"\n" } ?? "")
48 }.joined()
49 }
50
51 /// Doom: the Emacs preset's org bindings in every evil state (as org-mode-map's are), with
52 /// evil-org's `M-h/j/k/l` forms, then Doom's leader, localleader and evil-org keys.
53 static var doomToml: String {
54 var problems: [String] = []
55 let emacs = try! Keymap(toml: common + emacsBindings, problems: &problems)
56 let translations: [String: String] = ["<left>": "h", "<right>": "l", "<up>": "k", "<down>": "j"]
57 var out = ""
58 func bind(_ keys: String, _ command: String, when: String?, mode: String) {
59 out += "[[bind]]\nkeys = \"\(keys.replacingOccurrences(of: "\\", with: "\\\\"))\"\ncommand = \"\(command)\"\n"
60 if let when { out += "when = \"\(when)\"\n" }
61 out += "mode = \"\(mode)\"\n"
62 }
63 for binding in emacs.bindings {
64 let first = binding.keys[0]
65 let keys = KeySequence.format(binding.keys)
66 let orgKey = first.key == "c" && first.modifiers == [.control] || first.key == "x" && first.modifiers == [.control]
67 || (first.modifiers.contains(.meta) && ["<left>", "<right>", "<up>", "<down>", "RET"].contains(first.key))
68 || (first.modifiers.contains(.shift) && ["<left>", "<right>", "<up>", "<down>"].contains(first.key))
69 || (first.modifiers == [.control] && first.key == "RET")
70 || keys == "M-x"
71 guard orgKey else { continue }
72 for mode in ["normal", "insert", "visual"] { bind(keys, binding.command, when: binding.when, mode: mode) }
73 // evil-org: M-h/j/k/l and M-H/J/K/L in normal, visual and insert.
74 if binding.keys.count == 1, first.modifiers.contains(.meta), let letter = translations[first.key] {
75 let shifted = first.modifiers.contains(.shift)
76 let key = "M-" + (shifted ? letter.uppercased() : letter)
77 for mode in ["normal", "insert", "visual"] { bind(key, binding.command, when: binding.when, mode: mode) }
78 }
79 // Doom: C-S-h/j/k/l are org-shift* in normal and insert.
80 if binding.keys.count == 1, first.modifiers == [.shift], let letter = translations[first.key] {
81 for mode in ["normal", "insert"] { bind("C-" + letter.uppercased(), binding.command, when: binding.when, mode: mode) }
82 }
83 // evil-org insert state: C-t demotes, C-d promotes.
84 if binding.keys.count == 1, first.modifiers == [.meta], first.key == "<right>" || first.key == "<left>" {
85 bind(first.key == "<right>" ? "C-t" : "C-d", binding.command, when: binding.when, mode: "insert")
86 }
87 }
88 return out + doomBindings
89 }
90
91 static let doomBindings = """
92 # Leader
93 [[bind]]
94 keys = "SPC SPC"
95 command = "app.quick-open"
96 mode = "normal"
97 [[bind]]
98 keys = "SPC q q"
99 command = "app.quit"
100 mode = "normal"
101 [[bind]]
102 keys = "SPC ."
103 command = "app.quick-open"
104 mode = "normal"
105 [[bind]]
106 keys = "SPC f f"
107 command = "app.quick-open"
108 mode = "normal"
109 [[bind]]
110 keys = "SPC f s"
111 command = "app.save"
112 mode = "normal"
113 # Buffers
114 [[bind]]
115 keys = "SPC b b"
116 command = "app.buffer.switch"
117 mode = "normal"
118 [[bind]]
119 keys = "SPC b B"
120 command = "app.buffer.switch"
121 mode = "normal"
122 [[bind]]
123 keys = "SPC ,"
124 command = "app.buffer.switch"
125 mode = "normal"
126 [[bind]]
127 keys = "SPC `"
128 command = "app.buffer.last"
129 mode = "normal"
130 [[bind]]
131 keys = "SPC b k"
132 command = "app.buffer.kill"
133 mode = "normal"
134 [[bind]]
135 keys = "SPC b d"
136 command = "app.buffer.kill"
137 mode = "normal"
138 [[bind]]
139 keys = "SPC b K"
140 command = "app.buffer.kill-all"
141 mode = "normal"
142 [[bind]]
143 keys = "SPC b O"
144 command = "app.buffer.kill-others"
145 mode = "normal"
146 [[bind]]
147 keys = "SPC b n"
148 command = "app.buffer.next"
149 mode = "normal"
150 [[bind]]
151 keys = "SPC b p"
152 command = "app.buffer.previous"
153 mode = "normal"
154 [[bind]]
155 keys = "SPC b ]"
156 command = "app.buffer.next"
157 mode = "normal"
158 [[bind]]
159 keys = "SPC b ["
160 command = "app.buffer.previous"
161 mode = "normal"
162 [[bind]]
163 keys = "] b"
164 command = "app.buffer.next"
165 mode = "normal"
166 [[bind]]
167 keys = "[ b"
168 command = "app.buffer.previous"
169 mode = "normal"
170 [[bind]]
171 keys = "SPC b s"
172 command = "app.save"
173 mode = "normal"
174 [[bind]]
175 keys = "SPC b S"
176 command = "app.save-all"
177 mode = "normal"
178 [[bind]]
179 keys = "SPC s s"
180 command = "edit.find"
181 mode = "normal"
182 [[bind]]
183 keys = "SPC /"
184 command = "app.search"
185 mode = "normal"
186 [[bind]]
187 keys = "SPC s p"
188 command = "app.search"
189 mode = "normal"
190 [[bind]]
191 keys = "SPC :"
192 command = "app.palette"
193 mode = "normal"
194 [[bind]]
195 keys = "SPC o a"
196 command = "app.agenda"
197 mode = "normal"
198 [[bind]]
199 keys = "SPC X"
200 command = "app.capture"
201 mode = "normal"
202 [[bind]]
203 keys = "SPC z t"
204 command = "app.clock.report"
205 mode = "normal"
206 [[bind]]
207 keys = "SPC h r r"
208 command = "app.reload-keymap"
209 mode = "normal"
210
211 # Localleader (SPC m)
212 [[bind]]
213 keys = "SPC m '"
214 command = "org.edit-special"
215 mode = "normal"
216 [[bind]]
217 keys = "SPC m s c"
218 command = "org.subtree.clone"
219 mode = "normal"
220 [[bind]]
221 keys = "SPC m s d"
222 command = "org.subtree.cut"
223 mode = "normal"
224 [[bind]]
225 keys = "SPC m s S"
226 command = "org.sort"
227 mode = "normal"
228 [[bind]]
229 keys = "SPC m s n"
230 command = "org.narrow.subtree"
231 mode = "normal"
232 [[bind]]
233 keys = "SPC m s s"
234 command = "org.sparse-tree"
235 mode = "normal"
236 [[bind]]
237 keys = "SPC m s N"
238 command = "org.widen"
239 mode = "normal"
240 [[bind]]
241 keys = "SPC m ."
242 command = "org.goto"
243 mode = "normal"
244 [[bind]]
245 keys = "SPC m h"
246 command = "org.heading.toggle"
247 mode = "normal"
248 [[bind]]
249 keys = "SPC m i"
250 command = "org.item.toggle"
251 mode = "normal"
252 [[bind]]
253 keys = "SPC m l l"
254 command = "org.link.insert"
255 mode = "normal"
256 [[bind]]
257 keys = "SPC m l s"
258 command = "org.link.store"
259 mode = "normal"
260 [[bind]]
261 keys = "SPC m l i"
262 command = "org.id.store-link"
263 mode = "normal"
264 [[bind]]
265 keys = "SPC n l"
266 command = "org.link.store"
267 mode = "normal"
268 [[bind]]
269 keys = "SPC m t"
270 command = "org.todo.cycle"
271 mode = "normal"
272 [[bind]]
273 keys = "SPC m q"
274 command = "org.tags.set"
275 mode = "normal"
276 [[bind]]
277 keys = "SPC m x"
278 command = "org.checkbox.toggle"
279 mode = "normal"
280 [[bind]]
281 keys = "SPC m A"
282 command = "app.archive"
283 mode = "normal"
284 [[bind]]
285 keys = "SPC m e h h"
286 command = "app.export.html"
287 mode = "normal"
288 [[bind]]
289 keys = "SPC m e h o"
290 command = "app.export.html-open"
291 mode = "normal"
292 [[bind]]
293 keys = "SPC m e m m"
294 command = "app.export.markdown"
295 mode = "normal"
296 [[bind]]
297 keys = "SPC m e l p"
298 command = "app.export.pdf"
299 mode = "normal"
300 [[bind]]
301 keys = "SPC m d d"
302 command = "org.deadline"
303 mode = "normal"
304 [[bind]]
305 keys = "SPC m d s"
306 command = "org.schedule"
307 mode = "normal"
308 [[bind]]
309 keys = "SPC m d t"
310 command = "org.timestamp.active"
311 mode = "normal"
312 [[bind]]
313 keys = "SPC m d T"
314 command = "org.timestamp.inactive"
315 mode = "normal"
316 [[bind]]
317 keys = "SPC m r r"
318 command = "app.refile"
319 mode = "normal"
320 [[bind]]
321 keys = "SPC m s r"
322 command = "app.refile"
323 mode = "normal"
324 [[bind]]
325 keys = "SPC m s A"
326 command = "app.archive"
327 mode = "normal"
328 [[bind]]
329 keys = "SPC m s h"
330 command = "org.subtree.promote"
331 mode = "normal"
332 [[bind]]
333 keys = "SPC m s l"
334 command = "org.subtree.demote"
335 mode = "normal"
336 [[bind]]
337 keys = "SPC m s j"
338 command = "org.subtree.down"
339 mode = "normal"
340 [[bind]]
341 keys = "SPC m s k"
342 command = "org.subtree.up"
343 mode = "normal"
344 [[bind]]
345 keys = "SPC m c i"
346 command = "app.clock.in"
347 mode = "normal"
348 [[bind]]
349 keys = "SPC m c o"
350 command = "app.clock.out"
351 mode = "normal"
352 [[bind]]
353 keys = "SPC m c c"
354 command = "app.clock.cancel"
355 mode = "normal"
356 [[bind]]
357 keys = "SPC m c g"
358 command = "app.clock.goto"
359 mode = "normal"
360 [[bind]]
361 keys = "SPC m c R"
362 command = "app.clock.report"
363 mode = "normal"
364 [[bind]]
365 keys = "SPC m c E"
366 command = "org.effort.set"
367 mode = "normal"
368 [[bind]]
369 keys = "SPC m p p"
370 command = "org.priority.set"
371 mode = "normal"
372 [[bind]]
373 keys = "SPC m p u"
374 command = "org.priority.up"
375 mode = "normal"
376 [[bind]]
377 keys = "SPC m p d"
378 command = "org.priority.down"
379 mode = "normal"
380 [[bind]]
381 keys = "SPC m b -"
382 command = "org.table.insert-hline"
383 mode = "normal"
384 [[bind]]
385 keys = "SPC m b a"
386 command = "org.table.align"
387 mode = "normal"
388 [[bind]]
389 keys = "SPC m b r"
390 command = "org.table.recalc-all"
391 mode = "normal"
392 [[bind]]
393 keys = "SPC m b d c"
394 command = "org.table.delete-column"
395 mode = "normal"
396 [[bind]]
397 keys = "SPC m b d r"
398 command = "org.table.kill-row"
399 mode = "normal"
400 [[bind]]
401 keys = "SPC m b i c"
402 command = "org.table.insert-column"
403 mode = "normal"
404 [[bind]]
405 keys = "SPC m b i r"
406 command = "org.table.insert-row"
407 mode = "normal"
408 [[bind]]
409 keys = "SPC m b i h"
410 command = "org.table.insert-hline"
411 mode = "normal"
412
413 # evil-org and Doom's org keys
414 [[bind]]
415 keys = "TAB"
416 command = "org.cycle"
417 mode = "normal"
418 [[bind]]
419 keys = "S-TAB"
420 command = "org.cycle-global"
421 mode = "normal"
422 [[bind]]
423 keys = "RET"
424 command = "org.dwim"
425 mode = "normal"
426 [[bind]]
427 keys = "z a"
428 command = "org.cycle"
429 mode = "normal"
430 [[bind]]
431 keys = "z c"
432 command = "org.cycle"
433 mode = "normal"
434 [[bind]]
435 keys = "z o"
436 command = "org.cycle"
437 mode = "normal"
438 [[bind]]
439 keys = "z A"
440 command = "org.cycle-global"
441 mode = "normal"
442 [[bind]]
443 keys = "g h"
444 command = "org.heading.up"
445 mode = "normal"
446 [[bind]]
447 keys = "g j"
448 command = "org.heading.forward-same-level"
449 mode = "normal"
450 [[bind]]
451 keys = "g k"
452 command = "org.heading.backward-same-level"
453 mode = "normal"
454 [[bind]]
455 keys = "] h"
456 command = "org.heading.forward-same-level"
457 mode = "normal"
458 [[bind]]
459 keys = "[ h"
460 command = "org.heading.backward-same-level"
461 mode = "normal"
462 [[bind]]
463 keys = "RET"
464 command = "org.table.next-row"
465 when = "table"
466 mode = "insert"
467 [[bind]]
468 keys = "TAB"
469 command = "org.cycle"
470 mode = "visual"
471 [[bind]]
472 keys = "S-TAB"
473 command = "org.cycle-global"
474 mode = "visual"
475
476 # Insert state: org-cycle and org-shifttab with Doom's +org-indent-maybe-h, which
477 # demotes or promotes a heading and indents or outdents an item tree.
478 [[bind]]
479 keys = "S-TAB"
480 command = "org.cycle-global"
481 mode = "insert"
482 [[bind]]
483 keys = "TAB"
484 command = "org.table.next-field"
485 when = "table"
486 mode = "insert"
487 [[bind]]
488 keys = "S-TAB"
489 command = "org.table.previous-field"
490 when = "table"
491 mode = "insert"
492 [[bind]]
493 keys = "TAB"
494 command = "org.item.indent-tree"
495 when = "item"
496 mode = "insert"
497 [[bind]]
498 keys = "S-TAB"
499 command = "org.item.outdent-tree"
500 when = "item"
501 mode = "insert"
502 [[bind]]
503 keys = "TAB"
504 command = "org.heading.demote"
505 when = "heading"
506 mode = "insert"
507 [[bind]]
508 keys = "S-TAB"
509 command = "org.heading.promote"
510 when = "heading"
511 mode = "insert"
512
513 """
514
515
516 static let common = """
517 [[bind]]
518 keys = "TAB"
519 command = "org.cycle"
520 when = "heading"
521 [[bind]]
522 keys = "TAB"
523 command = "org.cycle"
524 when = "fold-line"
525
526 [[bind]]
527 keys = "S-TAB"
528 command = "org.cycle-global"
529 [[bind]]
530 keys = "TAB"
531 command = "org.table.next-field"
532 when = "table"
533 [[bind]]
534 keys = "S-TAB"
535 command = "org.table.previous-field"
536 when = "table"
537 [[bind]]
538 keys = "RET"
539 command = "org.table.next-row"
540 when = "table"
541
542 """
543
544 static let emacsBindings = """
545 # Movement and editing. With a mark set (C-SPC), movement extends the region.
546 [[bind]]
547 keys = "C-f"
548 command = "edit.forward-char"
549 [[bind]]
550 keys = "C-b"
551 command = "edit.backward-char"
552 [[bind]]
553 keys = "C-n"
554 command = "edit.next-line"
555 [[bind]]
556 keys = "C-p"
557 command = "edit.previous-line"
558 [[bind]]
559 keys = "C-a"
560 command = "edit.beginning-of-line"
561 [[bind]]
562 keys = "C-e"
563 command = "edit.end-of-line"
564 [[bind]]
565 keys = "M-f"
566 command = "edit.forward-word"
567 [[bind]]
568 keys = "M-b"
569 command = "edit.backward-word"
570 [[bind]]
571 keys = "M-<"
572 command = "edit.beginning-of-buffer"
573 [[bind]]
574 keys = "M->"
575 command = "edit.end-of-buffer"
576 [[bind]]
577 keys = "C-v"
578 command = "edit.scroll-up"
579 [[bind]]
580 keys = "M-v"
581 command = "edit.scroll-down"
582 [[bind]]
583 keys = "C-l"
584 command = "edit.recenter"
585 [[bind]]
586 keys = "C-d"
587 command = "edit.delete-char"
588 [[bind]]
589 keys = "M-d"
590 command = "edit.kill-word"
591 [[bind]]
592 keys = "M-DEL"
593 command = "edit.backward-kill-word"
594 [[bind]]
595 keys = "C-k"
596 command = "edit.kill-line"
597 [[bind]]
598 keys = "C-y"
599 command = "edit.yank"
600 [[bind]]
601 keys = "C-SPC"
602 command = "edit.set-mark"
603 [[bind]]
604 keys = "C-x h"
605 command = "edit.select-all"
606 [[bind]]
607 keys = "C-w"
608 command = "edit.kill-region"
609 [[bind]]
610 keys = "M-w"
611 command = "edit.copy-region"
612 [[bind]]
613 keys = "C-/"
614 command = "edit.undo"
615 [[bind]]
616 keys = "C-_"
617 command = "edit.undo"
618 [[bind]]
619 keys = "C-x u"
620 command = "edit.undo"
621 [[bind]]
622 keys = "C-g"
623 command = "edit.keyboard-quit"
624 [[bind]]
625 keys = "C-t"
626 command = "edit.transpose-chars"
627 [[bind]]
628 keys = "C-s"
629 command = "edit.find"
630 [[bind]]
631 keys = "C-r"
632 command = "edit.find"
633 [[bind]]
634 keys = "M-%"
635 command = "edit.replace"
636
637 # Files and commands
638 [[bind]]
639 keys = "C-x C-s"
640 command = "app.save"
641 [[bind]]
642 keys = "C-c C-o"
643 command = "org.link.open"
644 [[bind]]
645 keys = "C-c C-l"
646 command = "org.link.insert"
647 [[bind]]
648 keys = "C-c l"
649 command = "org.link.store"
650 [[bind]]
651 keys = "C-c ;"
652 command = "org.heading.toggle-comment"
653 [[bind]]
654 keys = "C-c *"
655 command = "org.heading.toggle"
656 [[bind]]
657 keys = "C-c -"
658 command = "org.item.toggle"
659 [[bind]]
660 keys = "C-c @"
661 command = "org.subtree.mark"
662 [[bind]]
663 keys = "C-c C-x C-w"
664 command = "org.subtree.cut"
665 [[bind]]
666 keys = "C-c C-x M-w"
667 command = "org.subtree.copy"
668 [[bind]]
669 keys = "C-c C-x C-y"
670 command = "org.subtree.paste"
671 [[bind]]
672 keys = "C-c C-x c"
673 command = "org.subtree.clone"
674 [[bind]]
675 keys = "C-c ^"
676 command = "org.sort"
677 [[bind]]
678 keys = "C-c C-c"
679 command = "org.ctrl-c-ctrl-c"
680 [[bind]]
681 keys = "C-c C-y"
682 command = "org.timestamp.evaluate-range"
683 [[bind]]
684 keys = "C-c C-x f"
685 command = "org.footnote.action"
686 [[bind]]
687 keys = "C-c ="
688 command = "org.table.column-formula"
689 [[bind]]
690 keys = "C-c TAB"
691 command = "org.table.toggle-column-width"
692 when = "table"
693 [[bind]]
694 keys = "C-x n s"
695 command = "org.narrow.subtree"
696 [[bind]]
697 keys = "C-x n b"
698 command = "org.narrow.block"
699 [[bind]]
700 keys = "C-x n w"
701 command = "org.widen"
702 [[bind]]
703 keys = "C-c C-j"
704 command = "org.goto"
705 [[bind]]
706 keys = "C-c /"
707 command = "org.sparse-tree"
708 [[bind]]
709 keys = "C-c ,"
710 command = "org.priority.set"
711 [[bind]]
712 keys = "C-c C-x C-r"
713 command = "org.clock.report"
714 [[bind]]
715 keys = "C-c C-x C-u"
716 command = "org.dblock.update"
717 [[bind]]
718 keys = "C-c C-x e"
719 command = "org.effort.set"
720 [[bind]]
721 keys = "C-c C-c"
722 command = "org.dblock.update"
723 when = "dblock"
724 [[bind]]
725 keys = "C-c C-,"
726 command = "org.structure-template"
727 [[bind]]
728 keys = "C-c '"
729 command = "org.edit-special"
730 [[bind]]
731 keys = "C-x b"
732 command = "app.buffer.switch"
733 [[bind]]
734 keys = "C-x C-b"
735 command = "app.buffer.switch"
736 [[bind]]
737 keys = "C-x k"
738 command = "app.buffer.kill"
739 [[bind]]
740 keys = "C-x <right>"
741 command = "app.buffer.next"
742 [[bind]]
743 keys = "C-x <left>"
744 command = "app.buffer.previous"
745 [[bind]]
746 keys = "C-x s"
747 command = "app.save-all"
748 [[bind]]
749 keys = "C-x C-f"
750 command = "app.quick-open"
751 [[bind]]
752 keys = "M-x"
753 command = "app.palette"
754 [[bind]]
755 keys = "C-c a"
756 command = "app.agenda"
757 [[bind]]
758 keys = "C-c c"
759 command = "app.capture"
760 [[bind]]
761 keys = "C-c C-x C-i"
762 command = "app.clock.in"
763 [[bind]]
764 keys = "C-c C-x C-o"
765 command = "app.clock.out"
766 [[bind]]
767 keys = "C-c C-x C-q"
768 command = "app.clock.cancel"
769 [[bind]]
770 keys = "C-c C-x C-j"
771 command = "app.clock.goto"
772 [[bind]]
773 keys = "C-c C-e h h"
774 command = "app.export.html"
775 [[bind]]
776 keys = "C-c C-e h o"
777 command = "app.export.html-open"
778 [[bind]]
779 keys = "C-c C-e m m"
780 command = "app.export.markdown"
781 [[bind]]
782 keys = "C-c C-e l p"
783 command = "app.export.pdf"
784 [[bind]]
785 keys = "C-c C-e l l"
786 command = "app.export.latex"
787 [[bind]]
788 keys = "C-c C-e o o"
789 command = "app.export.odt"
790 [[bind]]
791 keys = "C-c C-e t u"
792 command = "app.export.text"
793
794 # Org
795 [[bind]]
796 keys = "C-c C-t"
797 command = "org.todo.cycle"
798 [[bind]]
799 keys = "S-<right>"
800 command = "org.todo.next"
801 when = "heading"
802 [[bind]]
803 keys = "S-<left>"
804 command = "org.todo.previous"
805 when = "heading"
806 [[bind]]
807 keys = "S-<up>"
808 command = "org.priority.up"
809 when = "heading"
810 [[bind]]
811 keys = "S-<down>"
812 command = "org.priority.down"
813 when = "heading"
814 [[bind]]
815 keys = "M-<left>"
816 command = "org.heading.promote"
817 when = "heading"
818 [[bind]]
819 keys = "M-<right>"
820 command = "org.heading.demote"
821 when = "heading"
822 [[bind]]
823 keys = "M-S-<left>"
824 command = "org.subtree.promote"
825 when = "heading"
826 [[bind]]
827 keys = "M-S-<right>"
828 command = "org.subtree.demote"
829 when = "heading"
830 [[bind]]
831 keys = "M-<up>"
832 command = "org.subtree.up"
833 when = "heading"
834 [[bind]]
835 keys = "M-<down>"
836 command = "org.subtree.down"
837 when = "heading"
838 [[bind]]
839 keys = "M-RET"
840 command = "org.heading.insert"
841 [[bind]]
842 keys = "C-RET"
843 command = "org.heading.insert-after-subtree"
844 [[bind]]
845 keys = "M-S-RET"
846 command = "org.heading.insert-todo"
847 [[bind]]
848 keys = "C-c C-n"
849 command = "org.heading.next"
850 [[bind]]
851 keys = "C-c C-p"
852 command = "org.heading.previous"
853 [[bind]]
854 keys = "C-c C-f"
855 command = "org.heading.forward-same-level"
856 [[bind]]
857 keys = "C-c C-b"
858 command = "org.heading.backward-same-level"
859 [[bind]]
860 keys = "C-c C-u"
861 command = "org.heading.up"
862 [[bind]]
863 keys = "C-c C-q"
864 command = "org.tags.set"
865 [[bind]]
866 keys = "M-RET"
867 command = "org.item.insert"
868 when = "item"
869 [[bind]]
870 keys = "M-S-RET"
871 command = "org.item.insert-checkbox"
872 when = "item"
873 [[bind]]
874 keys = "M-<left>"
875 command = "org.item.outdent"
876 when = "item"
877 [[bind]]
878 keys = "M-<right>"
879 command = "org.item.indent"
880 when = "item"
881 [[bind]]
882 keys = "M-S-<left>"
883 command = "org.item.outdent-tree"
884 when = "item"
885 [[bind]]
886 keys = "M-S-<right>"
887 command = "org.item.indent-tree"
888 when = "item"
889 [[bind]]
890 keys = "M-<up>"
891 command = "org.item.up"
892 when = "item"
893 [[bind]]
894 keys = "M-<down>"
895 command = "org.item.down"
896 when = "item"
897 [[bind]]
898 keys = "C-c C-c"
899 command = "org.ctrl-c-ctrl-c"
900 when = "item"
901 [[bind]]
902 keys = "C-c C-x C-b"
903 command = "org.checkbox.toggle"
904 [[bind]]
905 keys = "C-c C-w"
906 command = "app.refile"
907 [[bind]]
908 keys = "C-c C-x C-s"
909 command = "app.archive"
910 [[bind]]
911 keys = "C-c $"
912 command = "app.archive"
913 [[bind]]
914 keys = "C-c ."
915 command = "org.timestamp.active"
916 [[bind]]
917 keys = "C-c !"
918 command = "org.timestamp.inactive"
919 [[bind]]
920 keys = "C-c C-s"
921 command = "org.schedule"
922 [[bind]]
923 keys = "C-c C-d"
924 command = "org.deadline"
925 [[bind]]
926 keys = "M-q"
927 command = "org.fill-paragraph"
928 [[bind]]
929 keys = "C-c C-c"
930 command = "org.table.align"
931 when = "table"
932 [[bind]]
933 keys = "C-c C-c"
934 command = "org.table.recalc-all"
935 when = "tblfm"
936 [[bind]]
937 keys = "C-c *"
938 command = "org.table.recalc"
939 when = "table"
940 [[bind]]
941 keys = "C-c C-c"
942 command = "org.babel.execute"
943 when = "src"
944 [[bind]]
945 keys = "M-<up>"
946 command = "org.table.row-up"
947 when = "table"
948 [[bind]]
949 keys = "M-<down>"
950 command = "org.table.row-down"
951 when = "table"
952 [[bind]]
953 keys = "M-<left>"
954 command = "org.table.column-left"
955 when = "table"
956 [[bind]]
957 keys = "M-<right>"
958 command = "org.table.column-right"
959 when = "table"
960 [[bind]]
961 keys = "M-S-<right>"
962 command = "org.table.insert-column"
963 when = "table"
964 [[bind]]
965 keys = "M-S-<left>"
966 command = "org.table.delete-column"
967 when = "table"
968 [[bind]]
969 keys = "M-S-<up>"
970 command = "org.table.kill-row"
971 when = "table"
972 [[bind]]
973 keys = "M-S-<down>"
974 command = "org.table.insert-row"
975 when = "table"
976 [[bind]]
977 keys = "C-c -"
978 command = "org.table.insert-hline"
979 when = "table"
980 [[bind]]
981 keys = "C-c |"
982 command = "org.table.create"
983 [[bind]]
984 keys = "S-<up>"
985 command = "org.timestamp.up"
986 when = "timestamp"
987 [[bind]]
988 keys = "S-<down>"
989 command = "org.timestamp.down"
990 when = "timestamp"
991 [[bind]]
992 keys = "S-<right>"
993 command = "org.timestamp.day-later"
994 when = "timestamp"
995 [[bind]]
996 keys = "S-<left>"
997 command = "org.timestamp.day-earlier"
998 when = "timestamp"
999
1000 """
1001
1002 /// Standard Mac text keys stay as they are; org commands use Control-Command chords, which
1003 /// macOS text editing leaves free.
1004 static let macBindings = """
1005 [[bind]]
1006 keys = "C-TAB"
1007 command = "app.buffer.next"
1008 [[bind]]
1009 keys = "C-S-TAB"
1010 command = "app.buffer.previous"
1011 [[bind]]
1012 keys = "C-s-t"
1013 command = "org.todo.cycle"
1014 [[bind]]
1015 keys = "C-s-<up>"
1016 command = "org.priority.up"
1017 [[bind]]
1018 keys = "C-s-<down>"
1019 command = "org.priority.down"
1020 [[bind]]
1021 keys = "C-s-<left>"
1022 command = "org.heading.promote"
1023 [[bind]]
1024 keys = "C-s-<right>"
1025 command = "org.heading.demote"
1026 [[bind]]
1027 keys = "C-M-s-<left>"
1028 command = "org.subtree.promote"
1029 [[bind]]
1030 keys = "C-M-s-<right>"
1031 command = "org.subtree.demote"
1032 [[bind]]
1033 keys = "C-M-s-<up>"
1034 command = "org.subtree.up"
1035 [[bind]]
1036 keys = "C-M-s-<down>"
1037 command = "org.subtree.down"
1038 [[bind]]
1039 keys = "s-RET"
1040 command = "org.heading.insert"
1041 [[bind]]
1042 keys = "C-s-RET"
1043 command = "org.heading.insert-after-subtree"
1044 [[bind]]
1045 keys = "s-S-RET"
1046 command = "org.heading.insert-todo"
1047 [[bind]]
1048 keys = "M-s-<down>"
1049 command = "org.heading.next"
1050 [[bind]]
1051 keys = "M-s-<up>"
1052 command = "org.heading.previous"
1053 [[bind]]
1054 keys = "C-s-q"
1055 command = "org.tags.set"
1056 [[bind]]
1057 keys = "s-RET"
1058 command = "org.item.insert"
1059 when = "item"
1060 [[bind]]
1061 keys = "s-S-RET"
1062 command = "org.item.insert-checkbox"
1063 when = "item"
1064 [[bind]]
1065 keys = "C-s-<left>"
1066 command = "org.item.outdent"
1067 when = "item"
1068 [[bind]]
1069 keys = "C-s-<right>"
1070 command = "org.item.indent"
1071 when = "item"
1072 [[bind]]
1073 keys = "C-M-s-<left>"
1074 command = "org.item.outdent-tree"
1075 when = "item"
1076 [[bind]]
1077 keys = "C-M-s-<right>"
1078 command = "org.item.indent-tree"
1079 when = "item"
1080 [[bind]]
1081 keys = "C-M-s-<up>"
1082 command = "org.item.up"
1083 when = "item"
1084 [[bind]]
1085 keys = "C-M-s-<down>"
1086 command = "org.item.down"
1087 when = "item"
1088 [[bind]]
1089 keys = "C-s-c"
1090 command = "org.checkbox.toggle"
1091 [[bind]]
1092 keys = "C-s-w"
1093 command = "app.refile"
1094 [[bind]]
1095 keys = "C-s-a"
1096 command = "app.archive"
1097 [[bind]]
1098 keys = "C-s-."
1099 command = "org.timestamp.active"
1100 [[bind]]
1101 keys = "C-M-s-."
1102 command = "org.timestamp.inactive"
1103 [[bind]]
1104 keys = "C-s-s"
1105 command = "org.schedule"
1106 [[bind]]
1107 keys = "C-s-d"
1108 command = "org.deadline"
1109 [[bind]]
1110 keys = "C-s-p"
1111 command = "org.fill-paragraph"
1112 [[bind]]
1113 keys = "C-s-<up>"
1114 command = "org.table.row-up"
1115 when = "table"
1116 [[bind]]
1117 keys = "C-s-<down>"
1118 command = "org.table.row-down"
1119 when = "table"
1120 [[bind]]
1121 keys = "C-s-<left>"
1122 command = "org.table.column-left"
1123 when = "table"
1124 [[bind]]
1125 keys = "C-s-<right>"
1126 command = "org.table.column-right"
1127 when = "table"
1128 [[bind]]
1129 keys = "C-M-s-<right>"
1130 command = "org.table.insert-column"
1131 when = "table"
1132 [[bind]]
1133 keys = "C-M-s-<left>"
1134 command = "org.table.delete-column"
1135 when = "table"
1136 [[bind]]
1137 keys = "C-M-s-<up>"
1138 command = "org.table.kill-row"
1139 when = "table"
1140 [[bind]]
1141 keys = "C-M-s-<down>"
1142 command = "org.table.insert-row"
1143 when = "table"
1144 [[bind]]
1145 keys = "C-s--"
1146 command = "org.table.insert-hline"
1147 when = "table"
1148 [[bind]]
1149 keys = "C-s-\\\\"
1150 command = "org.table.create"
1151 [[bind]]
1152 keys = "C-s-<up>"
1153 command = "org.timestamp.up"
1154 when = "timestamp"
1155 [[bind]]
1156 keys = "C-s-<down>"
1157 command = "org.timestamp.down"
1158 when = "timestamp"
1159 [[bind]]
1160 keys = "C-s-<right>"
1161 command = "org.timestamp.day-later"
1162 when = "timestamp"
1163 [[bind]]
1164 keys = "C-s-<left>"
1165 command = "org.timestamp.day-earlier"
1166 when = "timestamp"
1167
1168 """
1169}