Here's a variant of Martin's patch adapted to emacs-23.2.92, i.e. the current pretest. From what I can tell, it works. -- Simon.