I became obsessed with this (mainly because Philippe[3] tried to do a
better one for Emacs) and I ended up doing something that works fine
and I documented it at [1]. The code is at [2].
I removed the empty line before the signature cosmetic fix because it
makes it difficult to continue the editing (well, I had found other
solutions but I am happy with this one).