bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Dmitry Gutov
Subject: bug#41897: 28.0.50; JavaScript comment filling with mhtml-mode
Date: Wed, 24 Jun 2020 21:28:09 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0

Hi Alan,

On 24.06.2020 20:43, Alan Mackenzie wrote:

That's what I mean.  The cache persists over commands, reducing the
amount of recalculation needed, particularly for fast typing.  Refilling
it from scratch on every keypress would likely make it sluggish.

Not on every keypress. Only when js-fill-paragraph is called. One-time
delay only when required.

But a substantial delay, involving (I think) analysing the code from BOB
each time.  The current working setup has a negligible delay at each
buffer change (and, of course, recalculation of cache entries only when
required).

I imagine that would not be a significant problem for the rare cases that fill-paragraph is called in a JS region. Considering most of the contents in mhtml-mode buffers are not JS code, on average, that should tilt the scales in favor of parsing lazily, rather than affecting every character insertion.

Anyhow, it works fine at the moment, so why change it?

The above scheme would require fewer references to CC Mode functions
from outside. js-mode support would automatically transfer to mhtml-mode
and mmm-mode with associated changes in them necessary.

It sounds like you want to use a facility without initialising it.  This
feels a bit unreasonable.

That cache reset at the beginning of js-fill-paragraph could as well re-initialize the cache.

One fewer before-change-functions element is also nothing to sneeze at.

There's nothing wrong with having functions in
before/after-change-functions.  It's a standard Emacs programming
technique.

I'm not saying it's a terrible idea, but it has its downsides.

js-mode mostly works, aside from features like this one.

With the current patch, comment filling should work fine in js-mode.

Above, I meant that js-mode mostly works fine with mmm-mode. And my
suggestion might make comment filling work there, too. Automatically.

It works automatically at the moment (with the current patch applied).  I
think you're saying again you don't want to be troubled by initialising
it.

It doesn't automatically work in mmm-mode. With my suggestion, it very likely would.

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

Not without the before-change function, no.  I'm trying to see what the
point of putting these variables into mhtml's crucial variables would be.

Hopefully, it would make the submode regions inside independent
"islands", so to speak. Each of them having its own cache structure
(used or not).

Ah, OK.  So, buffer positions would be offsets from the island start, or
something like that.

Not necessarily, but possibly. The key aspect is that the cache inside a
particular submode is not affected by user actions outside of its
bounds. Not directly, at least.

Well, when a cached holds buffer positions, something has to give -
either markers need to be used, or an offset from a variable position, or
something.

Makes sense. The alternative would be to index the positions from the beginning of the submode region. But then the related feature must respect narrowing, and it would require explicit integration from mmm-mode and friends.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]