From: Simen Heggestøyl Date: Sat, 22 Aug 2015 17:13:10 +0000 (+0200) Subject: Handle comments inside unquoted URIs in css-mode X-Git-Tag: emacs-25.0.90~1299 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7372c1ab067ba93054fbb042cd13211042b83614;p=emacs.git Handle comments inside unquoted URIs in css-mode * lisp/textmodes/css-mode.el (css--uri-re): New defconst. (css-syntax-propertize-function): New defconst. (css--font-lock-keywords): Handle parens around unquoted URIs. (css-mode): Set `syntax-propertize-function'. --- diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 424cdb7f830..d73780caf36 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -198,6 +198,16 @@ (modify-syntax-entry ?- "_" st) st)) +(eval-and-compile + (defconst css--uri-re + (concat + "url\\((\\)[[:space:]]*\\(?:\\\\.\\|[^()[:space:]\n'\"]\\)+" + "[[:space:]]*\\()\\)"))) + +(defconst css-syntax-propertize-function + (syntax-propertize-rules + (css--uri-re (1 "|") (2 "|")))) + (defconst css-escapes-re "\\\\\\(?:[^\000-\037\177]\\|[0-9a-fA-F]+[ \n\t\r\f]?\\)") (defconst css-nmchar-re (concat "\\(?:[-[:alnum:]]\\|" css-escapes-re "\\)")) @@ -278,7 +288,13 @@ "\\(?:\\(" css-proprietary-nmstart-re "\\)\\|" css-nmstart-re "\\)" css-nmchar-re "*" "\\)\\s-*:") - (1 (if (match-end 2) 'css-proprietary-property 'css-property))))) + (1 (if (match-end 2) 'css-proprietary-property 'css-property))) + ;; Make sure the parens in a url(...) expression receive the + ;; default face. This is done because the parens may sometimes + ;; receive generic string delimiter syntax (see + ;; `css-syntax-propertize-function'). + (,css--uri-re + (1 'default t) (2 'default t)))) (defvar css-font-lock-keywords (css--font-lock-keywords)) @@ -381,6 +397,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)