Closing this debbugs as the patch is now commited to the trunk: http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=ec0d4d24fd11b5040de9f7657b486c3b1e743071 Many thanks to Jay for a very active feedback session, helping make the final patch much more robust than the initial version.