Enhance Emacs Ergonomics Under X: Happy Hands!
1. Executive Summary
Describes customizations under X that makes my hands happier. Leverages features and (mis-features) of modern-day laptops to break old habits and reduce chording in common cases.
2. Background
I have been using Emacs for 33 years now and at this point, much of my Emacs usage is based on muscle memory. This has its good and bad points; the good ones are obvious; I dont need to think about what keys I press. But it also has some downside; I likely press more keys than I ought to for a given result.
- I learn to use Emacs on a TTY (text console) and all my habits are driven by the keys available on a terminal.
- Under X you have more keys available, but I resisted running X until around 2008.
- Now, I almost never run Emacs on a TTY, except when I need to rescue a broken X setup.
- after turning
caps_lock
toControl
I forgot about the other modifier keys; I pressEscape
for Meta. - I also defined
C-;
and friends as additional Emacs prefix keys. - The above saves your hands because you dont chord using the modifier keys on the bottom row.
- But you waste 6 modifier keys on a laptop where keys are in short supply.
3. Leveraging Current Keyboard
- The motivation to leverage the laptop keyboard is higher now, since with the arrival of the pandemic, that has been my primary (only) machine.
- I can chord without thinking using the modified
caps_lock
asControl
. But I also noticed that I choard a lot. - Chords I use most often as a prefix:
C-e
— Emacspeak prefix,C-s
andC-r
— Isearch,C-c
andC-x
— emacs command prefix.
- Looking at the bottom row of the laptop keyboard, there are three modifier keys to either side of the spacebar.
- Adding the left and right
Shift
modifiers gives 8 keys that could do something useful when not used as a modifier key.
4. XCAPE: Turn Modifiers Into Buttons
I discovered xcape a while ago, but had set it aside for future exploration; The observations made in the previous section indicated that that time was now!
So here is my xcape Setup and associated XModmap as of the time of writing:
4.1. What This Does:
Control
by itself sendsC-e
,Super
by itself sendsC-c
,Alt
by itself sendsC-x
,Shift_l
by itself sendsC-s
,Shift_R
by itself sendsC-r
.
Note that the XModmap
file does the work of changing the <print>
key on my laptop to be Super_L
for symmetry. So the bottom row of
keys now look like this:
Modifier | Control | Super | Alt | Spacebar | Alt | Super | Control |
Key | C-e |
C-c |
C-x |
Spacebar | C-x |
C-c |
C-e |
Looking at the above, it's tempting to turn the SpaceBar
into a
modifier — but I've resisted doing that for now.
5. Observations
- A week later, I'm slowly retraining my muscle memory — I use the new affordances described here about 25% of the time.
- I find myself using the new features in the second half of the day when my hands are more tired.
- The effect of thinking before pressing a key reminds me of the time I learn to use dvorak for text input; I still do so sometimes to give my hands a break.
- The new mappings give some surprizing results e.g.,
alt
shift
saves the buffer, but buyer beware,alt
super
quits Emacs. - Am sure more muscle memory will emerge for oft-repeated tasks.