Subject: bug#41897: 28.0.50; JavaScript comment filling with mhtml-mode

From: Dmitry Gutov <[email-masked]>
Date: Tue, 23 Jun 2020 17:23:53 +0300

On 23.06.2020 11:36, Alan Mackenzie wrote:

>> If the latter (and it does serve as a cache this way), perhaps it
>> could be cleared once, at the beginning of c-fill-paragraph, instead
>> of adding a runtime cost to every edit?
> 
> The cost is tiny.  c-truncate-lit-pos-cache is a defsubst which does
> nothing but three copies of
> 
>      (setq cache-limit (min beg cache-limit))
> 
> .  All the intricacies of manipulating the cache take place whilst it is
> being used.
> 
>> Or if that's undesirable, js-fill-paragraph could do that.
> 
> No, it really has to be in a before-change-functions function, to keep
> track of the bound of the valid cache.

So it's really fine if it's called from HTML/CSS hunks as well?

And there's no way to just "reset" it to an appropriate value?

>> This way, I think it would automatically make it compatible with
>> mmm-mode. Or at least more compatible.
> 
> Maybe putting the two c-foreign-* functions into mmm-mode would work.

mmm-mode is a minor mode, it doesn't always deal with CC Mode.

And its configurations don't usually result in new major modes either.

I wouldn't say it's very hard to make it work, but I don't see a "neat" 
way to do either.

Have you considered adding variables that hold the cache to 
mhtml--crucial-variable-prefix as well? Would that make it work?