X Macros

No problem can be solved at the same level of thinking that created it.1 — “Albert Einstein” Consistency Challenge The first time I ran into X Macros was while debugging an out-of-bounds access issue. Here is a simplified example: // a.h typedef enum { SYS_OK, SYS_ERR_TIMEOUT, SYS_ERR_BUSY, SYS_ERR_INVALID_ARG, SYS_ERR_NOT_FOUND } SysState; // a.c const char *state_desc[] = { [SYS_OK] = "System OK", [SYS_ERR_TIMEOUT] = "Timeout", [SYS_ERR_BUSY] = "System Busy", [SYS_ERR_INVALID_ARG] = "Invalid Argument" // SYS_ERR_NOT_FOUND is missing here }; int main() { printf("State = %s\n", state_desc[SYS_ERR_NOT_FOUND]); } The issue is easy to spot: SYS_ERR_NOT_FOUND was added to the enum, but the string table was not updated. ...

March 12, 2026 · 4 min · 774 words

Splitting Ctrl+Space

Emacs comes with numerous default keybindings, which inevitably conflict with system-level shortcuts. For Emacs beginners, resolving these conflicts can be a significant challenge. One of the most common conflicts is with the command set-mark-command, which default binding is C-SPC~(Ctrl+Space)1. On Windows, Ctrl+Space is often used to toggle between English and Chinese input methods, which can makeCtrl+Space unusable for marking in Emacs. To resolve this issue, you can either use the alternative binding forset-mark-command, C-@, or disable the Ctrl+Space functionality in Windows. Additionally, since the spacebar can be operated easily with either thumb, there is a “third option”: you can configure the Ctrl+Space so that one side Ctrl+Space is reserved for Windows, while the other side Ctrl+Space is available for Emacs or other applications. This is the solution I adopted because it allows me to maintain my habit of using both thumbs for operation. ...

March 2, 2026 · 2 min · 349 words

Swapping Ctrl and Alt Keys

This is an essential configuration for all the computers I use, all because of Emacs. Emacs was originally developed as a set of macros for the TECO editor (Editing MACroS). At that time, the keyboard layout used by the developers placed the Ctrl key next to the spacebar1, making it convenient for operation with the thumbs. For some reason, standard keyboards that became widespread with personal computers moved the Ctrl key to the outermost position, which forces usage with the pinky finger. This design easily fatigues the pinky. ...

February 25, 2026 · 1 min · 163 words