Reviewing 56a7e7c made me start to think all of our regular expressions have built up too many backslashes and parentheses. I think we should consider rewriting them in terms of rx; here is an explanation of the macro. Anyone wanting full details can C-h f rx <RET> in Emacs itself. rx is surprisingly absent from the Emacs Lisp manual.