OK, after resolving bug#62732, now at last my nice and short patch for this feature. I've thought quite a bit about how to make this configurable, and I think just letting people write their own arbitrary transformation functions, as I do in this patch, is what we should provide. Making things any more modular is fairly difficult. Packages can come along and provide other fancy functions if they like.