--- /dev/null
+//
+// The emacs-keys layout is a modified "us" layout:
+//
+// * CapsLock becomes Left-Alt
+// * Left-Alt and Left-Ctrl are swapped
+// * Right-Alt and Right-Ctrl are swapped
+//
+// This could probably be pieced together from various
+// rules that ship with xkeyboard-config, but it's a
+// lot nicer to have everything available as a layout.
+//
+
+default partial alphanumeric_keys
+xkb_symbols "emacs-keys" {
+ include "us(basic)"
+ name[Group1] = "Emacs Keys";
+
+ // Make capslock a left-alt.
+ replace key <CAPS> { [ Alt_L, Meta_L ] };
+ modifier_map Mod1 { <CAPS> };
+
+ // This is a copy of the ctrl(swap_lalt_lctl) rule
+ // that ships with xkeyboard-config.
+ replace key <LALT> { [ Control_L, Control_L ] };
+ replace key <LCTL> { [ Alt_L, Meta_L ] };
+ modifier_map Mod1 { <LCTL> };
+ modifier_map Control { <LALT> };
+ replace key <LALT> { [ Control_L, Control_L ] };
+ replace key <LCTL> { [ Alt_L, Meta_L ] };
+ modifier_map Mod1 { <LCTL> };
+ modifier_map Control { <LALT> };
+
+ // This is a copy of the ctrl(swap_ralt_rctl) rule
+ // that ships with xkeyboard-config.
+ replace key <RALT> { [ Control_R, Control_R ] };
+ replace key <RCTL> { [ Alt_R, Meta_R ] };
+ modifier_map Mod1 { <RCTL> };
+ modifier_map Control { <RALT> };
+};