emacs-devel
[Top][All Lists]
Advanced

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

Re: html, css, and js modes working together


From: Dmitry Gutov
Subject: Re: html, css, and js modes working together
Date: Mon, 6 Feb 2017 05:46:48 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0

On 06.02.2017 05:26, Tom Tromey wrote:

I'm not sure what you're referring to here.  Do some of the existing
mixed mode things piggyback on the existing html mode?

Both https://github.com/purcell/mmm-mode/ and https://github.com/vspinu/polymode/ do.

I guess my view is that it is always ok to make things in-tree work
better with each other, even at the expense of some code that is
out-of-tree and presumably relying on implementation details to do its
work.

Still, defining a new major mode instead of directly reusing an existing one shouldn't take a lot of effort. Especially while the result is functional but not ideal.

And breaking packages that worked fine for many years is not nice, especially when it can be avoided.

Dmitry> So far it's only used in python-mode, I think.

grep shows no users in-tree, so maybe this never went in?  Or is this
one of the various out-of-tree python modes?

lisp/progmodes/python.el uses prog-first-column and prog-widen, both of which refer to prog-indentation-context.

Yeah, what I mean is that font-locking does not occur, but it would be
good to have.  I couldn't find anything saying how this might be solved.
I haven't come up with any really good ideas myself.  Maybe font-lock
could also look at text properties to decide what keywords to use?

Here's one way to do it: https://github.com/purcell/mmm-mode/blob/master/mmm-region.el#L768-L787

Dmitry> - Both css-mode and js-mode call syntax-ppss in their indentation
Dmitry> code. Luckily, their syntax tables are fairly compatible. But
Dmitry> sgml-syntax-propertize-rules calls syntax-ppss as well.

I thought that a syntax-table property on the characters would make
syntax-ppss do the "right" thing; namely, notice where the syntax table
changes and change its parsing method accordingly.

That seems orthogonal to the possibility of breaking the cache after calling syntax-ppss while a different syntax table is in effect.

The characters with the syntax-table text property set should be the same in both "world views", but they are usually a minority.

I didn't try your example yet.  Thanks for providing that, that's very
helpful.

No problem. BTW, I've worked around it with a hack like this: https://github.com/purcell/mmm-mode/blob/master/mmm-erb.el#L93-L98



reply via email to

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