Bring in a lot of the stuff from rewrite rtags.el