From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dale Newsgroups: gmane.emacs.bugs Subject: bug#13844: [PATCH] Fix html-mode quotes syntax in text Date: Thu, 28 Feb 2013 19:01:30 -0600 Message-ID: <512FFDEA.6040000@codefu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1362102491 24459 80.91.229.3 (1 Mar 2013 01:48:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 1 Mar 2013 01:48:11 +0000 (UTC) To: 13844@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Mar 01 02:48:35 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1UBF5O-00005s-3T for geb-bug-gnu-emacs@m.gmane.org; Fri, 01 Mar 2013 02:48:34 +0100 Original-Received: from localhost ([::1]:48109 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBF52-0002qV-Tq for geb-bug-gnu-emacs@m.gmane.org; Thu, 28 Feb 2013 20:48:12 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:38224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBF4x-0002lZ-Js for bug-gnu-emacs@gnu.org; Thu, 28 Feb 2013 20:48:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UBF4u-0002bJ-9H for bug-gnu-emacs@gnu.org; Thu, 28 Feb 2013 20:48:07 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:51568) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBF4u-0002b3-5r for bug-gnu-emacs@gnu.org; Thu, 28 Feb 2013 20:48:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UBF6o-0008QB-6l for bug-gnu-emacs@gnu.org; Thu, 28 Feb 2013 20:50:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dale Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 01 Mar 2013 01:50:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 13844 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.136210258432328 (code B ref -1); Fri, 01 Mar 2013 01:50:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 1 Mar 2013 01:49:44 +0000 Original-Received: from localhost ([127.0.0.1]:57024 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UBF6V-0008PL-GJ for submit@debbugs.gnu.org; Thu, 28 Feb 2013 20:49:44 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:35703) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UBENy-0007JJ-7O for submit@debbugs.gnu.org; Thu, 28 Feb 2013 20:03:43 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UBEM0-0003Pu-Ka for submit@debbugs.gnu.org; Thu, 28 Feb 2013 20:01:43 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:46535) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBEM0-0003Pq-Hd for submit@debbugs.gnu.org; Thu, 28 Feb 2013 20:01:40 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:47052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBELx-00078u-VM for bug-gnu-emacs@gnu.org; Thu, 28 Feb 2013 20:01:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UBELt-0003P2-Uj for bug-gnu-emacs@gnu.org; Thu, 28 Feb 2013 20:01:37 -0500 Original-Received: from mail-ie0-x236.google.com ([2607:f8b0:4001:c03::236]:49458) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBELt-0003Ou-Qy for bug-gnu-emacs@gnu.org; Thu, 28 Feb 2013 20:01:33 -0500 Original-Received: by mail-ie0-f182.google.com with SMTP id k14so2935069iea.13 for ; Thu, 28 Feb 2013 17:01:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding:x-gm-message-state; bh=5/NRwXbW5ekQo3sfX818kQFLVCWOdbLdwcgE4HjAaZ4=; b=d+pkBTVcosU3u6T47QhkzARQ+zTzyt3jqPK+BtedTVO4h45M5dT8Hkh3glPZBRVCd0 i9CAG93vaXE05oqyPYyboDbsTVuaibd4Y2WvkXsxpF9Zvx9fOp3HW9QuxjdF2DxIy2nT 0cFBTFIMS4It5RpvarOLC43XjDEITOy+ClqAsWfc0P14bVCQlTaq8EK37tO+mMIOgfrr fzbg9U20viouUhEvxV+FqpkodHrAgght4KIjbC4BWiRvGFVECfs1vBGNtDFNGlUKX7WZ jYVcaUrHZRei2dAsP8/bop8t3tNc/7Pi+Rm79NAVcOsmSYAPdEohhBvp1VbRpnnmqUP9 qzTg== X-Received: by 10.50.47.200 with SMTP id f8mr11610219ign.98.1362099692519; Thu, 28 Feb 2013 17:01:32 -0800 (PST) Original-Received: from dale.caliginous.net (c-67-165-179-226.hsd1.il.comcast.net. [67.165.179.226]) by mx.google.com with ESMTPS id wo8sm7991584igb.6.2013.02.28.17.01.31 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Feb 2013 17:01:31 -0800 (PST) User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 X-Gm-Message-State: ALoCoQnpgByojkSKjh2rnKoZLPmbJp3ozXwogKKwtwXJPtdKV6Xlj7gTMfx6aNvw4M83KrWWWWLd X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Mailman-Approved-At: Thu, 28 Feb 2013 20:49:41 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:71965 Archived-At: Hi, I noticed Emacs was colorizing the following sample wrong in html-mode: ~~~~~~
" Dangling quote makes the closing tag get highlighted as a string
" Highlighting now fixed:
Additionally, if you have apostrophe in sgml-specials, this more common usage will break: Dave's bar Now this tag will have incorrect highlighting:
~~~~~~ I believe I've tracked this down to two problems: 1. sgml-syntax-propertize-function is already prepared to correctly set the syntax on " (double quotes) within text, but returns "." for the syntax-table property value. That's not a valid value for syntax-table propertize. It needs to use (string-to-syntax "."). 2. sgml-syntax-propertize-function doesn't account for the fact that you could have set ' (apostrophe) in sgml-specials, which causes apostrophe to be set as string syntax in the syntax table, just like " is by default. The patch below hopefully fixes both problems. I believe I have filed my copyright assignment with the FSF for Emacs already. ChangeLog entry: ~~~~~~ 2013-02-28 Dale Sedivec * textmodes/sgml-mode.el (sgml-syntax-propertize-function): Return valid syntax-table property value when converting quotes within text from string syntax to punctuation syntax. Also perform this adjustment when apostrophe (?') is in sgml-specials. ~~~~~~ Patch against Git master follows. Dale *** /var/folders/l1/l_tpw26n35zbm0fp4x22_vjh0000kk/T//85VjC0_sgml-mode.el 2013-02-28 19:00:02.000000000 -0600 --- lisp/textmodes/sgml-mode.el 2013-02-28 18:54:52.000000000 -0600 *************** *** 312,328 **** (defconst sgml-syntax-propertize-function (syntax-propertize-rules ! ;; Use the `b' style of comments to avoid interference with the -- ... -- ! ;; comments recognized when `sgml-specials' includes ?-. ! ;; FIXME: beware of blabla !! ("\\(<\\)!--" (1 "< b")) ! ("--[ \t\n]*\\(>\\)" (1 "> b")) ! ;; Double quotes outside of tags should not introduce strings. ! ;; Be careful to call `syntax-ppss' on a position before the one we're ! ;; going to change, so as not to need to flush the data we just computed. ! ("\"" (0 (if (prog1 (zerop (car (syntax-ppss (match-beginning 0)))) ! (goto-char (match-end 0))) ! ".")))) "Syntactic keywords for `sgml-mode'.") ;; internal --- 312,335 ---- (defconst sgml-syntax-propertize-function (syntax-propertize-rules ! ;; Use the `b' style of comments to avoid interference with the -- ... -- ! ;; comments recognized when `sgml-specials' includes ?-. ! ;; FIXME: beware of blabla !! ("\\(<\\)!--" (1 "< b")) ! ("--[ \t\n]*\\(>\\)" (1 "> b")) ! ;; Quotes (single or double) outside of tags should not introduce ! ;; strings. Be careful to call `syntax-ppss' on a position before ! ;; the one we're going to change, so as not to need to flush the ! ;; data we just computed. ! ((let (string-delimiters) ! (when (memq ?\" sgml-specials) ! (setq string-delimiters (cons ?\" string-delimiters))) ! (when (memq ?' sgml-specials) ! (setq string-delimiters (cons ?' string-delimiters))) ! (regexp-opt-charset string-delimiters)) ! (0 (if (prog1 (zerop (car (syntax-ppss (match-beginning 0)))) ! (goto-char (match-end 0))) ! (string-to-syntax "."))))) "Syntactic keywords for `sgml-mode'.") ;; internal