v3. Convert to local module. Add option to discriminate on buffer type. (This is meant to be applied atop bug#60954. The attached version has been modified to apply cleanly on HEAD but is untested as such. See https://emacs-erc.gitlab.io/bugs/49860/patches.tar.gz for the combined set in its natural order.)