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