This is the entire source: #include #include #define stk(s) XKeysymToKeycode(d, XStringToKeysym(s)) #define on(_, x) if (e.type == _) { x; } #define map(k, x) if (e.xkey.keycode == stk(k)) { x; } #define grab(...) const char *l[] = { __VA_ARGS__, 0 }; \ for (int i = 0; l[i]; i++) XGrabKey(d, stk(l[i]), Mod4Mask, r, 1, 1, 1); int main() { Display *d = XOpenDisplay(0); Window r = DefaultRootWindow(d); XEvent e; XSelect…
Beware! That's the DSL trap. It works here so well because it's limited to 20 lines and each macro does exactly what it needs to for the problem at hand. Take that DSL and use it over a year to write a bunch of code to do normal things as your app grows into its problem domain and spills over into a few more, and it melts. New developers will show up to onboard to your and be like "WTF is this 'on()' thing I'm lookin…
I guess here's a question - do you consider regex libraries to be DSLs?