Ported stuff over from emacs prelude.