Guess the only thing that remains for me here is to express a wish for a
syntax-ppss based design here.
Because mmm-mode knows how to deal with major modes based on it, as a group.
How about enhancing mmm-mode to handle any major mode, rather than a
restricted subset?
It does not pick up each and every hook.
If it did, though, it would only call your before-change-functions
inside js-mode regions, but it would have ignored them in HTML and CSS
regions. Which doesn't appear to be what you want anyway.
Then why not do in mmm-mode what I'm doing in CC Mode, mhtml-mode and
js-mode, i.e. add ad hoc code to handle precisely the case of js-mode?
There's no problem with before/after-change-functions. They're the
canonical way to react to buffer changes.
They're not very manageable, from mmm's point of view. And like the
current example shows, it's not obvious what to do with such hooks
outside of submode regions of major modes that added them.
Like I said earlier on in the thread, making several major modes in a
buffer work is problematic in Emacs, and we really want better support
from the C core for it. Here we seem to want "global" and "mode-local"
before-change-functionses.