a neat idea from Paul Eggert on emacs-devel