emacs-devel
[Top][All Lists]
Advanced

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

Re: web-mode.el


From: Dmitry Gutov
Subject: Re: web-mode.el
Date: Tue, 19 Jun 2012 20:04:21 +0400
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1

On 19.06.2012 5:56, Lennart Borgman wrote:
On Tue, Jun 19, 2012 at 3:18 AM, Dmitry Gutov <address@hidden> 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.



reply via email to

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