From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Newsgroups: gmane.emacs.bugs Subject: bug#20859: 25.0.50; css-mode: Comments within URIs Date: Sun, 21 Jun 2015 19:38:11 +0200 Message-ID: <1434908291.13002.0@smtp.gmail.com> References: <1434812678.1585.2@smtp.gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=-yh74Jp8s18/IfXojm6m2" X-Trace: ger.gmane.org 1434908365 28211 80.91.229.3 (21 Jun 2015 17:39:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 21 Jun 2015 17:39:25 +0000 (UTC) To: 20859@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jun 21 19:39:14 2015 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 1Z6jD6-0000fJ-0t for geb-bug-gnu-emacs@m.gmane.org; Sun, 21 Jun 2015 19:39:12 +0200 Original-Received: from localhost ([::1]:36878 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z6jD5-0001lk-IE for geb-bug-gnu-emacs@m.gmane.org; Sun, 21 Jun 2015 13:39:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34940) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z6jD0-0001iS-TA for bug-gnu-emacs@gnu.org; Sun, 21 Jun 2015 13:39:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z6jCw-0000KA-RS for bug-gnu-emacs@gnu.org; Sun, 21 Jun 2015 13:39:06 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:52077) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z6jCw-0000K6-Nb for bug-gnu-emacs@gnu.org; Sun, 21 Jun 2015 13:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Z6jCw-00042l-AX for bug-gnu-emacs@gnu.org; Sun, 21 Jun 2015 13:39:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <1434812678.1585.2@smtp.gmail.com> Resent-From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 21 Jun 2015 17:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20859 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 20859-submit@debbugs.gnu.org id=B20859.143490830215489 (code B ref 20859); Sun, 21 Jun 2015 17:39:02 +0000 Original-Received: (at 20859) by debbugs.gnu.org; 21 Jun 2015 17:38:22 +0000 Original-Received: from localhost ([127.0.0.1]:53523 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z6jCI-00041k-4W for submit@debbugs.gnu.org; Sun, 21 Jun 2015 13:38:22 -0400 Original-Received: from mail-wi0-f182.google.com ([209.85.212.182]:38060) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z6jCG-00041W-7C for 20859@debbugs.gnu.org; Sun, 21 Jun 2015 13:38:20 -0400 Original-Received: by wibdq8 with SMTP id dq8so56248032wib.1 for <20859@debbugs.gnu.org>; Sun, 21 Jun 2015 10:38:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:subject:to:message-id:mime-version:content-type; bh=U5HqcRwrgiT/0G7OfQIL2Dxa8cpn1YXhRsFUO5XESYY=; b=mAfrpCq+qNf8b/YOdHhXcX/8bwi+X7Z0RgKrPFzA+ii8lfvvG/2iZ+q8ZjFmXHg5fU +B/rjOS3daM0djxMmThga4LUATozeUyo8gqgWI0O7R/qNH/fRRQ1XzFr9BdiQJKIU2Ne EyjlDh0ERF6OybcBbf19EcZVZRwv4KHMacGivNZXkTbfShK8whXcJA69ObreWpy1svrP xKGjpyJvJqprh1E19WJV1BH6AceQ5yfUvbJnLqHunDx9OgDFI4FZnp1jbzmIBhU+Yg3Q HlN1S4sYqWpoX3vDksFj2cOkP37B6yx16QHRWH7Wx76kyiwRo6MmfWZHdDCLUn+zCqfz kVDg== X-Received: by 10.194.250.98 with SMTP id zb2mr44701195wjc.90.1434908294369; Sun, 21 Jun 2015 10:38:14 -0700 (PDT) Original-Received: from [192.168.1.114] (cm-84.215.41.199.getinternet.no. [84.215.41.199]) by mx.google.com with ESMTPSA id cd9sm26619804wjc.34.2015.06.21.10.38.12 for <20859@debbugs.gnu.org> (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Jun 2015 10:38:13 -0700 (PDT) X-Mailer: geary/0.10.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.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:104180 Archived-At: --=-yh74Jp8s18/IfXojm6m2 Content-Type: text/plain; charset=utf-8; format=flowed I think I found a solution, by applying the string syntax class to the whole URI. Please consider the following patch: From 69e4a7635f17dd2b5cb773b9088d154687a75b44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= Date: Sat, 20 Jun 2015 17:17:31 +0200 Subject: [PATCH] Handle comments inside unquoted URIs in css-mode * css-mode.el (css-syntax-propertize-function): New function. (css-mode): Set `syntax-propertize-function'. (Bug#20859) --- lisp/textmodes/css-mode.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 424cdb7..9ffaa0a 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -198,6 +198,18 @@ (modify-syntax-entry ?- "_" st) st)) +(defun css-syntax-propertize-function (start end) + (save-excursion + (goto-char start) + ;; Allow comment starters to appear inside unquoted URIs, such as + ;; url(http://www.example.com/*/). + (while (re-search-forward + "url\([[:space:]]*\\([^\"'\n[:space:]]+\\)[[:space:]]*\)" + end t) + (add-text-properties + (match-beginning 1) (match-end 1) + '(syntax-table (2) font-lock-face font-lock-string-face))))) + (defconst css-escapes-re "\\\\\\(?:[^\000-\037\177]\\|[0-9a-fA-F]+[ \n\t\r\f]?\\)") (defconst css-nmchar-re (concat "\\(?:[-[:alnum:]]\\|" css-escapes-re "\\)")) @@ -381,6 +393,8 @@ pseudo-classes, and at-rules." (setq-local comment-start-skip "/\\*+[ \t]*") (setq-local comment-end "*/") (setq-local comment-end-skip "[ \t]*\\*+/") + (setq-local syntax-propertize-function + #'css-syntax-propertize-function) (setq-local fill-paragraph-function #'css-fill-paragraph) (setq-local adaptive-fill-function #'css-adaptive-fill) (setq-local add-log-current-defun-function #'css-current-defun-name) -- 2.1.4 --=-yh74Jp8s18/IfXojm6m2 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
I think I found a solution, by applying the string syntax class t= o the
whole URI.

