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