From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.devel Subject: Re: html, css, and js modes working together Date: Mon, 06 Feb 2017 20:40:47 -0700 Message-ID: <87zihy7jnk.fsf@tromey.com> References: <87o9ynarz3.fsf@tromey.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1486438905 19845 195.159.176.226 (7 Feb 2017 03:41:45 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 7 Feb 2017 03:41:45 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.91 (gnu/linux) Cc: Tom Tromey , Emacs discussions To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Feb 07 04:41:42 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cawey-0004oE-N9 for ged-emacs-devel@m.gmane.org; Tue, 07 Feb 2017 04:41:41 +0100 Original-Received: from localhost ([::1]:51853 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cawf1-0005Ya-11 for ged-emacs-devel@m.gmane.org; Mon, 06 Feb 2017 22:41:43 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1caweN-0005YK-5j for emacs-devel@gnu.org; Mon, 06 Feb 2017 22:41:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1caweK-0005eG-0L for emacs-devel@gnu.org; Mon, 06 Feb 2017 22:41:03 -0500 Original-Received: from gproxy7-pub.mail.unifiedlayer.com ([70.40.196.235]:44953) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1caweJ-0005dz-IV for emacs-devel@gnu.org; Mon, 06 Feb 2017 22:40:59 -0500 Original-Received: (qmail 31731 invoked by uid 0); 7 Feb 2017 03:40:54 -0000 Original-Received: from unknown (HELO cmgw3) (10.0.90.84) by gproxy7.mail.unifiedlayer.com with SMTP; 7 Feb 2017 03:40:54 -0000 Original-Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id hfgo1u0062f2jeq01fgrsT; Mon, 06 Feb 2017 20:40:54 -0700 X-Authority-Analysis: v=2.1 cv=WOnsABcR c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=n2v9WMKugxEA:10 a=vaJtXVxTAAAA:8 a=nn08sUxBZFQYomYG4xUA:9 a=L03L2QfmqWoA:10 a=hCt-GehETBxEYQOojhlW:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=1/uecmlNxqIZ/1szFjT2r7Z0IzZm5p/FlfhnQcWDsPw=; b=cN7FLuRF2Ksv/PN+gXNiKLAKRP SjUvaWPK7EVA/LduWxvMYjnPFbp+2efbfwTLRgHBn8SmtjRhL7kFyS5vI5TUV2oN5LZ8GPOOp8PDf uiyKy0lT2e8ClsvEtCUGbaFrZ; Original-Received: from 174-16-146-181.hlrn.qwest.net ([174.16.146.181]:36758 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1cawe8-0004nS-3D; Mon, 06 Feb 2017 20:40:48 -0700 X-Attribution: Tom In-Reply-To: (Dmitry Gutov's message of "Mon, 6 Feb 2017 05:08:05 +0200") X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box522.bluehost.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 174.16.146.181 X-Exim-ID: 1cawe8-0004nS-3D X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-146-181.hlrn.qwest.net (bapiya) [174.16.146.181]:36758 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 70.40.196.235 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:212075 Archived-At: >>>>> "Dmitry" == Dmitry Gutov writes: Dmitry> - Try this example: Dmitry> Dmitry> Dmitry> Dmitry> It indents fine. Now try replacing "4" with "4 < 5" and reindenting Dmitry> the "alert" line. It jumps to the right. I debugged this tonight. The problem here is that sgml-parse-tag-backward looks for "<" or ">" characters, but doesn't consider the syntax. The appended patch fixes this test case. My hope is that the html-syntax-propertize-function -- maybe not the one I wrote but one that's been fixed according to the various comments in this thread -- should suffice to fix all such problems in principle. Something like this problem in sgml-parse-tag-backward doesn't invalidate the scheme; this is just a buglet. What do you think? Tom diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index a2f132c..5e0a407 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -1290,13 +1290,24 @@ sgml-tag-text-p (let ((pps (parse-partial-sexp start end 2))) (and (= (nth 0 pps) 0)))))) +(defun sgml--find-<>-backward (limit) + "Search backward for a '<' or '>' character. +The character must have open or close syntax. +Returns t if found, nil otherwise." + (catch 'found + (while (re-search-backward "[<>]" limit 'move) + ;; If this character has "open" or "close" syntax, then we've + ;; found the one we want. + (when (memq (syntax-class (syntax-after (point))) '(4 5)) + (throw 'found t))))) + (defun sgml-parse-tag-backward (&optional limit) "Parse an SGML tag backward, and return information about the tag. Assume that parsing starts from within a textual context. Leave point at the beginning of the tag." (catch 'found (let (tag-type tag-start tag-end name) - (or (re-search-backward "[<>]" limit 'move) + (or (sgml--find-<>-backward limit) (error "No tag found")) (when (eq (char-after) ?<) ;; Oops!! Looks like we were not in a textual context after all!.