Add macro mode support

This should allow `selecthxml` to work during macro mode. The changes allow me to use `Detox` during macro mode, with only a small edit to `Detox` needed as well.