Use the Emacs keybindings you love across all applications for mac and windows.
- Ctrl-Space can be used to preform Emacs style text selection outside of Emacs
- Supports Emacs prefix keys such as Ctrl-xs (save)
- Allows you to specify app specific overrides (Google Chrome)
- Apps with native Emacs keybindings are left alone
- OS specific keybindings are left alone (alt+tab, ctrl+c, cmd+c, etc)
- Download and install Hammerspoon
- Copy
emacs_hammerspoon.lua
to~/.hammerspoon/init.lua
- Launch Hammerspoon
- Download and Install AutoHotkey
- Launch
emacs_autohotkey.ahk
(notice the green system tray icon) - Add
emacs_authotkey.ahk
to your Windows startup script. Checkout this guide.
Both windows and mac use the global keys
to configure keybindings.
Namespaces are used inside keys
to send different keys to different apps.
globalEmacs
sends Emacs like keybindings to all non-Emacs apps
globalOverride
overrides all app including Emacs
appName
app specific overrides
The keys
variable is structured using the following pattern:
- Namespace
- Source modifier keys such as
ctrl, alt, alt+shift, ...
- Source non-modifier key such as
a,b,c, space, /, ...
- Destination Modifiers and non-modifiers keys
- A boolean indicating if the keybinding will maintain a text selection
- Run a macro to run instead of a translating a keys
"globalEmacs" : { "ctrl" { "a": ["{Home}", True, ""] } }
globalEmacs
means this keybinding is for all non-Emacs apps- Translate the modifier key
Ctrl
- Translate the key
a
- Destination keys are
Home
True
tells the script to maintain the current text selection if currently selecting- No macro to run for this keybinding
['globalEmacs'] = { ["ctrl"] = { ['delete'] = {nil, nil, false, 'macroBackwardsKillWord'} } }
globalEmacs
means this keybinding is for all non-Emacs apps- Translate the modifier key
Ctrl
- Translate the key
delete
(or Backspace) - No destination modifier or key
false
tells the script to cancel a text selection if already started- run the macro
macroBackwardsKillWord
(which runs multiple keys presses)
In Hammerspoon add name of your app to the following list:
local appsWithNativeEmacsKeybindings = { 'emacs', 'terminal' }
In Autohotkey add the name of your app's exec to the following list:
global appsWithNativeEmacsKeybindings = ["emacs.exe", "conemu64.exe"]
I wrote a blog post laying out my reasons for developing these scripts.