Initial commit of patch. Little changes from the original to make it fit with current Arch emacs sources.