Please consider t= he following patch:


From 69e4a7635f= 17dd2b5cb773b9088d154687a75b44 Mon Sep 17 00:00:00 2001
From: =3D= ?UTF-8?q?Simen=3D20Heggest=3DC3=3DB8yl?=3D <simenheg@gmail.com>
=
Date: Sat, 20 Jun 2015 17:17:31 +0200
Subject: [PATCH] Handl= e comments inside unquoted URIs in css-mode

* css-= mode.el (css-syntax-propertize-function): New function.
(css-mode= ): Set `syntax-propertize-function'.  (Bug#20859)
---
<= div> lisp/textmodes/css-mode.el | 14 ++++++++++++++
 1 = file changed, 14 insertions(+)

diff --git a/lisp/t= extmodes/css-mode.el b/lisp/textmodes/css-mode.el
index 424cdb7..= 9ffaa0a 100644
--- a/lisp/textmodes/css-mode.el
+++ b/l= isp/textmodes/css-mode.el
@@ -198,6 +198,18 @@
  &= nbsp;  (modify-syntax-entry ?- "_" st)
     s= t))
 
+(defun css-syntax-propertize-function (star= t end)
+  (save-excursion
+    (goto-cha= r start)
+    ;; Allow comment starters to appear insid= e unquoted URIs, such as
+   &nbs= p;(while (re-search-forward
+           =  "url\([[:space:]]*\\([^\"'\n[:space:]]+\\)[[:space:]]*\)"
+=            end t)
+     =  (add-text-properties
+       (match-beginnin= g 1) (match-end 1)
+       '(syntax-table (2) font= -lock-face font-lock-string-face)))))
+
 (defconst= css-escapes-re
   "\\\\\\(?:[^\000-\037\177]\\|[0-9a-f= A-F]+[ \n\t\r\f]?\\)")
 (defconst css-nmchar-re (concat "\\(= ?:[-[:alnum:]]\\|" css-escapes-re "\\)"))
@@ -381,6 +393,8 @@ pse= udo-classes, and at-rules."
   (setq-local comment-star= t-skip "/\\*+[ \t]*")
   (setq-local comment-end "*/")<= /div>
   (setq-local comment-end-skip "[ \t]*\\*+/")
+  (setq-local syntax-propertize-function
+     =          #'css-syntax-propertize-function)
   (setq-local fill-paragraph-function #'css-fill-paragraph)
   (setq-local adaptive-fill-function #'css-adaptive-fil= l)
   (setq-local add-log-current-defun-function #'css-= current-defun-name)
-- 
2.1.4
= --=-yh74Jp8s18/IfXojm6m2--