[Top][All Lists]

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

Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss return

From: Dmitry Gutov
Subject: Re: Syntax tables for multiple modes [was: bug#22983: syntax-ppss returns wrong result.]
Date: Wed, 23 Mar 2016 03:18:44 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0

On 03/22/2016 08:17 PM, Vitalie Spinu wrote:

This will not work in above case. <%else-%> chunk needs to know about where <%if
signed_in? -%> was indented which is not an immediately preceding chunk.

It's hard to think of better solution than collecting all relevant previous
chunks in one place and indenting according to inner mode. In order to indent
"<%else-%>", STRING-BEFORE should be full "link_to ..." line. So basically
STRING-BEFORE must consist of all ruby spans in between "if" and "else" chunks.

...and the multi-mode package would have to know, somehow, that the "if" chunk is special in this regard, and know which "if" matches which "end", etc. Or simply always include all previous chunks in the given mode in STRING-BEFORE.

How should the "generic" code that links HTML and Ruby know when to indent
using the HTML indentation code and when to use the Ruby indentation rules?

No idea. Dmitry should have an answer for that. He implemented mmm-erb.

Again, mmm-erb is written to support a limited set of template languages (currently, two, though supporting JSP would be trivial-ish, were java-mode not a part of CC Mode, with associated pitfalls).

So IME, the multi-mode package needs to hardcode, in some form of another, the knowledge which file formats use this approach to indentation.

And since we're doing that anyway, using a simpler indentation code in those particular files doesn't seem like a bad idea either. (For non-continuation hunks, at least).

BTW, web-mode doesn't seem to dispatch to inner modes's functions at all: https://github.com/fxbois/web-mode/blob/c5aacacb8f4c233844306806a102405c8e9671c9/web-mode.el#L7164-L7198. I'm not a fan of this approach in general, but that clearly means that it can work for indentation.

reply via email to

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