Thanks for the pointers. I installed the first attached patch into the emacs-26 branch. (Sorry about misspelling your name in the commit message; fixed in the second attached patch.)