opensubscriber
   Find in this group all groups
 
Unknown more information…

e : emacs-devel@gnu.org 20 June 2012 • 12:04AM -0400

Re: web-mode.el
by Dmitry Gutov

REPLY TO AUTHOR
 
REPLY TO GROUP




On 19.06.2012 5:56, Lennart Borgman wrote:
> On Tue, Jun 19, 2012 at 3:18 AM, Dmitry Gutov <dgutov@yand...> wrote:
>>
>> What if the difference between mumamo-depth of pre-pre chunk and this one is
>> 1 or -1, can you indent correctly in this case? If so, why the difference of
>> 0 is a special case? Is this just a speed optimization?
>
> Yes, 0 is a special case. All chunks that "belongs to" the main major
> mode (this could be for example html-mode) in the file has
> mumamo-depth 0. Sub-chunks (for example a js or css chunk) has
> mumamo-depth 1, i.e. 0+1.
>
> The sub-chunks could themselves have sub-chunks which then have a +1
> greater mumamo-depth.
>
> If a pre-pre chunk has the same depth as this one then the code in
> this one could be a continuation of the code in the pre-pre chunk.
> (This could be the case in for example a file which html+php code.) So
> the user probably expects those chunks to be indented together.

Does that mean that

<div>
   <% if foo %>
     <span>Hello!</span>
   <% end %>
</div>

should be indented as

<div><!-- prev-prev chunk %>
   <% if foo %>
   <span>Hello!</span><!-- current chunk -->
   <% end %>
</div>

?

>>> Yes, I was trying to answer that. The reason it fails is because
>>> nxml-mode (like js2-mode) contains a full parser. I have been thinking
>>> that rewriting it is very difficult, but maybe Stefan's proposal (the
>>> change to "syntax-ppss") is a  rather easy road.
>>
>>
>> I don't think this changes much for nxml-mode: it uses the parser from
>> xmltok.el, which doesn't employ any of the -sexp commands.
>
> I thought that parser perhaps could use the -sexp commands for testing.

I think this will be a performance hit. When you just check sexp status
at important points, that's fine, but here you'd have to call
`syntax-ppss' each time you're scanning a token.

To look at it another way, an indent-line-function skipping comments is
normal. A parser, on the other hand, parses comments, too.


Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.