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: Sat, 16 Jun 2012 17:27:19 +0400
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1

On 16.06.2012 10:17, Stefan Monnier wrote:
2) sgml-indent-line calls sgml-parse-tag-backward, which does
(re-search-backward "[<>]"), finds "<" and performs simple regexp check.
Thus,<% if a<  3 %>  breaks indentation on following lines, until first
closing tag.
I think we can treat this as a bug in sgml-indent-line, which should try
and use syntax-ppss or something like that instead of regexps.
I wonder how that could be fixed exactly. parse-partial-sexp doesn't look
helpful, because it works with single characters, and sgml is concerned with
full tags. It also has to handle unclosed tags like <br>, some closing tags
are optional, and HTML 4 has self-closing tags.

I think just checking after the regexp-match whether the match was found
within a "comment" should do the trick, assuming we can get syntax-ppss
(or some extension thereof) to treat "other modes" as comments.

That should work. Looks like currently it looks for comments with (search-backward), too.

If parse-partial-sexp just starts from (point-min), and then skips over
"comments", it will never visit submode regions this way, no?

That's why we'd need to hook into syntax-ppss to run parse-partial-sexp
on a chunk-by-chunk basis, maybe.  Also parse-sexp-ignore-comments also
affects (for|back)ward-sexp, as well as up-list, which are important
building blocks for indentation algorithms.

Another thing to consider - having "visibility" into previous chunks of the
same submode may be more harmful than useful in some cases.

That's OK: the low-level code can't know those things, but the
higher-level code which handles the various chunks can treat different
chunks differently.  E.g. using narrow-to-region for chunks which need
to ignore previous text.

Yes, well, except js-indent-line calls (widen) first thing, so (narrow-to-region) will not help.



reply via email to

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