Sources/OrgCore/Keymap/Presets.swift
1206 lines · 34191 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-e"
733 command = "app.export-dialog"
734 [[bind]]
735 keys = "C-c C-x C-v"
736 command = "org.toggle-inline-images"
737 [[bind]]
738 keys = "C-c C-x C-c"
739 command = "org.columns"
740 [[bind]]
741 keys = "S-<right>"
742 command = "org.property.next-value"
743 when = "property"
744 [[bind]]
745 keys = "S-<left>"
746 command = "org.property.previous-value"
747 when = "property"
748 [[bind]]
749 keys = "C-c C-x C-r"
750 command = "org.clock.report"
751 [[bind]]
752 keys = "C-c C-x C-u"
753 command = "org.dblock.update"
754 [[bind]]
755 keys = "C-c C-x e"
756 command = "org.effort.set"
757 [[bind]]
758 keys = "C-c C-c"
759 command = "org.dblock.update"
760 when = "dblock"
761 [[bind]]
762 keys = "C-c C-,"
763 command = "org.structure-template"
764 [[bind]]
765 keys = "C-c '"
766 command = "org.edit-special"
767 [[bind]]
768 keys = "C-x b"
769 command = "app.buffer.switch"
770 [[bind]]
771 keys = "C-x C-b"
772 command = "app.buffer.switch"
773 [[bind]]
774 keys = "C-x k"
775 command = "app.buffer.kill"
776 [[bind]]
777 keys = "C-x <right>"
778 command = "app.buffer.next"
779 [[bind]]
780 keys = "C-x <left>"
781 command = "app.buffer.previous"
782 [[bind]]
783 keys = "C-x s"
784 command = "app.save-all"
785 [[bind]]
786 keys = "C-x C-f"
787 command = "app.quick-open"
788 [[bind]]
789 keys = "M-x"
790 command = "app.palette"
791 [[bind]]
792 keys = "C-c a"
793 command = "app.agenda"
794 [[bind]]
795 keys = "C-c c"
796 command = "app.capture"
797 [[bind]]
798 keys = "C-c C-x C-i"
799 command = "app.clock.in"
800 [[bind]]
801 keys = "C-c C-x C-o"
802 command = "app.clock.out"
803 [[bind]]
804 keys = "C-c C-x C-q"
805 command = "app.clock.cancel"
806 [[bind]]
807 keys = "C-c C-x C-j"
808 command = "app.clock.goto"
809 [[bind]]
810 keys = "C-c C-e h h"
811 command = "app.export.html"
812 [[bind]]
813 keys = "C-c C-e h o"
814 command = "app.export.html-open"
815 [[bind]]
816 keys = "C-c C-e m m"
817 command = "app.export.markdown"
818 [[bind]]
819 keys = "C-c C-e l p"
820 command = "app.export.pdf"
821 [[bind]]
822 keys = "C-c C-e l l"
823 command = "app.export.latex"
824 [[bind]]
825 keys = "C-c C-e o o"
826 command = "app.export.odt"
827 [[bind]]
828 keys = "C-c C-e t u"
829 command = "app.export.text"
830
831 # Org
832 [[bind]]
833 keys = "C-c C-t"
834 command = "org.todo.cycle"
835 [[bind]]
836 keys = "S-<right>"
837 command = "org.todo.next"
838 when = "heading"
839 [[bind]]
840 keys = "S-<left>"
841 command = "org.todo.previous"
842 when = "heading"
843 [[bind]]
844 keys = "S-<up>"
845 command = "org.priority.up"
846 when = "heading"
847 [[bind]]
848 keys = "S-<down>"
849 command = "org.priority.down"
850 when = "heading"
851 [[bind]]
852 keys = "M-<left>"
853 command = "org.heading.promote"
854 when = "heading"
855 [[bind]]
856 keys = "M-<right>"
857 command = "org.heading.demote"
858 when = "heading"
859 [[bind]]
860 keys = "M-S-<left>"
861 command = "org.subtree.promote"
862 when = "heading"
863 [[bind]]
864 keys = "M-S-<right>"
865 command = "org.subtree.demote"
866 when = "heading"
867 [[bind]]
868 keys = "M-<up>"
869 command = "org.subtree.up"
870 when = "heading"
871 [[bind]]
872 keys = "M-<down>"
873 command = "org.subtree.down"
874 when = "heading"
875 [[bind]]
876 keys = "M-RET"
877 command = "org.heading.insert"
878 [[bind]]
879 keys = "C-RET"
880 command = "org.heading.insert-after-subtree"
881 [[bind]]
882 keys = "M-S-RET"
883 command = "org.heading.insert-todo"
884 [[bind]]
885 keys = "C-c C-n"
886 command = "org.heading.next"
887 [[bind]]
888 keys = "C-c C-p"
889 command = "org.heading.previous"
890 [[bind]]
891 keys = "C-c C-f"
892 command = "org.heading.forward-same-level"
893 [[bind]]
894 keys = "C-c C-b"
895 command = "org.heading.backward-same-level"
896 [[bind]]
897 keys = "C-c C-u"
898 command = "org.heading.up"
899 [[bind]]
900 keys = "C-c C-q"
901 command = "org.tags.set"
902 [[bind]]
903 keys = "M-RET"
904 command = "org.item.insert"
905 when = "item"
906 [[bind]]
907 keys = "M-S-RET"
908 command = "org.item.insert-checkbox"
909 when = "item"
910 [[bind]]
911 keys = "M-<left>"
912 command = "org.item.outdent"
913 when = "item"
914 [[bind]]
915 keys = "M-<right>"
916 command = "org.item.indent"
917 when = "item"
918 [[bind]]
919 keys = "M-S-<left>"
920 command = "org.item.outdent-tree"
921 when = "item"
922 [[bind]]
923 keys = "M-S-<right>"
924 command = "org.item.indent-tree"
925 when = "item"
926 [[bind]]
927 keys = "M-<up>"
928 command = "org.item.up"
929 when = "item"
930 [[bind]]
931 keys = "M-<down>"
932 command = "org.item.down"
933 when = "item"
934 [[bind]]
935 keys = "C-c C-c"
936 command = "org.ctrl-c-ctrl-c"
937 when = "item"
938 [[bind]]
939 keys = "C-c C-x C-b"
940 command = "org.checkbox.toggle"
941 [[bind]]
942 keys = "C-c C-w"
943 command = "app.refile"
944 [[bind]]
945 keys = "C-c C-x C-s"
946 command = "app.archive"
947 [[bind]]
948 keys = "C-c $"
949 command = "app.archive"
950 [[bind]]
951 keys = "C-c ."
952 command = "org.timestamp.active"
953 [[bind]]
954 keys = "C-c !"
955 command = "org.timestamp.inactive"
956 [[bind]]
957 keys = "C-c C-s"
958 command = "org.schedule"
959 [[bind]]
960 keys = "C-c C-d"
961 command = "org.deadline"
962 [[bind]]
963 keys = "M-q"
964 command = "org.fill-paragraph"
965 [[bind]]
966 keys = "C-c C-c"
967 command = "org.table.align"
968 when = "table"
969 [[bind]]
970 keys = "C-c C-c"
971 command = "org.table.recalc-all"
972 when = "tblfm"
973 [[bind]]
974 keys = "C-c *"
975 command = "org.table.recalc"
976 when = "table"
977 [[bind]]
978 keys = "C-c C-c"
979 command = "org.babel.execute"
980 when = "src"
981 [[bind]]
982 keys = "M-<up>"
983 command = "org.table.row-up"
984 when = "table"
985 [[bind]]
986 keys = "M-<down>"
987 command = "org.table.row-down"
988 when = "table"
989 [[bind]]
990 keys = "M-<left>"
991 command = "org.table.column-left"
992 when = "table"
993 [[bind]]
994 keys = "M-<right>"
995 command = "org.table.column-right"
996 when = "table"
997 [[bind]]
998 keys = "M-S-<right>"
999 command = "org.table.insert-column"
1000 when = "table"
1001 [[bind]]
1002 keys = "M-S-<left>"
1003 command = "org.table.delete-column"
1004 when = "table"
1005 [[bind]]
1006 keys = "M-S-<up>"
1007 command = "org.table.kill-row"
1008 when = "table"
1009 [[bind]]
1010 keys = "M-S-<down>"
1011 command = "org.table.insert-row"
1012 when = "table"
1013 [[bind]]
1014 keys = "C-c -"
1015 command = "org.table.insert-hline"
1016 when = "table"
1017 [[bind]]
1018 keys = "C-c |"
1019 command = "org.table.create"
1020 [[bind]]
1021 keys = "S-<up>"
1022 command = "org.timestamp.up"
1023 when = "timestamp"
1024 [[bind]]
1025 keys = "S-<down>"
1026 command = "org.timestamp.down"
1027 when = "timestamp"
1028 [[bind]]
1029 keys = "S-<right>"
1030 command = "org.timestamp.day-later"
1031 when = "timestamp"
1032 [[bind]]
1033 keys = "S-<left>"
1034 command = "org.timestamp.day-earlier"
1035 when = "timestamp"
1036
1037 """
1038
1039 /// Standard Mac text keys stay as they are; org commands use Control-Command chords, which
1040 /// macOS text editing leaves free.
1041 static let macBindings = """
1042 [[bind]]
1043 keys = "C-TAB"
1044 command = "app.buffer.next"
1045 [[bind]]
1046 keys = "C-S-TAB"
1047 command = "app.buffer.previous"
1048 [[bind]]
1049 keys = "C-s-t"
1050 command = "org.todo.cycle"
1051 [[bind]]
1052 keys = "C-s-<up>"
1053 command = "org.priority.up"
1054 [[bind]]
1055 keys = "C-s-<down>"
1056 command = "org.priority.down"
1057 [[bind]]
1058 keys = "C-s-<left>"
1059 command = "org.heading.promote"
1060 [[bind]]
1061 keys = "C-s-<right>"
1062 command = "org.heading.demote"
1063 [[bind]]
1064 keys = "C-M-s-<left>"
1065 command = "org.subtree.promote"
1066 [[bind]]
1067 keys = "C-M-s-<right>"
1068 command = "org.subtree.demote"
1069 [[bind]]
1070 keys = "C-M-s-<up>"
1071 command = "org.subtree.up"
1072 [[bind]]
1073 keys = "C-M-s-<down>"
1074 command = "org.subtree.down"
1075 [[bind]]
1076 keys = "s-RET"
1077 command = "org.heading.insert"
1078 [[bind]]
1079 keys = "C-s-RET"
1080 command = "org.heading.insert-after-subtree"
1081 [[bind]]
1082 keys = "s-S-RET"
1083 command = "org.heading.insert-todo"
1084 [[bind]]
1085 keys = "M-s-<down>"
1086 command = "org.heading.next"
1087 [[bind]]
1088 keys = "M-s-<up>"
1089 command = "org.heading.previous"
1090 [[bind]]
1091 keys = "C-s-q"
1092 command = "org.tags.set"
1093 [[bind]]
1094 keys = "s-RET"
1095 command = "org.item.insert"
1096 when = "item"
1097 [[bind]]
1098 keys = "s-S-RET"
1099 command = "org.item.insert-checkbox"
1100 when = "item"
1101 [[bind]]
1102 keys = "C-s-<left>"
1103 command = "org.item.outdent"
1104 when = "item"
1105 [[bind]]
1106 keys = "C-s-<right>"
1107 command = "org.item.indent"
1108 when = "item"
1109 [[bind]]
1110 keys = "C-M-s-<left>"
1111 command = "org.item.outdent-tree"
1112 when = "item"
1113 [[bind]]
1114 keys = "C-M-s-<right>"
1115 command = "org.item.indent-tree"
1116 when = "item"
1117 [[bind]]
1118 keys = "C-M-s-<up>"
1119 command = "org.item.up"
1120 when = "item"
1121 [[bind]]
1122 keys = "C-M-s-<down>"
1123 command = "org.item.down"
1124 when = "item"
1125 [[bind]]
1126 keys = "C-s-c"
1127 command = "org.checkbox.toggle"
1128 [[bind]]
1129 keys = "C-s-w"
1130 command = "app.refile"
1131 [[bind]]
1132 keys = "C-s-a"
1133 command = "app.archive"
1134 [[bind]]
1135 keys = "C-s-."
1136 command = "org.timestamp.active"
1137 [[bind]]
1138 keys = "C-M-s-."
1139 command = "org.timestamp.inactive"
1140 [[bind]]
1141 keys = "C-s-s"
1142 command = "org.schedule"
1143 [[bind]]
1144 keys = "C-s-d"
1145 command = "org.deadline"
1146 [[bind]]
1147 keys = "C-s-p"
1148 command = "org.fill-paragraph"
1149 [[bind]]
1150 keys = "C-s-<up>"
1151 command = "org.table.row-up"
1152 when = "table"
1153 [[bind]]
1154 keys = "C-s-<down>"
1155 command = "org.table.row-down"
1156 when = "table"
1157 [[bind]]
1158 keys = "C-s-<left>"
1159 command = "org.table.column-left"
1160 when = "table"
1161 [[bind]]
1162 keys = "C-s-<right>"
1163 command = "org.table.column-right"
1164 when = "table"
1165 [[bind]]
1166 keys = "C-M-s-<right>"
1167 command = "org.table.insert-column"
1168 when = "table"
1169 [[bind]]
1170 keys = "C-M-s-<left>"
1171 command = "org.table.delete-column"
1172 when = "table"
1173 [[bind]]
1174 keys = "C-M-s-<up>"
1175 command = "org.table.kill-row"
1176 when = "table"
1177 [[bind]]
1178 keys = "C-M-s-<down>"
1179 command = "org.table.insert-row"
1180 when = "table"
1181 [[bind]]
1182 keys = "C-s--"
1183 command = "org.table.insert-hline"
1184 when = "table"
1185 [[bind]]
1186 keys = "C-s-\\\\"
1187 command = "org.table.create"
1188 [[bind]]
1189 keys = "C-s-<up>"
1190 command = "org.timestamp.up"
1191 when = "timestamp"
1192 [[bind]]
1193 keys = "C-s-<down>"
1194 command = "org.timestamp.down"
1195 when = "timestamp"
1196 [[bind]]
1197 keys = "C-s-<right>"
1198 command = "org.timestamp.day-later"
1199 when = "timestamp"
1200 [[bind]]
1201 keys = "C-s-<left>"
1202 command = "org.timestamp.day-earlier"
1203 when = "timestamp"
1204
1205 """
1206}