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