From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: web-mode.el Date: Fri, 15 Jun 2012 05:40:13 +0400 Message-ID: <4FDA927D.50306@yandex.ru> References: <4FD9F40C.90406@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1339724434 30941 80.91.229.3 (15 Jun 2012 01:40:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 15 Jun 2012 01:40:34 +0000 (UTC) Cc: cyd@gnu.org, lennart.borgman@gmail.com, emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 15 03:40:31 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SfLWV-00024K-Po for ged-emacs-devel@m.gmane.org; Fri, 15 Jun 2012 03:40:28 +0200 Original-Received: from localhost ([::1]:37787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfLWV-0003zp-OH for ged-emacs-devel@m.gmane.org; Thu, 14 Jun 2012 21:40:27 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:50405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfLWQ-0003kq-F2 for emacs-devel@gnu.org; Thu, 14 Jun 2012 21:40:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SfLWO-0004tx-Fm for emacs-devel@gnu.org; Thu, 14 Jun 2012 21:40:22 -0400 Original-Received: from forward4.mail.yandex.net ([77.88.46.9]:45935) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfLWL-0004so-1z; Thu, 14 Jun 2012 21:40:17 -0400 Original-Received: from smtp4.mail.yandex.net (smtp4.mail.yandex.net [77.88.46.104]) by forward4.mail.yandex.net (Yandex) with ESMTP id EA17E1BC154C; Fri, 15 Jun 2012 05:40:12 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1339724413; bh=Sz7200fCYm5BN5KX0YjZuSwL+lrKQp733SjlaqAdLwg=; h=Message-ID:Date:From:MIME-Version:To:CC:Subject:References: In-Reply-To:Content-Type:Content-Transfer-Encoding; b=DaZ83pEjkXF8RwTBhp+LlX36raJPjUhZxb1Avb1cbIG6bSZq+Z8nqwpWM3QIoEXVr iBmRNRRIg7kAZDHmTlgnMXzVenX0Z0FUVFVQRm15BD/YS5CzFDmg2ZcZzbkFwKewhA FvFVXL9VuAnUfcddFD38PviL0HzgAqSe60koWAnU= Original-Received: from smtp4.mail.yandex.net (localhost [127.0.0.1]) by smtp4.mail.yandex.net (Yandex) with ESMTP id 2BEBE5C02E8; Fri, 15 Jun 2012 05:40:11 +0400 (MSK) Original-Received: from 98-87.nwlink.spb.ru (98-87.nwlink.spb.ru [178.252.98.87]) by smtp4.mail.yandex.net (nwsmtp/Yandex) with ESMTP id eAfSubNb-eBfe8oq2; Fri, 15 Jun 2012 05:40:11 +0400 X-Yandex-Rcpt-Suid: monnier@iro.umontreal.ca X-Yandex-Rcpt-Suid: cyd@gnu.org X-Yandex-Rcpt-Suid: lennart.borgman@gmail.com X-Yandex-Rcpt-Suid: emacs-devel@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1339724411; bh=Sz7200fCYm5BN5KX0YjZuSwL+lrKQp733SjlaqAdLwg=; h=Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject: References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=HyyF6BK00/6mugNJnVu+x/wnexFkE0NY7J1M4j8e2y5WErGcKfW/Yih67VLi/EIMd 2dPOlI+2MCWXVlkecc3WWKy/h6qG8NRfCt05o5qJVZ7BUsV6sb/JgMuYrdNapfVp6d tUCjNJbSSMaiQZSYAyciXulewsznSPHhRXZv+muw= User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 77.88.46.9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:150954 Archived-At: On 14.06.2012 21:28, Stefan Monnier wrote: >> 1) js-mode uses (widen) at the beginning of js-indent-line, and then calls >> (syntax-ppss). > > Depending on how multi-major-mode works, widen is not necessarily > a problem. Clearly, it would need to hook into syntax-ppss. That's good. >> 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
, some closing tags are optional, and HTML 4 has self-closing tags. >>> Of course, tweaking some parts of the C mode might help. E.g. we could >>> maybe extend syntax-tables slightly so that chunk boundaries are marked >>> with a special syntax-table value which then makes forward-comment skip >>> over "other language" chunks, so that any indentation code which >>> consistently ignores comments would then work in multi-major-mode. >> As far as I can see, enhanced (forward-comment) won't help much with >> indentation. > > It would, if you combine it with parse-sexp-ignore-comments. If parse-partial-sexp just starts from (point-min), and then skips over "comments", it will never visit submode regions this way, no? Another thing to consider - having "visibility" into previous chunks of the same submode may be more harmful than useful in some cases. For example, when indenting the chunk in the middle, <% if true %>
<%= some_text %>
<% end %> the chunk will see the "if" statement, and decide that it should be indented only 2 spaces from. And since it does do some indenting, I can't with my current heuristic decide that it should be instead indented relative to the line 2. This is kinda handwavy, the example is contrived, the heuristic could be improved (suggestions welcome), but this could become more important for some other combinations of modes. Also, if I have an extra paren inside some