From unknown Tue Aug 19 07:09:36 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#25525 <25525@debbugs.gnu.org> To: bug#25525 <25525@debbugs.gnu.org> Subject: Status: 25.1.90; add color highlighting to css mode Reply-To: bug#25525 <25525@debbugs.gnu.org> Date: Tue, 19 Aug 2025 14:09:36 +0000 retitle 25525 25.1.90; add color highlighting to css mode reassign 25525 emacs submitter 25525 Tom Tromey severity 25525 wishlist tag 25525 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 25 03:07:44 2017 Received: (at submit) by debbugs.gnu.org; 25 Jan 2017 08:07:44 +0000 Received: from localhost ([127.0.0.1]:41448 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWIcJ-0006Zc-O8 for submit@debbugs.gnu.org; Wed, 25 Jan 2017 03:07:44 -0500 Received: from eggs.gnu.org ([208.118.235.92]:59362) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWIcH-0006ZP-LG for submit@debbugs.gnu.org; Wed, 25 Jan 2017 03:07:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cWIc4-0003oR-QF for submit@debbugs.gnu.org; Wed, 25 Jan 2017 03:07:36 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_50,RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:39543) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cWIc4-0003oM-MT for submit@debbugs.gnu.org; Wed, 25 Jan 2017 03:07:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50269) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWIc1-0003sM-HJ for bug-gnu-emacs@gnu.org; Wed, 25 Jan 2017 03:07:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cWIby-0003kj-6D for bug-gnu-emacs@gnu.org; Wed, 25 Jan 2017 03:07:25 -0500 Received: from gproxy9-pub.mail.unifiedlayer.com ([69.89.20.122]:47995 helo=gproxy9.mail.unifiedlayer.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cWIbx-0003gQ-ID for bug-gnu-emacs@gnu.org; Wed, 25 Jan 2017 03:07:22 -0500 Received: from CMOut01 (unknown [10.0.90.82]) by gproxy9.mail.unifiedlayer.com (Postfix) with ESMTP id 010FA1E0C75 for ; Wed, 25 Jan 2017 01:06:57 -0700 (MST) Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id cY6q1u00N2f2jeq01Y6ttl; Wed, 25 Jan 2017 01:06:55 -0700 X-Authority-Analysis: v=2.1 cv=H75InYoi 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=IgFoBzBjUZAA:10 a=6DmWVQPIf7JAJQnUgk0A:9 a=zstS-IiYAAAA:8 a=BcXV-_4havjdJU-tIZUA:9 a=EJsdeB0a1gU3Vzka:21 a=kL2s3ZrwCcusjf-_:21 a=VDEtfpoToLGKPWCa6wMA:9 a=TdWOT4xzaEZjwDgE:21 a=N6cwv5yv1pgz7ggB:21 a=4G6NA9xxw8l3yy4pmD5M: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:Date:Subject:To:From: Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=RpS341rkt3Pc/jrGLwm78kmSvkR0UC1DQa+AwAzxA+Y=; b=SKW5X49eg4HZBmgVyv5gwQghEJ Wf/ogG1xpDn+kZDBiltRgFg2UnjohC6lEYFXrDkNVXtiErT/L4QMFLx0oOlhQZApbBz/VhVkvSWlF m0ItA8fcQUGOxOVPOBrO3nLO1; Received: from 174-16-146-181.hlrn.qwest.net ([174.16.146.181]:49120 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1cWIbT-00065y-9Z; Wed, 25 Jan 2017 01:06:51 -0700 From: Tom Tromey To: bug-gnu-emacs@gnu.org Subject: 25.1.90; add color highlighting to css mode X-Attribution: Tom Date: Wed, 25 Jan 2017 01:06:48 -0700 Message-ID: <87mvefh8br.fsf@tromey.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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: 1cWIbT-00065y-9Z X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-146-181.hlrn.qwest.net (bapiya) [174.16.146.181]:49120 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.5 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.5 (----) --=-=-= Content-Type: text/plain This patch adds color highlighting to CSS mode. In particular, this provides a new jit-lock function that recognizes the various forms of CSS color syntax, including some css-color-4 additions. When such a color is seen, the background color of the text is set to the color itself. In order to remain readable, the foreground is set to a contrasting color, and a box is put around the text (this helps distinguish colors that are close to the buffer's background color). While doing this I noticed that css-mode was missing a few named colors specified by CSS, in particular: ("darkgrey" "darkslategrey" "dimgrey" "grey" "lightgrey" "lightslategrey" "slategrey") This patch fixes this problem as well. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=P Content-Description: the patch commit 2b873579a2b821c073826eed5bc199216fbc14ae Author: Tom Tromey Date: Wed Jan 25 00:53:49 2017 -0700 add color highlighting to css-mode * lisp/textmodes/css-mode.el (css--color-map): New constant. (css-value-class-alist): Use css--color-map. (css--number-regexp, css--percent-regexp) (css--number-or-percent-regexp, css--angle-regexp): New constants. (css--color-skip-blanks, css--rgb-color, css--hsl-color): New functions. (css--colors-regexp): New constant. (css--hex-color, css--compute-color, css--contrasty-color) (css--fontify-colors): New functions. (css-mode): Register css--fontify-colors with jit-lock. * test/lisp/textmodes/css-mode-tests.el (css-test-property-values): Update. (css-test-rgb-parser, css-test-hsl-parser): New tests. diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index c81c3f6..c4d86f5 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -32,6 +32,9 @@ ;;; Code: +(require 'cl-lib) +(require 'cl-macs) +(require 'color) (require 'seq) (require 'sgml-mode) (require 'smie) @@ -453,8 +456,157 @@ css-property-ids (mapcar #'car css-property-alist) "Identifiers for properties.") +(defconst css--color-map + '(("black" . "#000000") + ("silver" . "#c0c0c0") + ("gray" . "#808080") + ("white" . "#ffffff") + ("maroon" . "#800000") + ("red" . "#ff0000") + ("purple" . "#800080") + ("fuchsia" . "#ff00ff") + ("green" . "#008000") + ("lime" . "#00ff00") + ("olive" . "#808000") + ("yellow" . "#ffff00") + ("navy" . "#000080") + ("blue" . "#0000ff") + ("teal" . "#008080") + ("aqua" . "#00ffff") + ("orange" . "#ffa500") + ("aliceblue" . "#f0f8ff") + ("antiquewhite" . "#faebd7") + ("aquamarine" . "#7fffd4") + ("azure" . "#f0ffff") + ("beige" . "#f5f5dc") + ("bisque" . "#ffe4c4") + ("blanchedalmond" . "#ffebcd") + ("blueviolet" . "#8a2be2") + ("brown" . "#a52a2a") + ("burlywood" . "#deb887") + ("cadetblue" . "#5f9ea0") + ("chartreuse" . "#7fff00") + ("chocolate" . "#d2691e") + ("coral" . "#ff7f50") + ("cornflowerblue" . "#6495ed") + ("cornsilk" . "#fff8dc") + ("crimson" . "#dc143c") + ("darkblue" . "#00008b") + ("darkcyan" . "#008b8b") + ("darkgoldenrod" . "#b8860b") + ("darkgray" . "#a9a9a9") + ("darkgreen" . "#006400") + ("darkgrey" . "#a9a9a9") + ("darkkhaki" . "#bdb76b") + ("darkmagenta" . "#8b008b") + ("darkolivegreen" . "#556b2f") + ("darkorange" . "#ff8c00") + ("darkorchid" . "#9932cc") + ("darkred" . "#8b0000") + ("darksalmon" . "#e9967a") + ("darkseagreen" . "#8fbc8f") + ("darkslateblue" . "#483d8b") + ("darkslategray" . "#2f4f4f") + ("darkslategrey" . "#2f4f4f") + ("darkturquoise" . "#00ced1") + ("darkviolet" . "#9400d3") + ("deeppink" . "#ff1493") + ("deepskyblue" . "#00bfff") + ("dimgray" . "#696969") + ("dimgrey" . "#696969") + ("dodgerblue" . "#1e90ff") + ("firebrick" . "#b22222") + ("floralwhite" . "#fffaf0") + ("forestgreen" . "#228b22") + ("gainsboro" . "#dcdcdc") + ("ghostwhite" . "#f8f8ff") + ("gold" . "#ffd700") + ("goldenrod" . "#daa520") + ("greenyellow" . "#adff2f") + ("grey" . "#808080") + ("honeydew" . "#f0fff0") + ("hotpink" . "#ff69b4") + ("indianred" . "#cd5c5c") + ("indigo" . "#4b0082") + ("ivory" . "#fffff0") + ("khaki" . "#f0e68c") + ("lavender" . "#e6e6fa") + ("lavenderblush" . "#fff0f5") + ("lawngreen" . "#7cfc00") + ("lemonchiffon" . "#fffacd") + ("lightblue" . "#add8e6") + ("lightcoral" . "#f08080") + ("lightcyan" . "#e0ffff") + ("lightgoldenrodyellow" . "#fafad2") + ("lightgray" . "#d3d3d3") + ("lightgreen" . "#90ee90") + ("lightgrey" . "#d3d3d3") + ("lightpink" . "#ffb6c1") + ("lightsalmon" . "#ffa07a") + ("lightseagreen" . "#20b2aa") + ("lightskyblue" . "#87cefa") + ("lightslategray" . "#778899") + ("lightslategrey" . "#778899") + ("lightsteelblue" . "#b0c4de") + ("lightyellow" . "#ffffe0") + ("limegreen" . "#32cd32") + ("linen" . "#faf0e6") + ("mediumaquamarine" . "#66cdaa") + ("mediumblue" . "#0000cd") + ("mediumorchid" . "#ba55d3") + ("mediumpurple" . "#9370db") + ("mediumseagreen" . "#3cb371") + ("mediumslateblue" . "#7b68ee") + ("mediumspringgreen" . "#00fa9a") + ("mediumturquoise" . "#48d1cc") + ("mediumvioletred" . "#c71585") + ("midnightblue" . "#191970") + ("mintcream" . "#f5fffa") + ("mistyrose" . "#ffe4e1") + ("moccasin" . "#ffe4b5") + ("navajowhite" . "#ffdead") + ("oldlace" . "#fdf5e6") + ("olivedrab" . "#6b8e23") + ("orangered" . "#ff4500") + ("orchid" . "#da70d6") + ("palegoldenrod" . "#eee8aa") + ("palegreen" . "#98fb98") + ("paleturquoise" . "#afeeee") + ("palevioletred" . "#db7093") + ("papayawhip" . "#ffefd5") + ("peachpuff" . "#ffdab9") + ("peru" . "#cd853f") + ("pink" . "#ffc0cb") + ("plum" . "#dda0dd") + ("powderblue" . "#b0e0e6") + ("rosybrown" . "#bc8f8f") + ("royalblue" . "#4169e1") + ("saddlebrown" . "#8b4513") + ("salmon" . "#fa8072") + ("sandybrown" . "#f4a460") + ("seagreen" . "#2e8b57") + ("seashell" . "#fff5ee") + ("sienna" . "#a0522d") + ("skyblue" . "#87ceeb") + ("slateblue" . "#6a5acd") + ("slategray" . "#708090") + ("slategrey" . "#708090") + ("snow" . "#fffafa") + ("springgreen" . "#00ff7f") + ("steelblue" . "#4682b4") + ("tan" . "#d2b48c") + ("thistle" . "#d8bfd8") + ("tomato" . "#ff6347") + ("turquoise" . "#40e0d0") + ("violet" . "#ee82ee") + ("wheat" . "#f5deb3") + ("whitesmoke" . "#f5f5f5") + ("yellowgreen" . "#9acd32") + ("rebeccapurple" . "#663399")) + "Map CSS named color to their hex RGB value.") + (defconst css-value-class-alist - '((absolute-size + `((absolute-size "xx-small" "x-small" "small" "medium" "large" "x-large" "xx-large") (alphavalue number) @@ -506,36 +658,7 @@ css-value-class-alist (line-width length "thin" "medium" "thick") (linear-gradient "linear-gradient()") (margin-width "auto" length percentage) - (named-color - "aliceblue" "antiquewhite" "aqua" "aquamarine" "azure" "beige" - "bisque" "black" "blanchedalmond" "blue" "blueviolet" "brown" - "burlywood" "cadetblue" "chartreuse" "chocolate" "coral" - "cornflowerblue" "cornsilk" "crimson" "cyan" "darkblue" - "darkcyan" "darkgoldenrod" "darkgray" "darkgreen" "darkkhaki" - "darkmagenta" "darkolivegreen" "darkorange" "darkorchid" - "darkred" "darksalmon" "darkseagreen" "darkslateblue" - "darkslategray" "darkturquoise" "darkviolet" "deeppink" - "deepskyblue" "dimgray" "dodgerblue" "firebrick" "floralwhite" - "forestgreen" "fuchsia" "gainsboro" "ghostwhite" "gold" - "goldenrod" "gray" "green" "greenyellow" "honeydew" "hotpink" - "indianred" "indigo" "ivory" "khaki" "lavender" "lavenderblush" - "lawngreen" "lemonchiffon" "lightblue" "lightcoral" "lightcyan" - "lightgoldenrodyellow" "lightgray" "lightgreen" "lightpink" - "lightsalmon" "lightseagreen" "lightskyblue" "lightslategray" - "lightsteelblue" "lightyellow" "lime" "limegreen" "linen" - "magenta" "maroon" "mediumaquamarine" "mediumblue" "mediumorchid" - "mediumpurple" "mediumseagreen" "mediumslateblue" - "mediumspringgreen" "mediumturquoise" "mediumvioletred" - "midnightblue" "mintcream" "mistyrose" "moccasin" "navajowhite" - "navy" "oldlace" "olive" "olivedrab" "orange" "orangered" - "orchid" "palegoldenrod" "palegreen" "paleturquoise" - "palevioletred" "papayawhip" "peachpuff" "peru" "pink" "plum" - "powderblue" "purple" "rebeccapurple" "red" "rosybrown" - "royalblue" "saddlebrown" "salmon" "sandybrown" "seagreen" - "seashell" "sienna" "silver" "skyblue" "slateblue" "slategray" - "snow" "springgreen" "steelblue" "tan" "teal" "thistle" "tomato" - "turquoise" "violet" "wheat" "white" "whitesmoke" "yellow" - "yellowgreen") + (named-color . ,(mapcar #'car css--color-map)) (number "calc()") (numeric-figure-values "lining-nums" "oldstyle-nums") (numeric-fraction-values "diagonal-fractions" "stacked-fractions") @@ -726,6 +849,196 @@ css-font-lock-keywords (defvar css-font-lock-defaults '(css-font-lock-keywords nil t)) +(defconst css--number-regexp + "\\(\\(?:[0-9]*\\.[0-9]+\\(?:[eE][0-9]+\\)?\\)\\|[0-9]+\\)" + "A regular expression matching a CSS number.") + +(defconst css--percent-regexp "\\([0-9]+\\)%" + "A regular expression matching a CSS percentage.") + +(defconst css--number-or-percent-regexp + (concat "\\(?:" css--percent-regexp "\\)\\|\\(?:" css--number-regexp "\\)") + "A regular expression matching a CSS number or a CSS percentage.") + +(defconst css--angle-regexp + (concat css--number-regexp + (regexp-opt '("deg" "grad" "rad" "turn") t) + "?") + "A regular expression matching a CSS angle.") + +(defun css--color-skip-blanks () + "Skip blanks and comments." + (while (forward-comment 1))) + +(cl-defun css--rgb-color () + "Parse a CSS rgb() or rgba() color. +Point should be just after the open paren. +Returns a hex RGB color, or nil if the color could not be recognized. +This recognizes CSS-color-4 extensions." + (let ((result '()) + (iter 0)) + (while (< iter 4) + (css--color-skip-blanks) + (unless (looking-at css--number-or-percent-regexp) + (cl-return-from css--css-4-rgb nil)) + (let* ((is-percent (match-beginning 1)) + (str (match-string (if is-percent 1 2))) + (number (string-to-number str))) + (when is-percent + (setq number (* 255 (/ number 100.0)))) + ;; Don't push the alpha. + (when (< iter 3) + (push (min (max 0 (truncate number)) 255) result)) + (goto-char (match-end 0)) + (css--color-skip-blanks) + (cl-incf iter) + ;; Accept a superset of the CSS syntax since I'm feeling lazy. + (when (and (= (skip-chars-forward ",/") 0) + (= iter 3)) + ;; The alpha is optional. + (cl-incf iter)) + (css--color-skip-blanks))) + (when (looking-at ")") + (forward-char) + (apply #'format "#%02x%02x%02x" (nreverse result))))) + +(cl-defun css--hsl-color () + "Parse a CSS hsl() or hsla() color. +Point should be just after the open paren. +Returns a hex RGB color, or nil if the color could not be recognized. +This recognizes CSS-color-4 extensions." + (let ((result '())) + ;; First parse the hue. + (css--color-skip-blanks) + (unless (looking-at css--angle-regexp) + (cl-return-from css--hsl-color nil)) + (let ((hue (string-to-number (match-string 1))) + (unit (match-string 2))) + (goto-char (match-end 0)) + ;; Note that here "turn" is just passed through. + (cond + ((or (not unit) (equal unit "deg")) + ;; Degrees. + (setq hue (/ hue 360.0))) + ((equal unit "grad") + (setq hue (/ hue 400.0))) + ((equal unit "rad") + (setq hue (/ hue (* 2 float-pi))))) + (push (mod hue 1.0) result)) + (dotimes (_ 2) + (skip-chars-forward ",") + (css--color-skip-blanks) + (unless (looking-at css--percent-regexp) + (cl-return-from css--hsl-color nil)) + (let ((number (string-to-number (match-string 1)))) + (setq number (/ number 100.0)) + (push (min (max number 0.0) 1.0) result) + (goto-char (match-end 0)) + (css--color-skip-blanks))) + (css--color-skip-blanks) + ;; Accept a superset of the CSS syntax since I'm feeling lazy. + (when (> (skip-chars-forward ",/") 0) + (css--color-skip-blanks) + (unless (looking-at css--number-or-percent-regexp) + (cl-return-from css--hsl-color nil)) + (goto-char (match-end 0)) + (css--color-skip-blanks)) + (when (looking-at ")") + (forward-char) + (apply #'color-rgb-to-hex + (apply #'color-hsl-to-rgb (nreverse result)))))) + +(defconst css--colors-regexp + (concat + ;; Named colors. + (regexp-opt (mapcar #'car css--color-map) t) + "\\|" + ;; Short hex. css-color-4 adds alpha. + "\\(#[0-9a-fA-F]\\{3,4\\}\\b\\)" + "\\|" + ;; Long hex. css-color-4 adds alpha. + "\\(#\\(?:[0-9a-fA-F][0-9a-fA-F]\\)\\{3,4\\}\\b\\)" + "\\|" + ;; RGB. + "\\(rgba?(\\)" + "\\|" + ;; HSL. + "\\(hsla?(\\)") + "A regular expression that matches the start of a CSS color.") + +(defun css--hex-color (str) + "Convert a CSS hex color to an Emacs hex color. +STR is the incoming CSS hex color. +This function simply drops any transparency." + ;; Either #RGB or #RRGGBB, drop the "A" or "AA". + (if (> (length str) 4) + (substring str 0 7) + (substring str 0 4))) + +(defun css--compute-color () + "Return the CSS color at point. +Point should be just after the start of a CSS color, as recognized +by `css--colors-regexp'. This function will either return the color, +as a hex RGB string; or `nil' if no color could be recognized. When +this function returns, point will be at the end of the recognized +color." + (let ((match (downcase (match-string 0)))) + (cond + ((eq (aref match 0) ?#) + (css--hex-color match)) + ((member match '("rgb(" "rgba(")) + (css--rgb-color)) + ((member match '("hsl(" "hsla(")) + (css--hsl-color)) + ;; Evaluate to the color if the name is found. + ((cdr (assoc match css--color-map))) + (t + (error "invalid case in css--compute-color"))))) + +(defun css--contrasty-color (name) + "Return a color that contrasts with NAME. +NAME is of any form accepted by `color-name-to-rgb'. +The returned color will be usable by Emacs and will contrast +with NAME; in particular so that if NAME is used as a background +color, the returned color can be used as the foreground and still +be readable." + (let* ((color (color-name-to-rgb name)) + (red (car color)) + (green (cadr color)) + (blue (cl-caddr color)) + (luma (+ (* 0.299 red) (* 0.587 green) (* 0.114 blue)))) + (if (> luma 0.5) + "black" + "white"))) + +(defun css--fontify-colors (start end) + "Fontify CSS colors between START and END. +START and END are buffer positions. +This function is used via `jit-lock-register'." + (message "FONTIFY %S %S" start end) + (save-excursion + (let ((case-fold-search t)) + (goto-char start) + (while (re-search-forward css--colors-regexp end t) + ;; Skip comments and strings. + (unless (nth 8 (syntax-ppss)) + (let ((start (match-beginning 0)) + (color (css--compute-color))) + (when color + (with-silent-modifications + ;; Use the color as the background, to make it more + ;; clear. Use a contrasting color as the foreground, + ;; to make it readable. Finally, have a small box + ;; using the existing foreground color, to make sure + ;; it stands out a bit from any other text; in + ;; particular this is nice when the color matches the + ;; buffer's background color. + (add-text-properties + start (point) + (list 'face (list :background color + :foreground (css--contrasty-color color) + :box '(:line-width -1)))))))))))) + (defcustom css-indent-offset 4 "Basic size of one indentation step." :version "22.2" @@ -945,6 +1258,7 @@ css-mode :backward-token #'css-smie--backward-token) (setq-local electric-indent-chars (append css-electric-keys electric-indent-chars)) + (jit-lock-register #'css--fontify-colors) (add-hook 'completion-at-point-functions #'css-completion-at-point nil 'local)) diff --git a/test/lisp/textmodes/css-mode-tests.el b/test/lisp/textmodes/css-mode-tests.el index 6eb32ea..f058bcf 100644 --- a/test/lisp/textmodes/css-mode-tests.el +++ b/test/lisp/textmodes/css-mode-tests.el @@ -58,7 +58,7 @@ ;; Check that the `color' property doesn't cause infinite recursion ;; because it refers to the value class of the same name. - (should (= (length (css--property-values "color")) 147))) + (should (= (length (css--property-values "color")) 152))) (ert-deftest css-test-property-value-cache () "Test that `css--property-value-cache' is in use." @@ -218,5 +218,40 @@ css-mode-tests--completions (should (member "body" completions)) (should-not (member "article" completions))))) +(ert-deftest css-test-rgb-parser () + (with-temp-buffer + (css-mode) + (dolist (input '("255, 0, 127" + "255, /* comment */ 0, 127" + "255 0 127" + "255, 0, 127, 0.75" + "255 0 127 / 0.75" + "100%, 0%, 50%" + "100%, 0%, 50%, 0.115" + "100% 0% 50%" + "100% 0% 50% / 0.115")) + (erase-buffer) + (save-excursion + (insert input ")")) + (should (equal (css--rgb-color) "#ff007f"))))) + +(ert-deftest css-test-hsl-parser () + (with-temp-buffer + (css-mode) + (dolist (input '("0, 100%, 50%" + "0 100% 50%" + "0 /* two */ /* comments */100% 50%" + "0, 100%, 50%, 0.75" + "0 100% 50% / 0.75" + "0deg 100% 50%" + "360deg 100% 50%" + "0rad, 100%, 50%, 0.115" + "0grad, 100%, 50%, 0.115" + "1turn 100% 50% / 0.115")) + (erase-buffer) + (save-excursion + (insert input ")")) + (should (equal (css--hsl-color) "#ff0000"))))) + (provide 'css-mode-tests) ;;; css-mode-tests.el ends here --=-=-= Content-Type: text/plain Tom In GNU Emacs 25.1.90.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.20.9) of 2016-12-20 built on bapiya Repository revision: 88cdf14b37a7344bb266e94512485e3cc738c23d Windowing system distributor 'Fedora Project', version 11.0.11901000 System Description: Fedora release 25 (Twenty Five) Configured using: 'configure --prefix=/home/tromey/Emacs/install/ --with-modules' Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 MODULES Important settings: value of $LANG: en_US.utf8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: VC dir Minor modes in effect: diff-auto-refine-mode: t which-function-mode: t erc-services-mode: t erc-list-mode: t erc-menu-mode: t erc-autojoin-mode: t erc-ring-mode: t erc-networks-mode: t erc-pcomplete-mode: t erc-track-mode: t erc-match-mode: t erc-netsplit-mode: t erc-hl-nicks-mode: t erc-button-mode: t erc-fill-mode: t erc-stamp-mode: t erc-irccontrols-mode: t erc-noncommands-mode: t erc-move-to-prompt-mode: t erc-readonly-mode: t savehist-mode: t tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t buffer-read-only: t column-number-mode: t line-number-mode: t transient-mark-mode: t Recent messages: Saving file /tmp/r.css... Wrote /tmp/r.css FONTIFY 30 530 FONTIFY 530 1030 Mark set [2 times] Saving file /home/tromey/Emacs/trunk/test/lisp/textmodes/css-mode-tests.el... Wrote /home/tromey/Emacs/trunk/test/lisp/textmodes/css-mode-tests.el When done with a buffer, type C-x # Hiding up-to-date and ignored items When done with a buffer, type C-x # Load-path shadows: /home/tromey/.emacs.d/elpa/erc-hl-nicks-1.3.2/erc-hl-nicks hides /home/tromey/.emacs.d/elpa/erc-hl-nicks-1.3.1/erc-hl-nicks /home/tromey/.emacs.d/elpa/erc-hl-nicks-1.3.2/erc-hl-nicks-autoloads hides /home/tromey/.emacs.d/elpa/erc-hl-nicks-1.3.1/erc-hl-nicks-autoloads /home/tromey/.emacs.d/elpa/erc-hl-nicks-1.3.2/erc-hl-nicks-pkg hides /home/tromey/.emacs.d/elpa/erc-hl-nicks-1.3.1/erc-hl-nicks-pkg /home/tromey/.emacs.d/elpa/bubbles-0.5/bubbles hides /home/tromey/Emacs/install/share/emacs/25.1.90/lisp/play/bubbles Features: (autoload cus-edit descr-text vc-annotate edebug xref project gnus-draft bug-reference view tcl web-mode lisp-mnt url-handlers log-view url-http url-gw url-auth eww url-queue gnus-html xml url-cache mm-url url url-proxy url-privacy url-expand url-methods url-history url-cookie url-domsuf smerge-mode shadow emacsbug log-edit pcvs-util whitespace idutils derived noutline outline find-dired bbdb-sc supercite regi css-mode smie js sgml-mode json map cc-mode cc-fonts cc-guess cc-menus cc-cmds apropos debug dabbrev eieio-opt speedbar sb-image ezimage dframe find-func copyright misearch multi-isearch add-log jka-compr bbdb-message vc-mtn vc-hg mailalias mail-hist nnir vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs vc-git diff-mode easy-mmode term/xterm xterm flow-fill shr-color url-util url-parse url-vars shr dom subr-x browse-url mm-archive sort smiley gnus-cite gnus-async gnus-bcklg mail-extr qp gnus-ml disp-table gnus-topic nndraft nnmh nnfolder utf-7 bbdb-gnus bbdb-mua bbdb-com crm network-stream nsm starttls gnus-agent gnus-srvr gnus-score score-mode nnvirtual gnus-msg nntp gnus-cache gnus-registry registry eieio-compat eieio-base gnus-art mm-uu mml2015 mm-view mml-smime smime dig mailcap gnus-sum gnus-group gnus-undo smtpmail sendmail gnus-start gnus-cloud nnimap nnmail mail-source tls gnutls utf7 netrc nnoo parse-time gnus-spec gnus-int gnus-range message idna dired rfc822 mml mml-sec epg mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev gmm-utils mailheader gnus-win gnus gnus-ems nnheader mail-utils flyspell ispell diminish edmacro kmacro projectile grep compile ibuf-ext ibuffer dash appt diary-lib diary-loaddefs cal-menu calendar cal-loaddefs which-func imenu minimap autorevert filenotify cus-start cus-load status erc-services erc-list erc-menu erc-join erc-ring erc-networks erc-pcomplete pcomplete erc-track erc-match erc-netsplit erc-hl-nicks color erc-button erc-fill erc-stamp wid-edit erc-goodies erc erc-backend erc-compat format-spec auth-source eieio gnus-util mm-util help-fns mail-prsvr password-cache thingatpt pp warnings advice vc-dir ewoc vc vc-dispatcher cc-styles cc-align cc-engine cc-vars cc-defs bbdb bbdb-site timezone ange-ftp comint ansi-color ring server savehist finder-inf dwarf-mode-autoloads gdb-shell-autoloads eieio-core lisppaste-autoloads pydoc-info-autoloads info-look cl-seq cl-macs cl weblogger-autoloads info package epg-config seq byte-opt gv bytecomp byte-compile cl-extra help-mode easymenu cconv cl-loaddefs pcase cl-lib bbdb-loaddefs time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote dbusbind inotify dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 1974680 547097) (symbols 48 127411 61) (miscs 40 27623 7735) (strings 32 525621 148753) (string-bytes 1 13196826) (vectors 16 107759) (vector-slots 8 2410562 185496) (floats 8 874 1587) (intervals 56 200301 17468) (buffers 976 180) (heap 1024 305851 47738)) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 25 10:51:52 2017 Received: (at 25525) by debbugs.gnu.org; 25 Jan 2017 15:51:52 +0000 Received: from localhost ([127.0.0.1]:42953 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWPrU-0000x1-9U for submit@debbugs.gnu.org; Wed, 25 Jan 2017 10:51:52 -0500 Received: from eggs.gnu.org ([208.118.235.92]:45038) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWPrS-0000wp-Ud for 25525@debbugs.gnu.org; Wed, 25 Jan 2017 10:51:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cWPrJ-0003TO-P6 for 25525@debbugs.gnu.org; Wed, 25 Jan 2017 10:51:45 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:33829) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWPrJ-0003TK-ML; Wed, 25 Jan 2017 10:51:41 -0500 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2863 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cWPrI-0006JQ-Nb; Wed, 25 Jan 2017 10:51:41 -0500 Date: Wed, 25 Jan 2017 17:51:23 +0200 Message-Id: <83inp32l50.fsf@gnu.org> From: Eli Zaretskii To: Tom Tromey In-reply-to: <87mvefh8br.fsf@tromey.com> (message from Tom Tromey on Wed, 25 Jan 2017 01:06:48 -0700) Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -8.2 (--------) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -8.2 (--------) > From: Tom Tromey > Date: Wed, 25 Jan 2017 01:06:48 -0700 > > This patch adds color highlighting to CSS mode. > > In particular, this provides a new jit-lock function that recognizes the > various forms of CSS color syntax, including some css-color-4 additions. > > When such a color is seen, the background color of the text is set to > the color itself. In order to remain readable, the foreground is set to > a contrasting color, and a box is put around the text (this helps > distinguish colors that are close to the buffer's background color). > > While doing this I noticed that css-mode was missing a few named colors > specified by CSS, in particular: > > ("darkgrey" "darkslategrey" "dimgrey" "grey" "lightgrey" > "lightslategrey" "slategrey") > > This patch fixes this problem as well. Thanks. I wonder whether it would make sense to reuse some existing data and code here? For example, tty-colors.el already has a (longer) list of colors with suitable RGB values, so perhaps we should simply add the few missing ones to that list, and then use that for CSS? As another example, tty-colors.el also includes code for parsing and converting color values (although perhaps not all of the formats you support in your code). As yet another example of existing functionality that you could perhaps reuse, there's the :distant-foreground attribute of a face that might help you with the issue of color contrast. If you already considered all those and decided not to use them, could you tell why? From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 25 11:52:47 2017 Received: (at 25525) by debbugs.gnu.org; 25 Jan 2017 16:52:47 +0000 Received: from localhost ([127.0.0.1]:43023 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWQoR-0007WL-Ea for submit@debbugs.gnu.org; Wed, 25 Jan 2017 11:52:47 -0500 Received: from eggs.gnu.org ([208.118.235.92]:36204) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWQoQ-0007W8-1T for 25525@debbugs.gnu.org; Wed, 25 Jan 2017 11:52:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cWQoK-0005ce-Af for 25525@debbugs.gnu.org; Wed, 25 Jan 2017 11:52:41 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:34649) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWQo3-0005Oq-Cn; Wed, 25 Jan 2017 11:52:23 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1cWQo3-000548-0h; Wed, 25 Jan 2017 11:52:23 -0500 From: Glenn Morris To: Tom Tromey Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> X-Spook: wire transfer Epidemic Abbas Smuggling sweep Geraldton X-Ran: {FC.$,ea!IacDB2*6([:sz"^ecc)D1|`"9yygU[8h,:t13T%Ygt71N.Fq\b+[)L`|aK1w1 X-Hue: brightred X-Debbugs-No-Ack: yes X-Attribution: GM Date: Wed, 25 Jan 2017 11:52:22 -0500 In-Reply-To: <87mvefh8br.fsf@tromey.com> (Tom Tromey's message of "Wed, 25 Jan 2017 01:06:48 -0700") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -8.2 (--------) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -8.2 (--------) Tom Tromey wrote: > +(require 'cl-lib) > +(require 'cl-macs) > +(require 'color) Don't explicitly load cl-macs. It's an internal part of cl-lib, and loading cl-lib is all you need. From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 25 12:25:45 2017 Received: (at 25525) by debbugs.gnu.org; 25 Jan 2017 17:25:45 +0000 Received: from localhost ([127.0.0.1]:43179 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWRKL-0003Ps-89 for submit@debbugs.gnu.org; Wed, 25 Jan 2017 12:25:45 -0500 Received: from gproxy1-pub.mail.unifiedlayer.com ([69.89.25.95]:49416) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWRKI-0003Pd-Rf for 25525@debbugs.gnu.org; Wed, 25 Jan 2017 12:25:43 -0500 Received: from cmgw2 (cmgw3 [10.0.90.83]) by gproxy1.mail.unifiedlayer.com (Postfix) with ESMTP id 8D8E617633D for <25525@debbugs.gnu.org>; Wed, 25 Jan 2017 10:25:30 -0700 (MST) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id chRQ1u00S2f2jeq01hRTM9; Wed, 25 Jan 2017 10:25:28 -0700 X-Authority-Analysis: v=2.1 cv=ZINExxLb 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=IgFoBzBjUZAA:10 a=mDV3o1hIAAAA:8 a=zmvBgvANYKEz0gEvOrwA:9 a=_FVE-zBwftR9WsbkzFJk: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=jZz9JfNy9y5+y81DricJ4G+PenuXfdW836X7RKG8tP8=; b=a9MixCkSrI9v6QXFvE45Ejc3C5 3AjMOGaEtY7wen8YhTmMCocDrGYmlbOzx/vDnN1ukECPel52FMmNco7JgOmdN+4lMb9crFSJAUVm8 8/uBHizCVO2DhK6AFTyiYftxJ; Received: from 174-16-146-181.hlrn.qwest.net ([174.16.146.181]:50494 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1cWRK1-0003gj-VD; Wed, 25 Jan 2017 10:25:26 -0700 From: Tom Tromey To: Eli Zaretskii Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <83inp32l50.fsf@gnu.org> X-Attribution: Tom Date: Wed, 25 Jan 2017 10:25:21 -0700 In-Reply-To: <83inp32l50.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 25 Jan 2017 17:51:23 +0200") Message-ID: <87inp3gigu.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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 - debbugs.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: 1cWRK1-0003gj-VD X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-146-181.hlrn.qwest.net (bapiya) [174.16.146.181]:50494 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Tom Tromey X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.1 (-) >>>>> "Eli" == Eli Zaretskii writes: Eli> For example, tty-colors.el already has a (longer) list of colors with Eli> suitable RGB values, so perhaps we should simply add the few missing Eli> ones to that list, and then use that for CSS? CSS specifies the named colors that are available -- so the list in tty-colors.el would not be correct. Eli> As another example, tty-colors.el also includes code for parsing and Eli> converting color values (although perhaps not all of the formats you Eli> support in your code). Here too the new code supports what CSS specifies. It's important to the CSS developer that the Emacs mode follow CSS as precisely as possible; using other formats supplied by tty-colors.el would result in code that is invalid CSS. I think the only area of overlap is the #RRGGBB hex syntax, but that is so trivial as not to need any sharing. Eli> As yet another example of existing functionality that you could Eli> perhaps reuse, there's the :distant-foreground attribute of a face Eli> that might help you with the issue of color contrast. It seemed simpler to always set the :foreground, but I can experiment with :distant-foreground instead. Tom From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 25 15:24:04 2017 Received: (at 25525) by debbugs.gnu.org; 25 Jan 2017 20:24:04 +0000 Received: from localhost ([127.0.0.1]:43535 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWU6u-0004Xi-LQ for submit@debbugs.gnu.org; Wed, 25 Jan 2017 15:24:04 -0500 Received: from mail-lf0-f42.google.com ([209.85.215.42]:34925) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWU6s-0004WF-NQ for 25525@debbugs.gnu.org; Wed, 25 Jan 2017 15:24:03 -0500 Received: by mail-lf0-f42.google.com with SMTP id n124so134871110lfd.2 for <25525@debbugs.gnu.org>; Wed, 25 Jan 2017 12:24:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:message-id:in-reply-to:references :mime-version; bh=Vx6zmlYWv7zfRYfIRcUVk7slcsKYGQfAYwyDUK6j/MY=; b=OCajDgEWcf7LGsP49TWS0/DYEuDYt0FLhun3cwpv3YqJCXQGj50BVOshZw29T64b3r dqICDHOp71Wn9jhzlaqFCpt9iihyptRXDl2dbb1VpqcHO/Il+sXpDELfLNtIQiJUckR0 /xbBLKrxs+qM3rzvEfYAUZR2TsnybUqDB7IpDaLkpBArdkqWEyRgDT/8mTghkAYvWEnd rJQhXZ2BDWbY0ngBGvHW3bfredSmRPPFkXrMjXjrAlFAnwLiAY5B3md60UE0HiTSIWEd aIMO0Zl5rvyeukTL715oh7UtAQx1xiYoU074N2GOc0NBp/6YEpQ3HWQCRnlJqqOSrlZl EeYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to :references:mime-version; bh=Vx6zmlYWv7zfRYfIRcUVk7slcsKYGQfAYwyDUK6j/MY=; b=CbcSKL4Egsdqu6yO2sCotwG4+YlaJbtiDv3PZdvCqJrLGAPnkbYSRO1mRm8R+3pcJ0 Y1PDjbCsgPVZ1YrW9yvdFheIT55D+X0EidlIx//9vbygSW4djpMgZHl5vNNLsgNVgubp ibnlSsJyQs2yIvcz8+acrBAFNcaiuBeCGYlTG8hpYhJDLk2ufyncsBMRWrWU9EGLjA9N qnfmM1uhkUuCk5zKpNdPCDXhGCXKNDZDQs8VQv+ym/4OzIw2td9U/JV7epM/V3Y6MoIg IwqrhGlIwpJiucmNiuKcX7asXMNq6Qegsvco8C3Mb9vgli8XzSeuLAjIuvqSLubtTezB CpTQ== X-Gm-Message-State: AIkVDXLLYKY1X/3PckSBaRJThm5jV93LBkBkUpYxX3uFnpF0OQPcIckAjeDprfsHpGsB5w== X-Received: by 10.46.71.203 with SMTP id u194mr15514407lja.7.1485375836259; Wed, 25 Jan 2017 12:23:56 -0800 (PST) Received: from [192.168.100.10] (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id u126sm8622489lja.25.2017.01.25.12.23.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Jan 2017 12:23:55 -0800 (PST) Date: Wed, 25 Jan 2017 21:23:53 +0100 From: Simen =?iso-8859-1?q?Heggest=F8yl?= Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode To: Tom Tromey Message-Id: <1485375833.1960.0@smtp.gmail.com> In-Reply-To: <87mvefh8br.fsf@tromey.com> References: <87mvefh8br.fsf@tromey.com> X-Mailer: geary/0.11.3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) Thanks Tom, this looks to be a very nice addition to CSS mode! Some comments: - It should be possible to disable it. I'm not sure whether it should be turned on by default or not, though I'd think that most CSS developers will find it useful. - Selectors that happen to contain the name of a color are highlighted. The 'red' part of '.centered-button' is highlighted in red, for instance. - The same goes for variable names in both CSS and SCSS. - Property names are also highlighted, for instance in the case of the 'white-space' property. - There's a stray call to 'message' in the beginning of 'css--fontify-colors'. - The error message in 'css--compute-color' should be capitalized. - I think it deserves a NEWS entry. -- Simen From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 25 15:56:24 2017 Received: (at 25525) by debbugs.gnu.org; 25 Jan 2017 20:56:24 +0000 Received: from localhost ([127.0.0.1]:43659 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWUcC-0000Ly-C4 for submit@debbugs.gnu.org; Wed, 25 Jan 2017 15:56:24 -0500 Received: from gproxy1-pub.mail.unifiedlayer.com ([69.89.25.95]:41610) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWUcA-0000Lj-9D for 25525@debbugs.gnu.org; Wed, 25 Jan 2017 15:56:22 -0500 Received: from cmgw2 (cmgw3 [10.0.90.83]) by gproxy1.mail.unifiedlayer.com (Postfix) with ESMTP id E22071767E3 for <25525@debbugs.gnu.org>; Wed, 25 Jan 2017 13:41:20 -0700 (MST) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id ckhF1u00F2f2jeq01khJDh; Wed, 25 Jan 2017 13:41:19 -0700 X-Authority-Analysis: v=2.1 cv=ZINExxLb 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=IgFoBzBjUZAA:10 a=VXIX01xvmqJy_gnJ_yMA:9 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=w86MoOBMCjR5b35wvVR8tPNMUk2cGp8l3lA/Yd1OwOs=; b=IY4PuqkGKOkxd1rYrH2zr5FEhZ 6UUMtRijoXQ2O8f4HRG4Hd4FPR15kz7s/aEUGuKP9rbIOGNCmLPRu0Upkug5h5BQDqC1sS3PDK4CZ lm4XJDhu5Irt5xf89yp3WJobB; Received: from 174-16-146-181.hlrn.qwest.net ([174.16.146.181]:54618 helo=pokyo) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1cWUNY-0002l9-Jc; Wed, 25 Jan 2017 13:41:16 -0700 From: Tom Tromey To: Simen =?utf-8?Q?Heggest=C3=B8yl?= Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> X-Attribution: Tom Date: Wed, 25 Jan 2017 13:41:14 -0700 In-Reply-To: <1485375833.1960.0@smtp.gmail.com> ("Simen \=\?utf-8\?Q\?Heggest\?\= \=\?utf-8\?Q\?\=C3\=B8yl\=22's\?\= message of "Wed, 25 Jan 2017 21:23:53 +0100") Message-ID: <87r33q50ut.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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 - debbugs.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: 1cWUNY-0002l9-Jc X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-146-181.hlrn.qwest.net (pokyo) [174.16.146.181]:54618 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Tom Tromey X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.1 (-) Simen> - It should be possible to disable it. I'm not sure whether it should Simen> be turned on by default or not, though I'd think that most CSS Simen> developers will find it useful. I can add a defcustom. Simen> - Selectors that happen to contain the name of a color are Simen> highlighted. The 'red' part of '.centered-button' is highlighted in Simen> red, for instance. Thanks for noticing this. I am sure I had \b or \< or something in the regexp earlier but I must have dropped it. I'll fix this up. Tom From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 25 18:25:12 2017 Received: (at 25525) by debbugs.gnu.org; 25 Jan 2017 23:25:12 +0000 Received: from localhost ([127.0.0.1]:43913 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWWwB-0005pR-Mz for submit@debbugs.gnu.org; Wed, 25 Jan 2017 18:25:12 -0500 Received: from gproxy8-pub.mail.unifiedlayer.com ([67.222.33.93]:53041) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1cWWw8-0005pB-LT for 25525@debbugs.gnu.org; Wed, 25 Jan 2017 18:25:09 -0500 Received: (qmail 15470 invoked by uid 0); 25 Jan 2017 23:24:59 -0000 Received: from unknown (HELO cmgw4) (10.0.90.85) by gproxy8.mail.unifiedlayer.com with SMTP; 25 Jan 2017 23:24:59 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw4 with id cnQw1u00K2f2jeq01nQzVZ; Wed, 25 Jan 2017 16:24:59 -0700 X-Authority-Analysis: v=2.1 cv=JsBi8qIC 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=IgFoBzBjUZAA:10 a=GS6DF_Jz6lyyzpd00P0A:9 a=5g-_PHD3eboA:10 a=zstS-IiYAAAA:8 a=uybrv1H5_MdHPfUpQ7IA:9 a=QsZDxd8OryoxSs9D:21 a=z3RKfP7VsHXL5GT0:21 a=4G6NA9xxw8l3yy4pmD5M: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=ta0x4OTFayHiV5rLY0QSPBHs8eV3ymrCe52dq2Vu54U=; b=hd+1CaPoJEv3W7xIhLqejtda7+ vaM1RavL7Ko5A9Y6IGAIMDP7ySQRZK8SU8Xo45XDoFYUArRVDBPupTUVfClhaZu250f79YIoROFev hLja2o7NYOXj6XnrKTRbhXuHy; Received: from 75-166-101-147.hlrn.qwest.net ([75.166.101.147]:34026 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1cWWvv-0003Mk-Ef; Wed, 25 Jan 2017 16:24:56 -0700 From: Tom Tromey To: Simen =?utf-8?Q?Heggest=C3=B8yl?= Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> X-Attribution: Tom Date: Wed, 25 Jan 2017 16:24:50 -0700 In-Reply-To: <1485375833.1960.0@smtp.gmail.com> ("Simen \=\?utf-8\?Q\?Heggest\?\= \=\?utf-8\?Q\?\=C3\=B8yl\=22's\?\= message of "Wed, 25 Jan 2017 21:23:53 +0100") Message-ID: <877f5ihge5.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.90 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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 - debbugs.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: 75.166.101.147 X-Exim-ID: 1cWWvv-0003Mk-Ef X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-101-147.hlrn.qwest.net (bapiya) [75.166.101.147]:34026 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Tom Tromey X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.1 (-) --=-=-= Content-Type: text/plain Simen> Thanks Tom, this looks to be a very nice addition to CSS mode! Simen> Some comments: [...] I think this version addresses all the review comments. This necessitated changing the syntax table a bit. Now things like "#red" appear as a symbol, but " Date: Wed Jan 25 00:53:49 2017 -0700 add color highlighting to css-mode * lisp/textmodes/css-mode.el (css--color-map): New constant. (css-value-class-alist): Use css--color-map. (css--number-regexp, css--percent-regexp) (css--number-or-percent-regexp, css--angle-regexp): New constants. (css--color-skip-blanks, css--rgb-color, css--hsl-color): New functions. (css--colors-regexp): New constant. (css--hex-color, css--compute-color, css--contrasty-color) (css--fontify-colors): New functions. (css-mode): Register css--fontify-colors with jit-lock. (css-mode-syntax-table): Set syntax on more characters. (css-fontify-colors): New defcustom. * test/lisp/textmodes/css-mode-tests.el (css-test-property-values): Update. (css-test-rgb-parser, css-test-hsl-parser): New tests. * etc/NEWS: Add entry. diff --git a/etc/NEWS b/etc/NEWS index ca66df6..73ef1de 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -603,6 +603,11 @@ HTML tags, classes and IDs using the 'completion-at-point' command. Completion candidates for HTML classes and IDs are retrieved from open HTML mode buffers. +--- +*** CSS colors are fontified using the color they represent as the +background. For instance, #ff0000 would be fontified with a red +background. + +++ ** Emacs now supports character name escape sequences in character and string literals. The syntax variants \N{character name} and diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index c81c3f6..0f6c996 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -32,6 +32,8 @@ ;;; Code: +(require 'cl-lib) +(require 'color) (require 'seq) (require 'sgml-mode) (require 'smie) @@ -453,8 +455,157 @@ css-property-ids (mapcar #'car css-property-alist) "Identifiers for properties.") +(defconst css--color-map + '(("black" . "#000000") + ("silver" . "#c0c0c0") + ("gray" . "#808080") + ("white" . "#ffffff") + ("maroon" . "#800000") + ("red" . "#ff0000") + ("purple" . "#800080") + ("fuchsia" . "#ff00ff") + ("green" . "#008000") + ("lime" . "#00ff00") + ("olive" . "#808000") + ("yellow" . "#ffff00") + ("navy" . "#000080") + ("blue" . "#0000ff") + ("teal" . "#008080") + ("aqua" . "#00ffff") + ("orange" . "#ffa500") + ("aliceblue" . "#f0f8ff") + ("antiquewhite" . "#faebd7") + ("aquamarine" . "#7fffd4") + ("azure" . "#f0ffff") + ("beige" . "#f5f5dc") + ("bisque" . "#ffe4c4") + ("blanchedalmond" . "#ffebcd") + ("blueviolet" . "#8a2be2") + ("brown" . "#a52a2a") + ("burlywood" . "#deb887") + ("cadetblue" . "#5f9ea0") + ("chartreuse" . "#7fff00") + ("chocolate" . "#d2691e") + ("coral" . "#ff7f50") + ("cornflowerblue" . "#6495ed") + ("cornsilk" . "#fff8dc") + ("crimson" . "#dc143c") + ("darkblue" . "#00008b") + ("darkcyan" . "#008b8b") + ("darkgoldenrod" . "#b8860b") + ("darkgray" . "#a9a9a9") + ("darkgreen" . "#006400") + ("darkgrey" . "#a9a9a9") + ("darkkhaki" . "#bdb76b") + ("darkmagenta" . "#8b008b") + ("darkolivegreen" . "#556b2f") + ("darkorange" . "#ff8c00") + ("darkorchid" . "#9932cc") + ("darkred" . "#8b0000") + ("darksalmon" . "#e9967a") + ("darkseagreen" . "#8fbc8f") + ("darkslateblue" . "#483d8b") + ("darkslategray" . "#2f4f4f") + ("darkslategrey" . "#2f4f4f") + ("darkturquoise" . "#00ced1") + ("darkviolet" . "#9400d3") + ("deeppink" . "#ff1493") + ("deepskyblue" . "#00bfff") + ("dimgray" . "#696969") + ("dimgrey" . "#696969") + ("dodgerblue" . "#1e90ff") + ("firebrick" . "#b22222") + ("floralwhite" . "#fffaf0") + ("forestgreen" . "#228b22") + ("gainsboro" . "#dcdcdc") + ("ghostwhite" . "#f8f8ff") + ("gold" . "#ffd700") + ("goldenrod" . "#daa520") + ("greenyellow" . "#adff2f") + ("grey" . "#808080") + ("honeydew" . "#f0fff0") + ("hotpink" . "#ff69b4") + ("indianred" . "#cd5c5c") + ("indigo" . "#4b0082") + ("ivory" . "#fffff0") + ("khaki" . "#f0e68c") + ("lavender" . "#e6e6fa") + ("lavenderblush" . "#fff0f5") + ("lawngreen" . "#7cfc00") + ("lemonchiffon" . "#fffacd") + ("lightblue" . "#add8e6") + ("lightcoral" . "#f08080") + ("lightcyan" . "#e0ffff") + ("lightgoldenrodyellow" . "#fafad2") + ("lightgray" . "#d3d3d3") + ("lightgreen" . "#90ee90") + ("lightgrey" . "#d3d3d3") + ("lightpink" . "#ffb6c1") + ("lightsalmon" . "#ffa07a") + ("lightseagreen" . "#20b2aa") + ("lightskyblue" . "#87cefa") + ("lightslategray" . "#778899") + ("lightslategrey" . "#778899") + ("lightsteelblue" . "#b0c4de") + ("lightyellow" . "#ffffe0") + ("limegreen" . "#32cd32") + ("linen" . "#faf0e6") + ("mediumaquamarine" . "#66cdaa") + ("mediumblue" . "#0000cd") + ("mediumorchid" . "#ba55d3") + ("mediumpurple" . "#9370db") + ("mediumseagreen" . "#3cb371") + ("mediumslateblue" . "#7b68ee") + ("mediumspringgreen" . "#00fa9a") + ("mediumturquoise" . "#48d1cc") + ("mediumvioletred" . "#c71585") + ("midnightblue" . "#191970") + ("mintcream" . "#f5fffa") + ("mistyrose" . "#ffe4e1") + ("moccasin" . "#ffe4b5") + ("navajowhite" . "#ffdead") + ("oldlace" . "#fdf5e6") + ("olivedrab" . "#6b8e23") + ("orangered" . "#ff4500") + ("orchid" . "#da70d6") + ("palegoldenrod" . "#eee8aa") + ("palegreen" . "#98fb98") + ("paleturquoise" . "#afeeee") + ("palevioletred" . "#db7093") + ("papayawhip" . "#ffefd5") + ("peachpuff" . "#ffdab9") + ("peru" . "#cd853f") + ("pink" . "#ffc0cb") + ("plum" . "#dda0dd") + ("powderblue" . "#b0e0e6") + ("rosybrown" . "#bc8f8f") + ("royalblue" . "#4169e1") + ("saddlebrown" . "#8b4513") + ("salmon" . "#fa8072") + ("sandybrown" . "#f4a460") + ("seagreen" . "#2e8b57") + ("seashell" . "#fff5ee") + ("sienna" . "#a0522d") + ("skyblue" . "#87ceeb") + ("slateblue" . "#6a5acd") + ("slategray" . "#708090") + ("slategrey" . "#708090") + ("snow" . "#fffafa") + ("springgreen" . "#00ff7f") + ("steelblue" . "#4682b4") + ("tan" . "#d2b48c") + ("thistle" . "#d8bfd8") + ("tomato" . "#ff6347") + ("turquoise" . "#40e0d0") + ("violet" . "#ee82ee") + ("wheat" . "#f5deb3") + ("whitesmoke" . "#f5f5f5") + ("yellowgreen" . "#9acd32") + ("rebeccapurple" . "#663399")) + "Map CSS named color to their hex RGB value.") + (defconst css-value-class-alist - '((absolute-size + `((absolute-size "xx-small" "x-small" "small" "medium" "large" "x-large" "xx-large") (alphavalue number) @@ -506,36 +657,7 @@ css-value-class-alist (line-width length "thin" "medium" "thick") (linear-gradient "linear-gradient()") (margin-width "auto" length percentage) - (named-color - "aliceblue" "antiquewhite" "aqua" "aquamarine" "azure" "beige" - "bisque" "black" "blanchedalmond" "blue" "blueviolet" "brown" - "burlywood" "cadetblue" "chartreuse" "chocolate" "coral" - "cornflowerblue" "cornsilk" "crimson" "cyan" "darkblue" - "darkcyan" "darkgoldenrod" "darkgray" "darkgreen" "darkkhaki" - "darkmagenta" "darkolivegreen" "darkorange" "darkorchid" - "darkred" "darksalmon" "darkseagreen" "darkslateblue" - "darkslategray" "darkturquoise" "darkviolet" "deeppink" - "deepskyblue" "dimgray" "dodgerblue" "firebrick" "floralwhite" - "forestgreen" "fuchsia" "gainsboro" "ghostwhite" "gold" - "goldenrod" "gray" "green" "greenyellow" "honeydew" "hotpink" - "indianred" "indigo" "ivory" "khaki" "lavender" "lavenderblush" - "lawngreen" "lemonchiffon" "lightblue" "lightcoral" "lightcyan" - "lightgoldenrodyellow" "lightgray" "lightgreen" "lightpink" - "lightsalmon" "lightseagreen" "lightskyblue" "lightslategray" - "lightsteelblue" "lightyellow" "lime" "limegreen" "linen" - "magenta" "maroon" "mediumaquamarine" "mediumblue" "mediumorchid" - "mediumpurple" "mediumseagreen" "mediumslateblue" - "mediumspringgreen" "mediumturquoise" "mediumvioletred" - "midnightblue" "mintcream" "mistyrose" "moccasin" "navajowhite" - "navy" "oldlace" "olive" "olivedrab" "orange" "orangered" - "orchid" "palegoldenrod" "palegreen" "paleturquoise" - "palevioletred" "papayawhip" "peachpuff" "peru" "pink" "plum" - "powderblue" "purple" "rebeccapurple" "red" "rosybrown" - "royalblue" "saddlebrown" "salmon" "sandybrown" "seagreen" - "seashell" "sienna" "silver" "skyblue" "slateblue" "slategray" - "snow" "springgreen" "steelblue" "tan" "teal" "thistle" "tomato" - "turquoise" "violet" "wheat" "white" "whitesmoke" "yellow" - "yellowgreen") + (named-color . ,(mapcar #'car css--color-map)) (number "calc()") (numeric-figure-values "lining-nums" "oldstyle-nums") (numeric-fraction-values "diagonal-fractions" "stacked-fractions") @@ -614,11 +736,23 @@ css-mode-syntax-table (modify-syntax-entry ?\[ "(]" st) (modify-syntax-entry ?\] ")[" st) ;; Special chars that sometimes come at the beginning of words. - (modify-syntax-entry ?@ "'" st) - ;; (modify-syntax-entry ?: "'" st) - (modify-syntax-entry ?# "'" st) + ;; We'll treat them as symbol constituents. + (modify-syntax-entry ?@ "_" st) + (modify-syntax-entry ?# "_" st) + (modify-syntax-entry ?. "_" st) ;; Distinction between words and symbols. (modify-syntax-entry ?- "_" st) + + (modify-syntax-entry ?! "." st) + (modify-syntax-entry ?$ "." st) + (modify-syntax-entry ?% "." st) + (modify-syntax-entry ?& "." st) + (modify-syntax-entry ?+ "." st) + (modify-syntax-entry ?, "." st) + (modify-syntax-entry ?< "." st) + (modify-syntax-entry ?> "." st) + (modify-syntax-entry ?= "." st) + (modify-syntax-entry ?? "." st) st)) (eval-and-compile @@ -726,6 +860,206 @@ css-font-lock-keywords (defvar css-font-lock-defaults '(css-font-lock-keywords nil t)) +(defconst css--number-regexp + "\\(\\(?:[0-9]*\\.[0-9]+\\(?:[eE][0-9]+\\)?\\)\\|[0-9]+\\)" + "A regular expression matching a CSS number.") + +(defconst css--percent-regexp "\\([0-9]+\\)%" + "A regular expression matching a CSS percentage.") + +(defconst css--number-or-percent-regexp + (concat "\\(?:" css--percent-regexp "\\)\\|\\(?:" css--number-regexp "\\)") + "A regular expression matching a CSS number or a CSS percentage.") + +(defconst css--angle-regexp + (concat css--number-regexp + (regexp-opt '("deg" "grad" "rad" "turn") t) + "?") + "A regular expression matching a CSS angle.") + +(defun css--color-skip-blanks () + "Skip blanks and comments." + (while (forward-comment 1))) + +(cl-defun css--rgb-color () + "Parse a CSS rgb() or rgba() color. +Point should be just after the open paren. +Returns a hex RGB color, or nil if the color could not be recognized. +This recognizes CSS-color-4 extensions." + (let ((result '()) + (iter 0)) + (while (< iter 4) + (css--color-skip-blanks) + (unless (looking-at css--number-or-percent-regexp) + (cl-return-from css--css-4-rgb nil)) + (let* ((is-percent (match-beginning 1)) + (str (match-string (if is-percent 1 2))) + (number (string-to-number str))) + (when is-percent + (setq number (* 255 (/ number 100.0)))) + ;; Don't push the alpha. + (when (< iter 3) + (push (min (max 0 (truncate number)) 255) result)) + (goto-char (match-end 0)) + (css--color-skip-blanks) + (cl-incf iter) + ;; Accept a superset of the CSS syntax since I'm feeling lazy. + (when (and (= (skip-chars-forward ",/") 0) + (= iter 3)) + ;; The alpha is optional. + (cl-incf iter)) + (css--color-skip-blanks))) + (when (looking-at ")") + (forward-char) + (apply #'format "#%02x%02x%02x" (nreverse result))))) + +(cl-defun css--hsl-color () + "Parse a CSS hsl() or hsla() color. +Point should be just after the open paren. +Returns a hex RGB color, or nil if the color could not be recognized. +This recognizes CSS-color-4 extensions." + (let ((result '())) + ;; First parse the hue. + (css--color-skip-blanks) + (unless (looking-at css--angle-regexp) + (cl-return-from css--hsl-color nil)) + (let ((hue (string-to-number (match-string 1))) + (unit (match-string 2))) + (goto-char (match-end 0)) + ;; Note that here "turn" is just passed through. + (cond + ((or (not unit) (equal unit "deg")) + ;; Degrees. + (setq hue (/ hue 360.0))) + ((equal unit "grad") + (setq hue (/ hue 400.0))) + ((equal unit "rad") + (setq hue (/ hue (* 2 float-pi))))) + (push (mod hue 1.0) result)) + (dotimes (_ 2) + (skip-chars-forward ",") + (css--color-skip-blanks) + (unless (looking-at css--percent-regexp) + (cl-return-from css--hsl-color nil)) + (let ((number (string-to-number (match-string 1)))) + (setq number (/ number 100.0)) + (push (min (max number 0.0) 1.0) result) + (goto-char (match-end 0)) + (css--color-skip-blanks))) + (css--color-skip-blanks) + ;; Accept a superset of the CSS syntax since I'm feeling lazy. + (when (> (skip-chars-forward ",/") 0) + (css--color-skip-blanks) + (unless (looking-at css--number-or-percent-regexp) + (cl-return-from css--hsl-color nil)) + (goto-char (match-end 0)) + (css--color-skip-blanks)) + (when (looking-at ")") + (forward-char) + (apply #'color-rgb-to-hex + (apply #'color-hsl-to-rgb (nreverse result)))))) + +(defconst css--colors-regexp + (concat + ;; Named colors. + (regexp-opt (mapcar #'car css--color-map) 'symbols) + "\\|" + ;; Short hex. css-color-4 adds alpha. + "\\(#[0-9a-fA-F]\\{3,4\\}\\b\\)" + "\\|" + ;; Long hex. css-color-4 adds alpha. + "\\(#\\(?:[0-9a-fA-F][0-9a-fA-F]\\)\\{3,4\\}\\b\\)" + "\\|" + ;; RGB. + "\\(\\_ (length str) 4) + (substring str 0 7) + (substring str 0 4))) + +(defun css--compute-color () + "Return the CSS color at point. +Point should be just after the start of a CSS color, as recognized +by `css--colors-regexp'. This function will either return the color, +as a hex RGB string; or `nil' if no color could be recognized. When +this function returns, point will be at the end of the recognized +color." + (let ((match (downcase (match-string 0)))) + (cond + ((eq (aref match 0) ?#) + (css--hex-color match)) + ((member match '("rgb(" "rgba(")) + (css--rgb-color)) + ((member match '("hsl(" "hsla(")) + (css--hsl-color)) + ;; Evaluate to the color if the name is found. + ((cdr (assoc match css--color-map))) + (t + (error "Invalid case in css--compute-color"))))) + +(defun css--contrasty-color (name) + "Return a color that contrasts with NAME. +NAME is of any form accepted by `color-name-to-rgb'. +The returned color will be usable by Emacs and will contrast +with NAME; in particular so that if NAME is used as a background +color, the returned color can be used as the foreground and still +be readable." + (let* ((color (color-name-to-rgb name)) + (red (car color)) + (green (cadr color)) + (blue (cl-caddr color)) + (luma (+ (* 0.299 red) (* 0.587 green) (* 0.114 blue)))) + (if (> luma 0.5) + "black" + "white"))) + +(defcustom css-fontify-colors t + "Whether CSS colors should be fontified using the color as the background. +When non-`nil', a text representing CSS color will be fontified +such that its background is the color itself. E.g., #ff0000 will +be fontified with a red background." + :version "26.1" + :group 'css + :type 'boolean + :safe 'booleanp) + +(defun css--fontify-colors (start end) + "Fontify CSS colors between START and END. +START and END are buffer positions. +This function is used via `jit-lock-register'." + (when css-fontify-colors + (save-excursion + (let ((case-fold-search t)) + (goto-char start) + (while (re-search-forward css--colors-regexp end t) + ;; Skip comments and strings. + (unless (nth 8 (syntax-ppss)) + (let ((start (match-beginning 0)) + (color (css--compute-color))) + (when color + (with-silent-modifications + ;; Use the color as the background, to make it more + ;; clear. Use a contrasting color as the foreground, + ;; to make it readable. Finally, have a small box + ;; using the existing foreground color, to make sure + ;; it stands out a bit from any other text; in + ;; particular this is nice when the color matches the + ;; buffer's background color. + (add-text-properties + start (point) + (list 'face (list :background color + :foreground (css--contrasty-color color) + :box '(:line-width -1))))))))))))) + (defcustom css-indent-offset 4 "Basic size of one indentation step." :version "22.2" @@ -945,6 +1279,7 @@ css-mode :backward-token #'css-smie--backward-token) (setq-local electric-indent-chars (append css-electric-keys electric-indent-chars)) + (jit-lock-register #'css--fontify-colors) (add-hook 'completion-at-point-functions #'css-completion-at-point nil 'local)) diff --git a/test/lisp/textmodes/css-mode-tests.el b/test/lisp/textmodes/css-mode-tests.el index 6eb32ea..f058bcf 100644 --- a/test/lisp/textmodes/css-mode-tests.el +++ b/test/lisp/textmodes/css-mode-tests.el @@ -58,7 +58,7 @@ ;; Check that the `color' property doesn't cause infinite recursion ;; because it refers to the value class of the same name. - (should (= (length (css--property-values "color")) 147))) + (should (= (length (css--property-values "color")) 152))) (ert-deftest css-test-property-value-cache () "Test that `css--property-value-cache' is in use." @@ -218,5 +218,40 @@ css-mode-tests--completions (should (member "body" completions)) (should-not (member "article" completions))))) +(ert-deftest css-test-rgb-parser () + (with-temp-buffer + (css-mode) + (dolist (input '("255, 0, 127" + "255, /* comment */ 0, 127" + "255 0 127" + "255, 0, 127, 0.75" + "255 0 127 / 0.75" + "100%, 0%, 50%" + "100%, 0%, 50%, 0.115" + "100% 0% 50%" + "100% 0% 50% / 0.115")) + (erase-buffer) + (save-excursion + (insert input ")")) + (should (equal (css--rgb-color) "#ff007f"))))) + +(ert-deftest css-test-hsl-parser () + (with-temp-buffer + (css-mode) + (dolist (input '("0, 100%, 50%" + "0 100% 50%" + "0 /* two */ /* comments */100% 50%" + "0, 100%, 50%, 0.75" + "0 100% 50% / 0.75" + "0deg 100% 50%" + "360deg 100% 50%" + "0rad, 100%, 50%, 0.115" + "0grad, 100%, 50%, 0.115" + "1turn 100% 50% / 0.115")) + (erase-buffer) + (save-excursion + (insert input ")")) + (should (equal (css--hsl-color) "#ff0000"))))) + (provide 'css-mode-tests) ;;; css-mode-tests.el ends here --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 25 18:34:22 2017 Received: (at 25525) by debbugs.gnu.org; 25 Jan 2017 23:34:22 +0000 Received: from localhost ([127.0.0.1]:43926 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWX54-00064i-MI for submit@debbugs.gnu.org; Wed, 25 Jan 2017 18:34:22 -0500 Received: from gproxy8-pub.mail.unifiedlayer.com ([67.222.33.93]:45224) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1cWX52-00064U-AZ for 25525@debbugs.gnu.org; Wed, 25 Jan 2017 18:34:20 -0500 Received: (qmail 27013 invoked by uid 0); 25 Jan 2017 23:34:09 -0000 Received: from unknown (HELO CMOut01) (10.0.90.82) by gproxy8.mail.unifiedlayer.com with SMTP; 25 Jan 2017 23:34:09 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id cna31u00f2f2jeq01na6FJ; Wed, 25 Jan 2017 16:34:07 -0700 X-Authority-Analysis: v=2.1 cv=H75InYoi 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=IgFoBzBjUZAA:10 a=zstS-IiYAAAA:8 a=-5DiPzokYJN1ZtRZJ8sA:9 a=4G6NA9xxw8l3yy4pmD5M: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=OcLUZS1pY5zAhCkm7rgsuCpTZZMdh+1ggfg9Yq7UUbg=; b=xCKkPytN5Tf7B9zCNVn9x1lv7C AgR7ScF2Wy8+UdHOAr+7jL6oZzKFYnNx4yS4sIY7MSDGWcWApsQZHCexV27dpF1a7KUHqb50UO7Uo 8KF1PqZ6b+R/kUKtF8w+AR6Zs; Received: from 75-166-101-147.hlrn.qwest.net ([75.166.101.147]:34040 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1cWX4m-0006Xl-Fw; Wed, 25 Jan 2017 16:34:04 -0700 From: Tom Tromey To: Tom Tromey Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <83inp32l50.fsf@gnu.org> <87inp3gigu.fsf@tromey.com> X-Attribution: Tom Date: Wed, 25 Jan 2017 16:34:00 -0700 In-Reply-To: <87inp3gigu.fsf@tromey.com> (Tom Tromey's message of "Wed, 25 Jan 2017 10:25:21 -0700") Message-ID: <8737g6hfyv.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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 - debbugs.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: 75.166.101.147 X-Exim-ID: 1cWX4m-0006Xl-Fw X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-101-147.hlrn.qwest.net (bapiya) [75.166.101.147]:34040 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.1 (-) >>>>> "Tom" == Tom Tromey writes: Tom> It seemed simpler to always set the :foreground, but I can experiment Tom> with :distant-foreground instead. I gave this a try. I think the code in this patch works better than :distant-foreground. One case where it is better is the CSS color "purple", aka #800080. In my theme the foreground color is black. My patch picks white as the foreground, but the Emacs chooses not to use a distant-foreground, but rather keep a black foreground. You can compare these two cases by evalling: (progn (insert (propertize "hello\n" 'font-lock-face '(:background "#800080" :foreground "black" :distant-foreground "white"))) (insert (propertize "hello\n" 'font-lock-face '(:background "#800080" :foreground "white")))) I find the latter much more readable. Tom From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 26 11:05:37 2017 Received: (at 25525) by debbugs.gnu.org; 26 Jan 2017 16:05:37 +0000 Received: from localhost ([127.0.0.1]:45726 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWmYL-0007SB-0Z for submit@debbugs.gnu.org; Thu, 26 Jan 2017 11:05:37 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55270) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWmYJ-0007Ry-Rk for 25525@debbugs.gnu.org; Thu, 26 Jan 2017 11:05:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cWmYA-0007Kv-0G for 25525@debbugs.gnu.org; Thu, 26 Jan 2017 11:05:30 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:49670) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWmY9-0007Kr-Tu; Thu, 26 Jan 2017 11:05:25 -0500 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3595 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cWmY9-00055V-01; Thu, 26 Jan 2017 11:05:25 -0500 Date: Thu, 26 Jan 2017 18:05:08 +0200 Message-Id: <83d1f93iyz.fsf@gnu.org> From: Eli Zaretskii To: Tom Tromey In-reply-to: <8737g6hfyv.fsf@tromey.com> (message from Tom Tromey on Wed, 25 Jan 2017 16:34:00 -0700) Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <83inp32l50.fsf@gnu.org> <87inp3gigu.fsf@tromey.com> <8737g6hfyv.fsf@tromey.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -8.2 (--------) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -8.2 (--------) > From: Tom Tromey > Cc: Eli Zaretskii , 25525@debbugs.gnu.org > Date: Wed, 25 Jan 2017 16:34:00 -0700 > > >>>>> "Tom" == Tom Tromey writes: > > Tom> It seemed simpler to always set the :foreground, but I can experiment > Tom> with :distant-foreground instead. > > I gave this a try. I think the code in this patch works better than > :distant-foreground. > > One case where it is better is the CSS color "purple", aka #800080. > > In my theme the foreground color is black. My patch picks white as the > foreground, but the Emacs chooses not to use a distant-foreground, but > rather keep a black foreground. > > You can compare these two cases by evalling: > > (progn > (insert (propertize > "hello\n" > 'font-lock-face '(:background "#800080" :foreground "black" > :distant-foreground "white"))) > (insert (propertize > "hello\n" > 'font-lock-face '(:background "#800080" :foreground "white")))) > > I find the latter much more readable. If all you need is to choose either black or white as the foreground color, then :distant-foreground is indeed not for you. Still, I'd suggest to use color-distance rather than to invent a new metric. Or maybe just always use the color that is complementary to the background color, as black and white seem arbitrary to me. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 26 12:14:29 2017 Received: (at 25525) by debbugs.gnu.org; 26 Jan 2017 17:14:29 +0000 Received: from localhost ([127.0.0.1]:45797 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWncz-0002Mk-KR for submit@debbugs.gnu.org; Thu, 26 Jan 2017 12:14:29 -0500 Received: from gproxy8-pub.mail.unifiedlayer.com ([67.222.33.93]:43908) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1cWncx-0002MX-BS for 25525@debbugs.gnu.org; Thu, 26 Jan 2017 12:14:28 -0500 Received: (qmail 14555 invoked by uid 0); 26 Jan 2017 17:14:15 -0000 Received: from unknown (HELO cmgw4) (10.0.90.85) by gproxy8.mail.unifiedlayer.com with SMTP; 26 Jan 2017 17:14:15 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw4 with id d5Dd1u01V2f2jeq015Dg68; Thu, 26 Jan 2017 10:13:41 -0700 X-Authority-Analysis: v=2.1 cv=JsBi8qIC 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=IgFoBzBjUZAA:10 a=dtCbpQN9WzPdp4t20nAA:9 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=4KewrpzDTHZ9FnIxRryCNVr8RF/Jo2DPMwMSUzsctRU=; b=MJyOpg6Io1rZ5a+C0BJbbnNv8A +m1Zgc7g5Mnn6xTilQHFwu1mAltVXkxoQ0BUzuR9/5SOP6Ny6d7cxJRVhH/kv//juSY5+aaZmmTp6 pAQF84xFfTey1VYLbBWEOSfIK; Received: from 174-16-146-181.hlrn.qwest.net ([174.16.146.181]:60066 helo=pokyo) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1cWnc9-0000om-GX; Thu, 26 Jan 2017 10:13:37 -0700 From: Tom Tromey To: Eli Zaretskii Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <83inp32l50.fsf@gnu.org> <87inp3gigu.fsf@tromey.com> <8737g6hfyv.fsf@tromey.com> <83d1f93iyz.fsf@gnu.org> X-Attribution: Tom Date: Thu, 26 Jan 2017 10:13:33 -0700 In-Reply-To: <83d1f93iyz.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 26 Jan 2017 18:05:08 +0200") Message-ID: <874m0l4ude.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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 - debbugs.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: 1cWnc9-0000om-GX X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-146-181.hlrn.qwest.net (pokyo) [174.16.146.181]:60066 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Tom Tromey X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.1 (-) Eli> If all you need is to choose either black or white as the foreground Eli> color, then :distant-foreground is indeed not for you. Still, I'd Eli> suggest to use color-distance rather than to invent a new metric. Or Eli> maybe just always use the color that is complementary to the Eli> background color, as black and white seem arbitrary to me. I will test with complementary colors, but I am not sure those are always as visible. Black and white are arbitrary, but at least they work ok. I'm not sure there's a good way to use color distance to get the desired effect; if there were, surely Emacs core would be doing that already. Tom From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 26 12:23:54 2017 Received: (at 25525) by debbugs.gnu.org; 26 Jan 2017 17:23:54 +0000 Received: from localhost ([127.0.0.1]:45802 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWnm6-0004HQ-Gc for submit@debbugs.gnu.org; Thu, 26 Jan 2017 12:23:54 -0500 Received: from gproxy1-pub.mail.unifiedlayer.com ([69.89.25.95]:58109) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWnm5-0004HB-Dg for 25525@debbugs.gnu.org; Thu, 26 Jan 2017 12:23:53 -0500 Received: from cmgw4 (cmgw5 [10.0.90.85]) by gproxy1.mail.unifiedlayer.com (Postfix) with ESMTP id BE7F217738A for <25525@debbugs.gnu.org>; Thu, 26 Jan 2017 10:17:56 -0700 (MST) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw4 with id d5Hs1u01N2f2jeq015Hwhl; Thu, 26 Jan 2017 10:17:56 -0700 X-Authority-Analysis: v=2.1 cv=JsBi8qIC 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=IgFoBzBjUZAA:10 a=8pif782wAAAA:8 a=U1qOWiUI1RbDLIx0wX4A:9 a=0rJpSBR2IEkCROgwrX0h: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=+GtC9vkzUYC2+WxotheoWkT1Pb72sWzqUs1hGRdwB74=; b=tG+PZ1sZrcUDPqGorbqmJRRx3O DctUIQSCAtlqpV+uKgVq822fMQlsmGGPNZ42WbkyH0yfWbB1VUGbuWx53jN9shOqmBEiKXiDT2vHB ZJPavIsS8azjoQmIT72PxocIb; Received: from 174-16-146-181.hlrn.qwest.net ([174.16.146.181]:60272 helo=pokyo) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1cWngG-0007Gk-MN; Thu, 26 Jan 2017 10:17:52 -0700 From: Tom Tromey To: Eli Zaretskii Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <83inp32l50.fsf@gnu.org> <87inp3gigu.fsf@tromey.com> <8737g6hfyv.fsf@tromey.com> <83d1f93iyz.fsf@gnu.org> X-Attribution: Tom Date: Thu, 26 Jan 2017 10:17:51 -0700 In-Reply-To: <83d1f93iyz.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 26 Jan 2017 18:05:08 +0200") Message-ID: <87ziid3fls.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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 - debbugs.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: 1cWngG-0007Gk-MN X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-146-181.hlrn.qwest.net (pokyo) [174.16.146.181]:60272 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: -0.6 (/) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Tom Tromey X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) Eli> Still, I'd suggest to use color-distance rather than to invent a Eli> new metric. BTW I wanted to mention, I didn't invent this metric, it's well-known: https://en.wikipedia.org/wiki/Luma_(video) Tom From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 26 13:25:24 2017 Received: (at 25525) by debbugs.gnu.org; 26 Jan 2017 18:25:24 +0000 Received: from localhost ([127.0.0.1]:45901 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWojc-0007Tq-Bo for submit@debbugs.gnu.org; Thu, 26 Jan 2017 13:25:24 -0500 Received: from mail-lf0-f50.google.com ([209.85.215.50]:36212) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWoja-0007TW-Gu for 25525@debbugs.gnu.org; Thu, 26 Jan 2017 13:25:23 -0500 Received: by mail-lf0-f50.google.com with SMTP id z134so150019903lff.3 for <25525@debbugs.gnu.org>; Thu, 26 Jan 2017 10:25:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:message-id:in-reply-to:references :mime-version; bh=6vyiEQ22mLgaF0D/UyrDToTNnX2iqYaGchCi0O2L5Ns=; b=L2ADxZMBtq62r9P7cRpDG14TrbvbhyKbhH2CFQNhiBPuzT8JpmE6ymj+942f8YhbIi bAQLMl3hbbP2YSkx4X7kkr+q7b/cgAVcFrqisQTZJZnGqyfoczn/e3zeklSthIhK0HIi X9LeSTgJ+NRsYaIOQfQKZWq1i3yly7iz4+Y8QMizOZgPZUz7OXJkNs/Lb0AZf9JiUBrm p7H+useRqFsUQICx5KPFvLKd++CxNNV9H1DPxiGpr5aD/BbZmemtQ+KHibZFBV4IjFpq fdOa38oOGW5IlM+nVcpNfQSybIwZRXBpnI8R1lL8cmR97Bg/DkV57a8UEGTeqJL9DzSn BJzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to :references:mime-version; bh=6vyiEQ22mLgaF0D/UyrDToTNnX2iqYaGchCi0O2L5Ns=; b=J06lWJfLDWd6RkNlZVolWnZiC5JLRYzsBf5soewsFo0+/9h/4TxHUIftYulfAmAulS JnpNmttA5JrzK8zYyL5ya5K7LlxbRAzo8aSB2Z/a6OHHBHX0yXDT3d7li7wGVdsWDAjX wE895cHd5KawR+MdV8UuWlMtV6odyPx8SNZXjBtUFMhqVSKo6A/xWHJld1KpA8bmHWDX OML2DmD4rv3u/kASKlslaMgxaXjEwfUAiuejE8zPE1SoKeERY3Cvgz0E5nZPycV7+96L pUscsEyyixm8yanMUy4TtJUqgP7sWpLQ3GBwpm/q97eBSrPCrx/c4mznoGbjzlWtkW0S zeLQ== X-Gm-Message-State: AIkVDXJ161k1NZoQMtDCDF0CbUuOvSvriQ1ZKF96zDMCvWYJc1fQf6qcUdG8DgEs+Z/4TQ== X-Received: by 10.46.69.7 with SMTP id s7mr1622128lja.44.1485455116148; Thu, 26 Jan 2017 10:25:16 -0800 (PST) Received: from [192.168.100.10] (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id l133sm676443lfg.40.2017.01.26.10.25.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Jan 2017 10:25:15 -0800 (PST) Date: Thu, 26 Jan 2017 19:25:13 +0100 From: Simen =?iso-8859-1?q?Heggest=F8yl?= Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode To: Tom Tromey Message-Id: <1485455113.4245.1@smtp.gmail.com> In-Reply-To: <877f5ihge5.fsf@tromey.com> References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <"Simen \=\?utf-8\?Q\?Heggest\?\= \=\?utf-8\?Q\?\=C3\=B8yl\=22's\?\= message of "Wed, 25 Jan 2017 21:23:53 +0100"> X-Mailer: geary/0.11.3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed X-Spam-Score: -0.2 (/) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.2 (/) On Thu, Jan 26, 2017 at 12:24 AM, Tom Tromey wrote: > Simen> Thanks Tom, this looks to be a very nice addition to CSS mode! > Simen> Some comments: > [...] > > I think this version addresses all the review comments. Thanks Tom, that seems to fix all the issues I mentioned. I've come across one new problem when testing with the newest patch: Sometimes, in buffers that are long enough to scroll in, some colors aren't fontified until the line that contains the color is edited. I'm able to reproduce it in https://www.gnu.org/software/emacs/layout.css for instance, by opening the file and searching for "#". -- Simen From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 26 14:33:27 2017 Received: (at 25525) by debbugs.gnu.org; 26 Jan 2017 19:33:27 +0000 Received: from localhost ([127.0.0.1]:46035 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWpnS-0005q7-Qn for submit@debbugs.gnu.org; Thu, 26 Jan 2017 14:33:26 -0500 Received: from eggs.gnu.org ([208.118.235.92]:54077) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWpnQ-0005pu-P5 for 25525@debbugs.gnu.org; Thu, 26 Jan 2017 14:33:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cWpnI-0007Kn-CU for 25525@debbugs.gnu.org; Thu, 26 Jan 2017 14:33:19 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_05,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:52578) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWpnI-0007KZ-8i; Thu, 26 Jan 2017 14:33:16 -0500 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3726 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cWpnH-0007RO-0O; Thu, 26 Jan 2017 14:33:15 -0500 Date: Thu, 26 Jan 2017 21:32:55 +0200 Message-Id: <834m0l39co.fsf@gnu.org> From: Eli Zaretskii To: Tom Tromey In-reply-to: <874m0l4ude.fsf@tromey.com> (message from Tom Tromey on Thu, 26 Jan 2017 10:13:33 -0700) Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <83inp32l50.fsf@gnu.org> <87inp3gigu.fsf@tromey.com> <8737g6hfyv.fsf@tromey.com> <83d1f93iyz.fsf@gnu.org> <874m0l4ude.fsf@tromey.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -8.2 (--------) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -8.2 (--------) > From: Tom Tromey > Cc: Tom Tromey , 25525@debbugs.gnu.org > Date: Thu, 26 Jan 2017 10:13:33 -0700 > > I'm not sure there's a good way to use color distance to get the > desired effect; if there were, surely Emacs core would be doing that > already. I thought about something like (if (> (color-distance color "black") 292485) "black" "white") I think this is the equivalent of your test. (One reason for color-distance being unused could be that it isn't mentioned in the ELisp manual.) From debbugs-submit-bounces@debbugs.gnu.org Fri Feb 10 23:12:07 2017 Received: (at 25525) by debbugs.gnu.org; 11 Feb 2017 04:12:07 +0000 Received: from localhost ([127.0.0.1]:35245 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ccP2d-00028I-08 for submit@debbugs.gnu.org; Fri, 10 Feb 2017 23:12:07 -0500 Received: from gproxy7-pub.mail.unifiedlayer.com ([70.40.196.235]:54827) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1ccP2b-00027o-A8 for 25525@debbugs.gnu.org; Fri, 10 Feb 2017 23:12:05 -0500 Received: (qmail 26539 invoked by uid 0); 11 Feb 2017 04:11:54 -0000 Received: from unknown (HELO cmgw3) (10.0.90.84) by gproxy7.mail.unifiedlayer.com with SMTP; 11 Feb 2017 04:11:54 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id jGBp1u00J2f2jeq01GBsYq; Fri, 10 Feb 2017 21:11: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=mDV3o1hIAAAA:8 a=Jyo5vD-BFT8nKQQ6RR0A:9 a=_FVE-zBwftR9WsbkzFJk: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=JrGpEyrwa6X0tbwABTRe9d34FPwkWT8qXb36KsEpdJU=; b=D8nstcsJP6IiBBnbLwrrLTxyO1 oInnFSPPW33blePpEb8AL0HSNK6llPVfgPzgTEfz6nx1bjTMmdlgrSh8y5JkWkAe/bJqcjlbYslDs Q87TQadgvX/u5caAE5j9siXcs; Received: from 75-171-188-196.hlrn.qwest.net ([75.171.188.196]:49630 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1ccP2L-0005fG-48; Fri, 10 Feb 2017 21:11:49 -0700 From: Tom Tromey To: Eli Zaretskii Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <83inp32l50.fsf@gnu.org> <87inp3gigu.fsf@tromey.com> <8737g6hfyv.fsf@tromey.com> <83d1f93iyz.fsf@gnu.org> <874m0l4ude.fsf@tromey.com> <834m0l39co.fsf@gnu.org> X-Attribution: Tom Date: Fri, 10 Feb 2017 21:11:48 -0700 In-Reply-To: <834m0l39co.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 26 Jan 2017 21:32:55 +0200") Message-ID: <87mvdt5ptn.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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 - debbugs.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: 75.171.188.196 X-Exim-ID: 1ccP2L-0005fG-48 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-171-188-196.hlrn.qwest.net (bapiya) [75.171.188.196]:49630 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Tom Tromey X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.4 (-) >>>>> "Eli" == Eli Zaretskii writes: Eli> I thought about something like Eli> (if (> (color-distance color "black") 292485) "black" "white") Eli> I think this is the equivalent of your test. I tried this. In particular with the patch applied, I did this in a temporary (fundamental-mode) buffer: (mapcar (lambda (c) (insert (propertize (car c) 'font-lock-face (list :background (cdr c) :foreground (css--contrasty-color (cdr c)))) " " (propertize (car c) 'font-lock-face (list :background (cdr c) :foreground (if (> (color-distance (cdr c) "black") 292485) "black" "white"))) "\n")) css--color-map) ... then I looked at all the pairs. For the most part I think they are all ok. Occasionally color-distance picks a different color, sometimes a mildly worse one IMO, though at least in one case ("grey") a mildly better one. Anyway, I think it's good enough, and if someone trips across a difficult case and files a bug, we can revisit it at that time. Tom From debbugs-submit-bounces@debbugs.gnu.org Fri Feb 10 23:17:13 2017 Received: (at 25525) by debbugs.gnu.org; 11 Feb 2017 04:17:13 +0000 Received: from localhost ([127.0.0.1]:35249 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ccP7X-0002GQ-KS for submit@debbugs.gnu.org; Fri, 10 Feb 2017 23:17:11 -0500 Received: from gproxy6-pub.mail.unifiedlayer.com ([67.222.39.168]:37143) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1ccP7V-0002GB-Lu for 25525@debbugs.gnu.org; Fri, 10 Feb 2017 23:17:10 -0500 Received: (qmail 27111 invoked by uid 0); 11 Feb 2017 04:16:54 -0000 Received: from unknown (HELO CMOut01) (10.0.90.82) by gproxy6.mail.unifiedlayer.com with SMTP; 11 Feb 2017 04:16:54 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id jGGq1u00d2f2jeq01GGtpj; Fri, 10 Feb 2017 21:16:54 -0700 X-Authority-Analysis: v=2.1 cv=U+QBU4bu 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=IkcTkHD0fZMA:10 a=n2v9WMKugxEA:10 a=pGLkceISAAAA:8 a=VozNJtr-YH12Z0uM8owA:9 a=QEXdDO2ut3YA:10 a=6kGIvZw6iX1k4Y-7sg4_:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To: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=zL57/NoWGKRaa4rRr6VowaMM+P2o/QPz1NYw/38LqpE=; b=Gj8gNJb8mWtiRpDTNdjt6xQ1eq lzgZv01yZG8zxhcYg0CyJl2Eh6z46dvWGRQY0mV+lMJr35qTotcKVzr4AXPMcaChB8NWUniaOuZFM vd1DGT7RBp5pc9EsGE9/4DHHo; Received: from 75-171-188-196.hlrn.qwest.net ([75.171.188.196]:49642 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1ccP7C-0001iV-IR; Fri, 10 Feb 2017 21:16:50 -0700 From: Tom Tromey To: Simen =?utf-8?Q?Heggest=C3=B8yl?= Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> X-Attribution: Tom Date: Fri, 10 Feb 2017 21:16:48 -0700 In-Reply-To: <1485455113.4245.1@smtp.gmail.com> ("Simen \=\?utf-8\?Q\?Heggest\?\= \=\?utf-8\?Q\?\=C3\=B8yl\=22's\?\= message of "Thu, 26 Jan 2017 19:25:13 +0100") Message-ID: <87inoh5plb.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 - debbugs.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: 75.171.188.196 X-Exim-ID: 1ccP7C-0001iV-IR X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-171-188-196.hlrn.qwest.net (bapiya) [75.171.188.196]:49642 X-Source-Auth: tom+tromey.com X-Email-Count: 7 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Tom Tromey X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.4 (-) >>>>> "Simen" =3D=3D Simen Heggest=C3=B8yl writes: Simen> I've come across one new problem when testing with the newest patch: Simen> Sometimes, in buffers that are long enough to scroll in, some colors Simen> aren't fontified until the line that contains the color is edited. I've seen weird behavior too but haven't debugged it yet. Maybe css-mode needs to set font-lock-fontify-region-function instead. I am not sure. Tom From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 11 10:17:47 2017 Received: (at 25525) by debbugs.gnu.org; 11 Feb 2017 15:17:47 +0000 Received: from localhost ([127.0.0.1]:35814 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ccZQo-0004fP-8w for submit@debbugs.gnu.org; Sat, 11 Feb 2017 10:17:46 -0500 Received: from gproxy7-pub.mail.unifiedlayer.com ([70.40.196.235]:49207) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1ccZQl-0004fB-It for 25525@debbugs.gnu.org; Sat, 11 Feb 2017 10:17:44 -0500 Received: (qmail 6744 invoked by uid 0); 11 Feb 2017 15:17:30 -0000 Received: from unknown (HELO cmgw2) (10.0.90.83) by gproxy7.mail.unifiedlayer.com with SMTP; 11 Feb 2017 15:17:30 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id jTHS1u0012f2jeq01THVXo; Sat, 11 Feb 2017 08:17:30 -0700 X-Authority-Analysis: v=2.1 cv=H5NInYoi 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=IkcTkHD0fZMA:10 a=n2v9WMKugxEA:10 a=pGLkceISAAAA:8 a=O9wxBRIL8WYq-iCCro0A:9 a=ObKISWM53QNM9CDf:21 a=_x5vgm7SCCLjpacH:21 a=QEXdDO2ut3YA:10 a=6kGIvZw6iX1k4Y-7sg4_:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To: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=+wD7FwQ1VrwHXTqXcXExj3CH+C3QonzCrll5G/C0PEQ=; b=jRVLGfrKYPrbTcYCYqwNFoUFjw ssR6BjlViovJ8ZKOUfJPepgAC9rEylBla+SZxXwnvzqWDzd0X6dfemdlKpD6mpGvGm7uDcyOFd96j /6JsKrwo7A8JXgNlGIISkBolS; Received: from 75-171-188-196.hlrn.qwest.net ([75.171.188.196]:49926 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1ccZQT-0000D9-NI; Sat, 11 Feb 2017 08:17:25 -0700 From: Tom Tromey To: Simen =?utf-8?Q?Heggest=C3=B8yl?= Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> X-Attribution: Tom Date: Sat, 11 Feb 2017 08:17:21 -0700 In-Reply-To: <1485455113.4245.1@smtp.gmail.com> ("Simen \=\?utf-8\?Q\?Heggest\?\= \=\?utf-8\?Q\?\=C3\=B8yl\=22's\?\= message of "Thu, 26 Jan 2017 19:25:13 +0100") Message-ID: <87efz469ku.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 - debbugs.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: 75.171.188.196 X-Exim-ID: 1ccZQT-0000D9-NI X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-171-188-196.hlrn.qwest.net (bapiya) [75.171.188.196]:49926 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Tom Tromey X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.4 (-) >>>>> "Simen" =3D=3D Simen Heggest=C3=B8yl writes: Simen> I've come across one new problem when testing with the newest patch: Simen> Sometimes, in buffers that are long enough to scroll in, some colors Simen> aren't fontified until the line that contains the color is edited. Could you try this version? Tom diff --git a/etc/NEWS b/etc/NEWS index da0b538..4287387 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -638,6 +638,11 @@ pseudo-element, with the default being guessed from co= ntext). By default the information is looked up on the Mozilla Developer Network, but this can be customized using 'css-lookup-url-format'. =20 +--- +*** CSS colors are fontified using the color they represent as the +background. For instance, #ff0000 would be fontified with a red +background. + +++ ** Emacs now supports character name escape sequences in character and string literals. The syntax variants \N{character name} and diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 19746c6..a1e17b4 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -33,6 +33,8 @@ ;;; Code: =20 (require 'eww) +(require 'cl-lib) +(require 'color) (require 'seq) (require 'sgml-mode) (require 'smie) @@ -455,8 +457,157 @@ css-property-ids (mapcar #'car css-property-alist) "Identifiers for properties.") =20 +(defconst css--color-map + '(("black" . "#000000") + ("silver" . "#c0c0c0") + ("gray" . "#808080") + ("white" . "#ffffff") + ("maroon" . "#800000") + ("red" . "#ff0000") + ("purple" . "#800080") + ("fuchsia" . "#ff00ff") + ("green" . "#008000") + ("lime" . "#00ff00") + ("olive" . "#808000") + ("yellow" . "#ffff00") + ("navy" . "#000080") + ("blue" . "#0000ff") + ("teal" . "#008080") + ("aqua" . "#00ffff") + ("orange" . "#ffa500") + ("aliceblue" . "#f0f8ff") + ("antiquewhite" . "#faebd7") + ("aquamarine" . "#7fffd4") + ("azure" . "#f0ffff") + ("beige" . "#f5f5dc") + ("bisque" . "#ffe4c4") + ("blanchedalmond" . "#ffebcd") + ("blueviolet" . "#8a2be2") + ("brown" . "#a52a2a") + ("burlywood" . "#deb887") + ("cadetblue" . "#5f9ea0") + ("chartreuse" . "#7fff00") + ("chocolate" . "#d2691e") + ("coral" . "#ff7f50") + ("cornflowerblue" . "#6495ed") + ("cornsilk" . "#fff8dc") + ("crimson" . "#dc143c") + ("darkblue" . "#00008b") + ("darkcyan" . "#008b8b") + ("darkgoldenrod" . "#b8860b") + ("darkgray" . "#a9a9a9") + ("darkgreen" . "#006400") + ("darkgrey" . "#a9a9a9") + ("darkkhaki" . "#bdb76b") + ("darkmagenta" . "#8b008b") + ("darkolivegreen" . "#556b2f") + ("darkorange" . "#ff8c00") + ("darkorchid" . "#9932cc") + ("darkred" . "#8b0000") + ("darksalmon" . "#e9967a") + ("darkseagreen" . "#8fbc8f") + ("darkslateblue" . "#483d8b") + ("darkslategray" . "#2f4f4f") + ("darkslategrey" . "#2f4f4f") + ("darkturquoise" . "#00ced1") + ("darkviolet" . "#9400d3") + ("deeppink" . "#ff1493") + ("deepskyblue" . "#00bfff") + ("dimgray" . "#696969") + ("dimgrey" . "#696969") + ("dodgerblue" . "#1e90ff") + ("firebrick" . "#b22222") + ("floralwhite" . "#fffaf0") + ("forestgreen" . "#228b22") + ("gainsboro" . "#dcdcdc") + ("ghostwhite" . "#f8f8ff") + ("gold" . "#ffd700") + ("goldenrod" . "#daa520") + ("greenyellow" . "#adff2f") + ("grey" . "#808080") + ("honeydew" . "#f0fff0") + ("hotpink" . "#ff69b4") + ("indianred" . "#cd5c5c") + ("indigo" . "#4b0082") + ("ivory" . "#fffff0") + ("khaki" . "#f0e68c") + ("lavender" . "#e6e6fa") + ("lavenderblush" . "#fff0f5") + ("lawngreen" . "#7cfc00") + ("lemonchiffon" . "#fffacd") + ("lightblue" . "#add8e6") + ("lightcoral" . "#f08080") + ("lightcyan" . "#e0ffff") + ("lightgoldenrodyellow" . "#fafad2") + ("lightgray" . "#d3d3d3") + ("lightgreen" . "#90ee90") + ("lightgrey" . "#d3d3d3") + ("lightpink" . "#ffb6c1") + ("lightsalmon" . "#ffa07a") + ("lightseagreen" . "#20b2aa") + ("lightskyblue" . "#87cefa") + ("lightslategray" . "#778899") + ("lightslategrey" . "#778899") + ("lightsteelblue" . "#b0c4de") + ("lightyellow" . "#ffffe0") + ("limegreen" . "#32cd32") + ("linen" . "#faf0e6") + ("mediumaquamarine" . "#66cdaa") + ("mediumblue" . "#0000cd") + ("mediumorchid" . "#ba55d3") + ("mediumpurple" . "#9370db") + ("mediumseagreen" . "#3cb371") + ("mediumslateblue" . "#7b68ee") + ("mediumspringgreen" . "#00fa9a") + ("mediumturquoise" . "#48d1cc") + ("mediumvioletred" . "#c71585") + ("midnightblue" . "#191970") + ("mintcream" . "#f5fffa") + ("mistyrose" . "#ffe4e1") + ("moccasin" . "#ffe4b5") + ("navajowhite" . "#ffdead") + ("oldlace" . "#fdf5e6") + ("olivedrab" . "#6b8e23") + ("orangered" . "#ff4500") + ("orchid" . "#da70d6") + ("palegoldenrod" . "#eee8aa") + ("palegreen" . "#98fb98") + ("paleturquoise" . "#afeeee") + ("palevioletred" . "#db7093") + ("papayawhip" . "#ffefd5") + ("peachpuff" . "#ffdab9") + ("peru" . "#cd853f") + ("pink" . "#ffc0cb") + ("plum" . "#dda0dd") + ("powderblue" . "#b0e0e6") + ("rosybrown" . "#bc8f8f") + ("royalblue" . "#4169e1") + ("saddlebrown" . "#8b4513") + ("salmon" . "#fa8072") + ("sandybrown" . "#f4a460") + ("seagreen" . "#2e8b57") + ("seashell" . "#fff5ee") + ("sienna" . "#a0522d") + ("skyblue" . "#87ceeb") + ("slateblue" . "#6a5acd") + ("slategray" . "#708090") + ("slategrey" . "#708090") + ("snow" . "#fffafa") + ("springgreen" . "#00ff7f") + ("steelblue" . "#4682b4") + ("tan" . "#d2b48c") + ("thistle" . "#d8bfd8") + ("tomato" . "#ff6347") + ("turquoise" . "#40e0d0") + ("violet" . "#ee82ee") + ("wheat" . "#f5deb3") + ("whitesmoke" . "#f5f5f5") + ("yellowgreen" . "#9acd32") + ("rebeccapurple" . "#663399")) + "Map CSS named color to their hex RGB value.") + (defconst css-value-class-alist - '((absolute-size + `((absolute-size "xx-small" "x-small" "small" "medium" "large" "x-large" "xx-large") (alphavalue number) @@ -508,36 +659,7 @@ css-value-class-alist (line-width length "thin" "medium" "thick") (linear-gradient "linear-gradient()") (margin-width "auto" length percentage) - (named-color - "aliceblue" "antiquewhite" "aqua" "aquamarine" "azure" "beige" - "bisque" "black" "blanchedalmond" "blue" "blueviolet" "brown" - "burlywood" "cadetblue" "chartreuse" "chocolate" "coral" - "cornflowerblue" "cornsilk" "crimson" "cyan" "darkblue" - "darkcyan" "darkgoldenrod" "darkgray" "darkgreen" "darkkhaki" - "darkmagenta" "darkolivegreen" "darkorange" "darkorchid" - "darkred" "darksalmon" "darkseagreen" "darkslateblue" - "darkslategray" "darkturquoise" "darkviolet" "deeppink" - "deepskyblue" "dimgray" "dodgerblue" "firebrick" "floralwhite" - "forestgreen" "fuchsia" "gainsboro" "ghostwhite" "gold" - "goldenrod" "gray" "green" "greenyellow" "honeydew" "hotpink" - "indianred" "indigo" "ivory" "khaki" "lavender" "lavenderblush" - "lawngreen" "lemonchiffon" "lightblue" "lightcoral" "lightcyan" - "lightgoldenrodyellow" "lightgray" "lightgreen" "lightpink" - "lightsalmon" "lightseagreen" "lightskyblue" "lightslategray" - "lightsteelblue" "lightyellow" "lime" "limegreen" "linen" - "magenta" "maroon" "mediumaquamarine" "mediumblue" "mediumorchid" - "mediumpurple" "mediumseagreen" "mediumslateblue" - "mediumspringgreen" "mediumturquoise" "mediumvioletred" - "midnightblue" "mintcream" "mistyrose" "moccasin" "navajowhite" - "navy" "oldlace" "olive" "olivedrab" "orange" "orangered" - "orchid" "palegoldenrod" "palegreen" "paleturquoise" - "palevioletred" "papayawhip" "peachpuff" "peru" "pink" "plum" - "powderblue" "purple" "rebeccapurple" "red" "rosybrown" - "royalblue" "saddlebrown" "salmon" "sandybrown" "seagreen" - "seashell" "sienna" "silver" "skyblue" "slateblue" "slategray" - "snow" "springgreen" "steelblue" "tan" "teal" "thistle" "tomato" - "turquoise" "violet" "wheat" "white" "whitesmoke" "yellow" - "yellowgreen") + (named-color . ,(mapcar #'car css--color-map)) (number "calc()") (numeric-figure-values "lining-nums" "oldstyle-nums") (numeric-fraction-values "diagonal-fractions" "stacked-fractions") @@ -616,11 +738,23 @@ css-mode-syntax-table (modify-syntax-entry ?\[ "(]" st) (modify-syntax-entry ?\] ")[" st) ;; Special chars that sometimes come at the beginning of words. - (modify-syntax-entry ?@ "'" st) - ;; (modify-syntax-entry ?: "'" st) - (modify-syntax-entry ?# "'" st) + ;; We'll treat them as symbol constituents. + (modify-syntax-entry ?@ "_" st) + (modify-syntax-entry ?# "_" st) + (modify-syntax-entry ?. "_" st) ;; Distinction between words and symbols. (modify-syntax-entry ?- "_" st) + + (modify-syntax-entry ?! "." st) + (modify-syntax-entry ?$ "." st) + (modify-syntax-entry ?% "." st) + (modify-syntax-entry ?& "." st) + (modify-syntax-entry ?+ "." st) + (modify-syntax-entry ?, "." st) + (modify-syntax-entry ?< "." st) + (modify-syntax-entry ?> "." st) + (modify-syntax-entry ?=3D "." st) + (modify-syntax-entry ?? "." st) st)) =20 (defvar css-mode-map @@ -734,6 +868,201 @@ css-font-lock-keywords (defvar css-font-lock-defaults '(css-font-lock-keywords nil t)) =20 +(defconst css--number-regexp + "\\(\\(?:[0-9]*\\.[0-9]+\\(?:[eE][0-9]+\\)?\\)\\|[0-9]+\\)" + "A regular expression matching a CSS number.") + +(defconst css--percent-regexp "\\([0-9]+\\)%" + "A regular expression matching a CSS percentage.") + +(defconst css--number-or-percent-regexp + (concat "\\(?:" css--percent-regexp "\\)\\|\\(?:" css--number-regexp "\\= )") + "A regular expression matching a CSS number or a CSS percentage.") + +(defconst css--angle-regexp + (concat css--number-regexp + (regexp-opt '("deg" "grad" "rad" "turn") t) + "?") + "A regular expression matching a CSS angle.") + +(defun css--color-skip-blanks () + "Skip blanks and comments." + (while (forward-comment 1))) + +(cl-defun css--rgb-color () + "Parse a CSS rgb() or rgba() color. +Point should be just after the open paren. +Returns a hex RGB color, or nil if the color could not be recognized. +This recognizes CSS-color-4 extensions." + (let ((result '()) + (iter 0)) + (while (< iter 4) + (css--color-skip-blanks) + (unless (looking-at css--number-or-percent-regexp) + (cl-return-from css--css-4-rgb nil)) + (let* ((is-percent (match-beginning 1)) + (str (match-string (if is-percent 1 2))) + (number (string-to-number str))) + (when is-percent + (setq number (* 255 (/ number 100.0)))) + ;; Don't push the alpha. + (when (< iter 3) + (push (min (max 0 (truncate number)) 255) result)) + (goto-char (match-end 0)) + (css--color-skip-blanks) + (cl-incf iter) + ;; Accept a superset of the CSS syntax since I'm feeling lazy. + (when (and (=3D (skip-chars-forward ",/") 0) + (=3D iter 3)) + ;; The alpha is optional. + (cl-incf iter)) + (css--color-skip-blanks))) + (when (looking-at ")") + (forward-char) + (apply #'format "#%02x%02x%02x" (nreverse result))))) + +(cl-defun css--hsl-color () + "Parse a CSS hsl() or hsla() color. +Point should be just after the open paren. +Returns a hex RGB color, or nil if the color could not be recognized. +This recognizes CSS-color-4 extensions." + (let ((result '())) + ;; First parse the hue. + (css--color-skip-blanks) + (unless (looking-at css--angle-regexp) + (cl-return-from css--hsl-color nil)) + (let ((hue (string-to-number (match-string 1))) + (unit (match-string 2))) + (goto-char (match-end 0)) + ;; Note that here "turn" is just passed through. + (cond + ((or (not unit) (equal unit "deg")) + ;; Degrees. + (setq hue (/ hue 360.0))) + ((equal unit "grad") + (setq hue (/ hue 400.0))) + ((equal unit "rad") + (setq hue (/ hue (* 2 float-pi))))) + (push (mod hue 1.0) result)) + (dotimes (_ 2) + (skip-chars-forward ",") + (css--color-skip-blanks) + (unless (looking-at css--percent-regexp) + (cl-return-from css--hsl-color nil)) + (let ((number (string-to-number (match-string 1)))) + (setq number (/ number 100.0)) + (push (min (max number 0.0) 1.0) result) + (goto-char (match-end 0)) + (css--color-skip-blanks))) + (css--color-skip-blanks) + ;; Accept a superset of the CSS syntax since I'm feeling lazy. + (when (> (skip-chars-forward ",/") 0) + (css--color-skip-blanks) + (unless (looking-at css--number-or-percent-regexp) + (cl-return-from css--hsl-color nil)) + (goto-char (match-end 0)) + (css--color-skip-blanks)) + (when (looking-at ")") + (forward-char) + (apply #'color-rgb-to-hex + (apply #'color-hsl-to-rgb (nreverse result)))))) + +(defconst css--colors-regexp + (concat + ;; Named colors. + (regexp-opt (mapcar #'car css--color-map) 'symbols) + "\\|" + ;; Short hex. css-color-4 adds alpha. + "\\(#[0-9a-fA-F]\\{3,4\\}\\b\\)" + "\\|" + ;; Long hex. css-color-4 adds alpha. + "\\(#\\(?:[0-9a-fA-F][0-9a-fA-F]\\)\\{3,4\\}\\b\\)" + "\\|" + ;; RGB. + "\\(\\_ (length str) 4) + (substring str 0 7) + (substring str 0 4))) + +(defun css--compute-color () + "Return the CSS color at point. +Point should be just after the start of a CSS color, as recognized +by `css--colors-regexp'. This function will either return the color, +as a hex RGB string; or `nil' if no color could be recognized. When +this function returns, point will be at the end of the recognized +color." + (let ((match (downcase (match-string 0)))) + (cond + ((eq (aref match 0) ?#) + (css--hex-color match)) + ((member match '("rgb(" "rgba(")) + (css--rgb-color)) + ((member match '("hsl(" "hsla(")) + (css--hsl-color)) + ;; Evaluate to the color if the name is found. + ((cdr (assoc match css--color-map))) + (t + (error "Invalid case in css--compute-color"))))) + +(defun css--contrasty-color (name) + "Return a color that contrasts with NAME. +NAME is of any form accepted by `color-distance'. +The returned color will be usable by Emacs and will contrast +with NAME; in particular so that if NAME is used as a background +color, the returned color can be used as the foreground and still +be readable." + ;; See bug#25525 for a discussion of this. + (if (> (color-distance name "black") 292485) + "black" "white")) + +(defcustom css-fontify-colors t + "Whether CSS colors should be fontified using the color as the backgroun= d. +When non-`nil', a text representing CSS color will be fontified +such that its background is the color itself. E.g., #ff0000 will +be fontified with a red background." + :version "26.1" + :group 'css + :type 'boolean + :safe 'booleanp) + +(defun css--fontify-region (start end &optional loudly) + "Fontify a CSS buffer between START and END. +START and END are buffer positions." + (font-lock-default-fontify-region start end loudly) + (when css-fontify-colors + (save-excursion + (let ((case-fold-search t)) + (goto-char start) + (while (re-search-forward css--colors-regexp end t) + ;; Skip comments and strings. + (unless (nth 8 (syntax-ppss)) + (let ((start (match-beginning 0)) + (color (css--compute-color))) + (when color + (with-silent-modifications + ;; Use the color as the background, to make it more + ;; clear. Use a contrasting color as the foreground, + ;; to make it readable. Finally, have a small box + ;; using the existing foreground color, to make sure + ;; it stands out a bit from any other text; in + ;; particular this is nice when the color matches the + ;; buffer's background color. + (add-text-properties + start (point) + (list 'face (list :background color + :foreground (css--contrasty-color col= or) + :box '(:line-width -1))))))))))))) + (defcustom css-indent-offset 4 "Basic size of one indentation step." :version "22.2" @@ -988,6 +1317,7 @@ css-mode :backward-token #'css-smie--backward-token) (setq-local electric-indent-chars (append css-electric-keys electric-indent-chars)) + (setq-local font-lock-fontify-region-function #'css--fontify-region) (add-hook 'completion-at-point-functions #'css-completion-at-point nil 'local)) =20 diff --git a/test/lisp/textmodes/css-mode-tests.el b/test/lisp/textmodes/cs= s-mode-tests.el index 5372c37..a741484 100644 --- a/test/lisp/textmodes/css-mode-tests.el +++ b/test/lisp/textmodes/css-mode-tests.el @@ -58,7 +58,7 @@ =20 ;; Check that the `color' property doesn't cause infinite recursion ;; because it refers to the value class of the same name. - (should (=3D (length (css--property-values "color")) 147))) + (should (=3D (length (css--property-values "color")) 152))) =20 (ert-deftest css-test-property-value-cache () "Test that `css--property-value-cache' is in use." @@ -233,5 +233,40 @@ css-mode-tests--completions (save-excursion (insert (nth 1 item))) (should (equal (nth 2 item) (css--mdn-find-symbol)))))) =20 +(ert-deftest css-test-rgb-parser () + (with-temp-buffer + (css-mode) + (dolist (input '("255, 0, 127" + "255, /* comment */ 0, 127" + "255 0 127" + "255, 0, 127, 0.75" + "255 0 127 / 0.75" + "100%, 0%, 50%" + "100%, 0%, 50%, 0.115" + "100% 0% 50%" + "100% 0% 50% / 0.115")) + (erase-buffer) + (save-excursion + (insert input ")")) + (should (equal (css--rgb-color) "#ff007f"))))) + +(ert-deftest css-test-hsl-parser () + (with-temp-buffer + (css-mode) + (dolist (input '("0, 100%, 50%" + "0 100% 50%" + "0 /* two */ /* comments */100% 50%" + "0, 100%, 50%, 0.75" + "0 100% 50% / 0.75" + "0deg 100% 50%" + "360deg 100% 50%" + "0rad, 100%, 50%, 0.115" + "0grad, 100%, 50%, 0.115" + "1turn 100% 50% / 0.115")) + (erase-buffer) + (save-excursion + (insert input ")")) + (should (equal (css--hsl-color) "#ff0000"))))) + (provide 'css-mode-tests) ;;; css-mode-tests.el ends here From debbugs-submit-bounces@debbugs.gnu.org Fri Feb 17 14:29:46 2017 Received: (at 25525) by debbugs.gnu.org; 17 Feb 2017 19:29:46 +0000 Received: from localhost ([127.0.0.1]:43821 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ceoDy-00015m-1g for submit@debbugs.gnu.org; Fri, 17 Feb 2017 14:29:46 -0500 Received: from mail-lf0-f53.google.com ([209.85.215.53]:36166) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ceoDv-00015W-Ai for 25525@debbugs.gnu.org; Fri, 17 Feb 2017 14:29:44 -0500 Received: by mail-lf0-f53.google.com with SMTP id z134so26941209lff.3 for <25525@debbugs.gnu.org>; Fri, 17 Feb 2017 11:29:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JZxFXU2Leh85g2yeUxoXr0dXWZY15c0rK1nd3DcTSco=; b=spvDeEvlGSD+/chNWVSxRW6QSK4K8bQ7VeZhLrFjfwMml4/q1bgcZcAbxdk9OByKhU VdNdiSYBFaRgvIKJDwE5SdVUsmgYPDFFU6J9PPHBDIsUYZ7R6sECL5oWg/gtIumtGl+P bOx+Vmrvk2o7Aujq/rbKXrQspdsWvo+zLOzJu1TcAVBsUDnaQAgcwKYbpAFmFYcf82ky K1IBW4xjJNQ/Ag38usQRhoAfdrhU78YgioY09z2eUk8WBodkbe9j2MrSkUvRnaiAurrf bm43xa3/gkjdVt4wVPv7EiXOCtEEW7dQES5PhJpceCB/+vu/QzzYrpzK2uSh2RyqyV82 zZxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JZxFXU2Leh85g2yeUxoXr0dXWZY15c0rK1nd3DcTSco=; b=IHrlynpB7ONklH2BoCmNKml/Tg+efT8xo9vGWdnFUNCaf9FXQeTI2yTgOyaqxO9rs/ bTFpdZOH+qJMA+F+NswOnM/07jCDNTIQ0evDlmslG0xlSq4MIXSU6YAQQ5iVUJZjiW0p /viD1vag9sxdJRq9sGEnBhLtZFnKUPkQbXPNqIOOkLF2yCVvWi1gt3B1nZ3xDFQPqoHS eWOeAMl2myJAo5GH+xvFXN51z59PV3bSM10JrJHYTYgJeRGJSylRJpCEYI6PzVOav9oc 0RdDUY3H1SO8/QkzbDecaIZSLWxF2LLgcmUqZJnX5mF9ye/Wul83RZiWVpm9rJ/PyH76 E0+Q== X-Gm-Message-State: AMke39kNJAVUBLgSvoMQHp/JUe5Pi2+tlpUUVgE4GdQd+NB2EYM/f6a9svHFvwPkIc6JnA== X-Received: by 10.25.217.205 with SMTP id s74mr2416031lfi.8.1487359776667; Fri, 17 Feb 2017 11:29:36 -0800 (PST) Received: from [192.168.100.10] (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id s14sm2743407ljd.53.2017.02.17.11.29.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 17 Feb 2017 11:29:35 -0800 (PST) Date: Fri, 17 Feb 2017 20:29:34 +0100 From: Simen =?iso-8859-1?q?Heggest=F8yl?= Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode To: Tom Tromey Message-Id: <1487359774.1998.0@smtp.gmail.com> In-Reply-To: <87efz469ku.fsf@tromey.com> References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <"Simen \=\?utf-8\?Q\?Heggest\?\= \=\?utf-8\?Q\?\=C3\=B8yl\=22's\?\= message of "Thu, 26 Jan 2017 19:25:13 +0100"> X-Mailer: geary/0.11.3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On Sat, Feb 11, 2017 at 4:17 PM, Tom Tromey wrote: >>>>>> "Simen" =3D=3D Simen Heggest=C3=B8yl writes: >=20 > Simen> I've come across one new problem when testing with the newest=20 > patch: > Simen> Sometimes, in buffers that are long enough to scroll in, some=20 > colors > Simen> aren't fontified until the line that contains the color is=20 > edited. >=20 > Could you try this version? >=20 > Tom Hi, Tom. Unfortunately I'm still experiencing the bug with that version too. -- Simen = From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 04 12:56:08 2017 Received: (at 25525) by debbugs.gnu.org; 4 Mar 2017 17:56:08 +0000 Received: from localhost ([127.0.0.1]:40230 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ckDuZ-0002cF-Hf for submit@debbugs.gnu.org; Sat, 04 Mar 2017 12:56:08 -0500 Received: from gproxy6-pub.mail.unifiedlayer.com ([67.222.39.168]:39026) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1ckDuX-0002bi-4z for 25525@debbugs.gnu.org; Sat, 04 Mar 2017 12:56:06 -0500 Received: (qmail 25127 invoked by uid 0); 4 Mar 2017 17:55:53 -0000 Received: from unknown (HELO CMOut01) (10.0.90.82) by gproxy6.mail.unifiedlayer.com with SMTP; 4 Mar 2017 17:55:53 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id rtvm1u00N2f2jeq01tvpgy; Sat, 04 Mar 2017 10:55:53 -0700 X-Authority-Analysis: v=2.1 cv=U+QBU4bu 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=6Iz7jQTuP9IA:10 a=wagK1E21nVZSIia02O8A:9 a=8vpisfNK0ZZER1Mbb-EA:9 a=Gqr2KEVnnw4uaM16:21 a=s9Hzk0S6iktw1MOL:21 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=hbwoTVbuRq+lHcPvS8TLfn2oIvh0+F8yMWJp3AfaSBQ=; b=mKqSgaL/y4tc83RA9peYHfEu8c mXawY4U5W1026RH1RJaeLRIrzrCIcUzJM+riDZwptrbH8WOFJUpkn/swgh7r02qzHInGbtJ4hIobK KoS77Jh64/tVi86McxhAjCo1M; Received: from 71-218-43-111.hlrn.qwest.net ([71.218.43.111]:52086 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1ckDuE-0003IM-Hr; Sat, 04 Mar 2017 10:55:46 -0700 From: Tom Tromey To: Simen =?utf-8?Q?Heggest=C3=B8yl?= Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <1487359774.1998.0@smtp.gmail.com> Date: Sat, 04 Mar 2017 10:55:45 -0700 In-Reply-To: <1487359774.1998.0@smtp.gmail.com> ("Simen \=\?utf-8\?Q\?Heggest\?\= \=\?utf-8\?Q\?\=C3\=B8yl\=22's\?\= message of "Fri, 17 Feb 2017 20:29:34 +0100") Message-ID: <87a891j59a.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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 - debbugs.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: 71.218.43.111 X-Exim-ID: 1ckDuE-0003IM-Hr X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-218-43-111.hlrn.qwest.net (bapiya) [71.218.43.111]:52086 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: 2.6 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Simen> Unfortunately I'm still experiencing the bug with that version Simen> too. I was able to reproduce the problem and I think I found the bug: css--fontify-region was not respecting any region extension done by font-lock-default-fontify-region, but this is what extended fontification to include the whole line containing point when searching. [...] Content analysis details: (2.6 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [67.222.39.168 listed in list.dnswl.org] 2.7 RCVD_IN_PSBL RBL: Received via a relay in PSBL [67.222.39.168 listed in psbl.surriel.com] -0.1 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [67.222.39.168 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Tom Tromey X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 2.6 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Simen> Unfortunately I'm still experiencing the bug with that version Simen> too. I was able to reproduce the problem and I think I found the bug: css--fontify-region was not respecting any region extension done by font-lock-default-fontify-region, but this is what extended fontification to include the whole line containing point when searching. [...] Content analysis details: (2.6 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.7 RCVD_IN_PSBL RBL: Received via a relay in PSBL [67.222.39.168 listed in psbl.surriel.com] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [67.222.39.168 listed in list.dnswl.org] -0.1 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [67.222.39.168 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid --=-=-= Content-Type: text/plain Simen> Unfortunately I'm still experiencing the bug with that version Simen> too. I was able to reproduce the problem and I think I found the bug: css--fontify-region was not respecting any region extension done by font-lock-default-fontify-region, but this is what extended fontification to include the whole line containing point when searching. Please try this version. Tom --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=P Content-Description: newest patch diff --git a/etc/NEWS b/etc/NEWS index a8db54c..ae2ac3e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -668,6 +668,11 @@ pseudo-element, with the default being guessed from context). By default the information is looked up on the Mozilla Developer Network, but this can be customized using 'css-lookup-url-format'. +--- +*** CSS colors are fontified using the color they represent as the +background. For instance, #ff0000 would be fontified with a red +background. + +++ ** Emacs now supports character name escape sequences in character and string literals. The syntax variants \N{character name} and diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 7a9454f..8cec7ca 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -33,6 +33,8 @@ ;;; Code: (require 'eww) +(require 'cl-lib) +(require 'color) (require 'seq) (require 'sgml-mode) (require 'smie) @@ -455,8 +457,157 @@ css-property-ids (mapcar #'car css-property-alist) "Identifiers for properties.") +(defconst css--color-map + '(("black" . "#000000") + ("silver" . "#c0c0c0") + ("gray" . "#808080") + ("white" . "#ffffff") + ("maroon" . "#800000") + ("red" . "#ff0000") + ("purple" . "#800080") + ("fuchsia" . "#ff00ff") + ("green" . "#008000") + ("lime" . "#00ff00") + ("olive" . "#808000") + ("yellow" . "#ffff00") + ("navy" . "#000080") + ("blue" . "#0000ff") + ("teal" . "#008080") + ("aqua" . "#00ffff") + ("orange" . "#ffa500") + ("aliceblue" . "#f0f8ff") + ("antiquewhite" . "#faebd7") + ("aquamarine" . "#7fffd4") + ("azure" . "#f0ffff") + ("beige" . "#f5f5dc") + ("bisque" . "#ffe4c4") + ("blanchedalmond" . "#ffebcd") + ("blueviolet" . "#8a2be2") + ("brown" . "#a52a2a") + ("burlywood" . "#deb887") + ("cadetblue" . "#5f9ea0") + ("chartreuse" . "#7fff00") + ("chocolate" . "#d2691e") + ("coral" . "#ff7f50") + ("cornflowerblue" . "#6495ed") + ("cornsilk" . "#fff8dc") + ("crimson" . "#dc143c") + ("darkblue" . "#00008b") + ("darkcyan" . "#008b8b") + ("darkgoldenrod" . "#b8860b") + ("darkgray" . "#a9a9a9") + ("darkgreen" . "#006400") + ("darkgrey" . "#a9a9a9") + ("darkkhaki" . "#bdb76b") + ("darkmagenta" . "#8b008b") + ("darkolivegreen" . "#556b2f") + ("darkorange" . "#ff8c00") + ("darkorchid" . "#9932cc") + ("darkred" . "#8b0000") + ("darksalmon" . "#e9967a") + ("darkseagreen" . "#8fbc8f") + ("darkslateblue" . "#483d8b") + ("darkslategray" . "#2f4f4f") + ("darkslategrey" . "#2f4f4f") + ("darkturquoise" . "#00ced1") + ("darkviolet" . "#9400d3") + ("deeppink" . "#ff1493") + ("deepskyblue" . "#00bfff") + ("dimgray" . "#696969") + ("dimgrey" . "#696969") + ("dodgerblue" . "#1e90ff") + ("firebrick" . "#b22222") + ("floralwhite" . "#fffaf0") + ("forestgreen" . "#228b22") + ("gainsboro" . "#dcdcdc") + ("ghostwhite" . "#f8f8ff") + ("gold" . "#ffd700") + ("goldenrod" . "#daa520") + ("greenyellow" . "#adff2f") + ("grey" . "#808080") + ("honeydew" . "#f0fff0") + ("hotpink" . "#ff69b4") + ("indianred" . "#cd5c5c") + ("indigo" . "#4b0082") + ("ivory" . "#fffff0") + ("khaki" . "#f0e68c") + ("lavender" . "#e6e6fa") + ("lavenderblush" . "#fff0f5") + ("lawngreen" . "#7cfc00") + ("lemonchiffon" . "#fffacd") + ("lightblue" . "#add8e6") + ("lightcoral" . "#f08080") + ("lightcyan" . "#e0ffff") + ("lightgoldenrodyellow" . "#fafad2") + ("lightgray" . "#d3d3d3") + ("lightgreen" . "#90ee90") + ("lightgrey" . "#d3d3d3") + ("lightpink" . "#ffb6c1") + ("lightsalmon" . "#ffa07a") + ("lightseagreen" . "#20b2aa") + ("lightskyblue" . "#87cefa") + ("lightslategray" . "#778899") + ("lightslategrey" . "#778899") + ("lightsteelblue" . "#b0c4de") + ("lightyellow" . "#ffffe0") + ("limegreen" . "#32cd32") + ("linen" . "#faf0e6") + ("mediumaquamarine" . "#66cdaa") + ("mediumblue" . "#0000cd") + ("mediumorchid" . "#ba55d3") + ("mediumpurple" . "#9370db") + ("mediumseagreen" . "#3cb371") + ("mediumslateblue" . "#7b68ee") + ("mediumspringgreen" . "#00fa9a") + ("mediumturquoise" . "#48d1cc") + ("mediumvioletred" . "#c71585") + ("midnightblue" . "#191970") + ("mintcream" . "#f5fffa") + ("mistyrose" . "#ffe4e1") + ("moccasin" . "#ffe4b5") + ("navajowhite" . "#ffdead") + ("oldlace" . "#fdf5e6") + ("olivedrab" . "#6b8e23") + ("orangered" . "#ff4500") + ("orchid" . "#da70d6") + ("palegoldenrod" . "#eee8aa") + ("palegreen" . "#98fb98") + ("paleturquoise" . "#afeeee") + ("palevioletred" . "#db7093") + ("papayawhip" . "#ffefd5") + ("peachpuff" . "#ffdab9") + ("peru" . "#cd853f") + ("pink" . "#ffc0cb") + ("plum" . "#dda0dd") + ("powderblue" . "#b0e0e6") + ("rosybrown" . "#bc8f8f") + ("royalblue" . "#4169e1") + ("saddlebrown" . "#8b4513") + ("salmon" . "#fa8072") + ("sandybrown" . "#f4a460") + ("seagreen" . "#2e8b57") + ("seashell" . "#fff5ee") + ("sienna" . "#a0522d") + ("skyblue" . "#87ceeb") + ("slateblue" . "#6a5acd") + ("slategray" . "#708090") + ("slategrey" . "#708090") + ("snow" . "#fffafa") + ("springgreen" . "#00ff7f") + ("steelblue" . "#4682b4") + ("tan" . "#d2b48c") + ("thistle" . "#d8bfd8") + ("tomato" . "#ff6347") + ("turquoise" . "#40e0d0") + ("violet" . "#ee82ee") + ("wheat" . "#f5deb3") + ("whitesmoke" . "#f5f5f5") + ("yellowgreen" . "#9acd32") + ("rebeccapurple" . "#663399")) + "Map CSS named color to their hex RGB value.") + (defconst css-value-class-alist - '((absolute-size + `((absolute-size "xx-small" "x-small" "small" "medium" "large" "x-large" "xx-large") (alphavalue number) @@ -508,36 +659,7 @@ css-value-class-alist (line-width length "thin" "medium" "thick") (linear-gradient "linear-gradient()") (margin-width "auto" length percentage) - (named-color - "aliceblue" "antiquewhite" "aqua" "aquamarine" "azure" "beige" - "bisque" "black" "blanchedalmond" "blue" "blueviolet" "brown" - "burlywood" "cadetblue" "chartreuse" "chocolate" "coral" - "cornflowerblue" "cornsilk" "crimson" "cyan" "darkblue" - "darkcyan" "darkgoldenrod" "darkgray" "darkgreen" "darkkhaki" - "darkmagenta" "darkolivegreen" "darkorange" "darkorchid" - "darkred" "darksalmon" "darkseagreen" "darkslateblue" - "darkslategray" "darkturquoise" "darkviolet" "deeppink" - "deepskyblue" "dimgray" "dodgerblue" "firebrick" "floralwhite" - "forestgreen" "fuchsia" "gainsboro" "ghostwhite" "gold" - "goldenrod" "gray" "green" "greenyellow" "honeydew" "hotpink" - "indianred" "indigo" "ivory" "khaki" "lavender" "lavenderblush" - "lawngreen" "lemonchiffon" "lightblue" "lightcoral" "lightcyan" - "lightgoldenrodyellow" "lightgray" "lightgreen" "lightpink" - "lightsalmon" "lightseagreen" "lightskyblue" "lightslategray" - "lightsteelblue" "lightyellow" "lime" "limegreen" "linen" - "magenta" "maroon" "mediumaquamarine" "mediumblue" "mediumorchid" - "mediumpurple" "mediumseagreen" "mediumslateblue" - "mediumspringgreen" "mediumturquoise" "mediumvioletred" - "midnightblue" "mintcream" "mistyrose" "moccasin" "navajowhite" - "navy" "oldlace" "olive" "olivedrab" "orange" "orangered" - "orchid" "palegoldenrod" "palegreen" "paleturquoise" - "palevioletred" "papayawhip" "peachpuff" "peru" "pink" "plum" - "powderblue" "purple" "rebeccapurple" "red" "rosybrown" - "royalblue" "saddlebrown" "salmon" "sandybrown" "seagreen" - "seashell" "sienna" "silver" "skyblue" "slateblue" "slategray" - "snow" "springgreen" "steelblue" "tan" "teal" "thistle" "tomato" - "turquoise" "violet" "wheat" "white" "whitesmoke" "yellow" - "yellowgreen") + (named-color . ,(mapcar #'car css--color-map)) (number "calc()") (numeric-figure-values "lining-nums" "oldstyle-nums") (numeric-fraction-values "diagonal-fractions" "stacked-fractions") @@ -616,11 +738,23 @@ css-mode-syntax-table (modify-syntax-entry ?\[ "(]" st) (modify-syntax-entry ?\] ")[" st) ;; Special chars that sometimes come at the beginning of words. - (modify-syntax-entry ?@ "'" st) - ;; (modify-syntax-entry ?: "'" st) - (modify-syntax-entry ?# "'" st) + ;; We'll treat them as symbol constituents. + (modify-syntax-entry ?@ "_" st) + (modify-syntax-entry ?# "_" st) + (modify-syntax-entry ?. "_" st) ;; Distinction between words and symbols. (modify-syntax-entry ?- "_" st) + + (modify-syntax-entry ?! "." st) + (modify-syntax-entry ?$ "." st) + (modify-syntax-entry ?% "." st) + (modify-syntax-entry ?& "." st) + (modify-syntax-entry ?+ "." st) + (modify-syntax-entry ?, "." st) + (modify-syntax-entry ?< "." st) + (modify-syntax-entry ?> "." st) + (modify-syntax-entry ?= "." st) + (modify-syntax-entry ?? "." st) st)) (defvar css-mode-map @@ -735,6 +869,206 @@ css-font-lock-keywords (defvar css-font-lock-defaults '(css-font-lock-keywords nil t)) +(defconst css--number-regexp + "\\(\\(?:[0-9]*\\.[0-9]+\\(?:[eE][0-9]+\\)?\\)\\|[0-9]+\\)" + "A regular expression matching a CSS number.") + +(defconst css--percent-regexp "\\([0-9]+\\)%" + "A regular expression matching a CSS percentage.") + +(defconst css--number-or-percent-regexp + (concat "\\(?:" css--percent-regexp "\\)\\|\\(?:" css--number-regexp "\\)") + "A regular expression matching a CSS number or a CSS percentage.") + +(defconst css--angle-regexp + (concat css--number-regexp + (regexp-opt '("deg" "grad" "rad" "turn") t) + "?") + "A regular expression matching a CSS angle.") + +(defun css--color-skip-blanks () + "Skip blanks and comments." + (while (forward-comment 1))) + +(cl-defun css--rgb-color () + "Parse a CSS rgb() or rgba() color. +Point should be just after the open paren. +Returns a hex RGB color, or nil if the color could not be recognized. +This recognizes CSS-color-4 extensions." + (let ((result '()) + (iter 0)) + (while (< iter 4) + (css--color-skip-blanks) + (unless (looking-at css--number-or-percent-regexp) + (cl-return-from css--css-4-rgb nil)) + (let* ((is-percent (match-beginning 1)) + (str (match-string (if is-percent 1 2))) + (number (string-to-number str))) + (when is-percent + (setq number (* 255 (/ number 100.0)))) + ;; Don't push the alpha. + (when (< iter 3) + (push (min (max 0 (truncate number)) 255) result)) + (goto-char (match-end 0)) + (css--color-skip-blanks) + (cl-incf iter) + ;; Accept a superset of the CSS syntax since I'm feeling lazy. + (when (and (= (skip-chars-forward ",/") 0) + (= iter 3)) + ;; The alpha is optional. + (cl-incf iter)) + (css--color-skip-blanks))) + (when (looking-at ")") + (forward-char) + (apply #'format "#%02x%02x%02x" (nreverse result))))) + +(cl-defun css--hsl-color () + "Parse a CSS hsl() or hsla() color. +Point should be just after the open paren. +Returns a hex RGB color, or nil if the color could not be recognized. +This recognizes CSS-color-4 extensions." + (let ((result '())) + ;; First parse the hue. + (css--color-skip-blanks) + (unless (looking-at css--angle-regexp) + (cl-return-from css--hsl-color nil)) + (let ((hue (string-to-number (match-string 1))) + (unit (match-string 2))) + (goto-char (match-end 0)) + ;; Note that here "turn" is just passed through. + (cond + ((or (not unit) (equal unit "deg")) + ;; Degrees. + (setq hue (/ hue 360.0))) + ((equal unit "grad") + (setq hue (/ hue 400.0))) + ((equal unit "rad") + (setq hue (/ hue (* 2 float-pi))))) + (push (mod hue 1.0) result)) + (dotimes (_ 2) + (skip-chars-forward ",") + (css--color-skip-blanks) + (unless (looking-at css--percent-regexp) + (cl-return-from css--hsl-color nil)) + (let ((number (string-to-number (match-string 1)))) + (setq number (/ number 100.0)) + (push (min (max number 0.0) 1.0) result) + (goto-char (match-end 0)) + (css--color-skip-blanks))) + (css--color-skip-blanks) + ;; Accept a superset of the CSS syntax since I'm feeling lazy. + (when (> (skip-chars-forward ",/") 0) + (css--color-skip-blanks) + (unless (looking-at css--number-or-percent-regexp) + (cl-return-from css--hsl-color nil)) + (goto-char (match-end 0)) + (css--color-skip-blanks)) + (when (looking-at ")") + (forward-char) + (apply #'color-rgb-to-hex + (apply #'color-hsl-to-rgb (nreverse result)))))) + +(defconst css--colors-regexp + (concat + ;; Named colors. + (regexp-opt (mapcar #'car css--color-map) 'symbols) + "\\|" + ;; Short hex. css-color-4 adds alpha. + "\\(#[0-9a-fA-F]\\{3,4\\}\\b\\)" + "\\|" + ;; Long hex. css-color-4 adds alpha. + "\\(#\\(?:[0-9a-fA-F][0-9a-fA-F]\\)\\{3,4\\}\\b\\)" + "\\|" + ;; RGB. + "\\(\\_ (length str) 4) + (substring str 0 7) + (substring str 0 4))) + +(defun css--compute-color () + "Return the CSS color at point. +Point should be just after the start of a CSS color, as recognized +by `css--colors-regexp'. This function will either return the color, +as a hex RGB string; or `nil' if no color could be recognized. When +this function returns, point will be at the end of the recognized +color." + (let ((match (downcase (match-string 0)))) + (cond + ((eq (aref match 0) ?#) + (css--hex-color match)) + ((member match '("rgb(" "rgba(")) + (css--rgb-color)) + ((member match '("hsl(" "hsla(")) + (css--hsl-color)) + ;; Evaluate to the color if the name is found. + ((cdr (assoc match css--color-map))) + (t + (error "Invalid case in css--compute-color"))))) + +(defun css--contrasty-color (name) + "Return a color that contrasts with NAME. +NAME is of any form accepted by `color-distance'. +The returned color will be usable by Emacs and will contrast +with NAME; in particular so that if NAME is used as a background +color, the returned color can be used as the foreground and still +be readable." + ;; See bug#25525 for a discussion of this. + (if (> (color-distance name "black") 292485) + "black" "white")) + +(defcustom css-fontify-colors t + "Whether CSS colors should be fontified using the color as the background. +When non-`nil', a text representing CSS color will be fontified +such that its background is the color itself. E.g., #ff0000 will +be fontified with a red background." + :version "26.1" + :group 'css + :type 'boolean + :safe 'booleanp) + +(defun css--fontify-region (start end &optional loudly) + "Fontify a CSS buffer between START and END. +START and END are buffer positions." + (let ((extended-region (font-lock-default-fontify-region start end loudly))) + (when css-fontify-colors + (when (and (consp extended-region) + (eq (car extended-region) 'jit-lock-bounds)) + (setq start (cadr extended-region)) + (setq end (cddr extended-region))) + (save-excursion + (let ((case-fold-search t)) + (goto-char start) + (while (re-search-forward css--colors-regexp end t) + ;; Skip comments and strings. + (unless (nth 8 (syntax-ppss)) + (let ((start (match-beginning 0)) + (color (css--compute-color))) + (when color + (with-silent-modifications + ;; Use the color as the background, to make it more + ;; clear. Use a contrasting color as the foreground, + ;; to make it readable. Finally, have a small box + ;; using the existing foreground color, to make sure + ;; it stands out a bit from any other text; in + ;; particular this is nice when the color matches the + ;; buffer's background color. + (add-text-properties + start (point) + (list 'face (list :background color + :foreground (css--contrasty-color color) + :box '(:line-width -1)))))))))))) + extended-region)) + (defcustom css-indent-offset 4 "Basic size of one indentation step." :version "22.2" @@ -1001,6 +1335,7 @@ css-mode :backward-token #'css-smie--backward-token) (setq-local electric-indent-chars (append css-electric-keys electric-indent-chars)) + (setq-local font-lock-fontify-region-function #'css--fontify-region) (add-hook 'completion-at-point-functions #'css-completion-at-point nil 'local)) diff --git a/test/lisp/textmodes/css-mode-tests.el b/test/lisp/textmodes/css-mode-tests.el index d601f43..5fa4ae2 100644 --- a/test/lisp/textmodes/css-mode-tests.el +++ b/test/lisp/textmodes/css-mode-tests.el @@ -58,7 +58,7 @@ ;; Check that the `color' property doesn't cause infinite recursion ;; because it refers to the value class of the same name. - (should (= (length (css--property-values "color")) 147))) + (should (= (length (css--property-values "color")) 152))) (ert-deftest css-test-property-value-cache () "Test that `css--property-value-cache' is in use." @@ -234,5 +234,40 @@ css-mode-tests--completions (save-excursion (insert (nth 1 item))) (should (equal (nth 2 item) (css--mdn-find-symbol)))))) +(ert-deftest css-test-rgb-parser () + (with-temp-buffer + (css-mode) + (dolist (input '("255, 0, 127" + "255, /* comment */ 0, 127" + "255 0 127" + "255, 0, 127, 0.75" + "255 0 127 / 0.75" + "100%, 0%, 50%" + "100%, 0%, 50%, 0.115" + "100% 0% 50%" + "100% 0% 50% / 0.115")) + (erase-buffer) + (save-excursion + (insert input ")")) + (should (equal (css--rgb-color) "#ff007f"))))) + +(ert-deftest css-test-hsl-parser () + (with-temp-buffer + (css-mode) + (dolist (input '("0, 100%, 50%" + "0 100% 50%" + "0 /* two */ /* comments */100% 50%" + "0, 100%, 50%, 0.75" + "0 100% 50% / 0.75" + "0deg 100% 50%" + "360deg 100% 50%" + "0rad, 100%, 50%, 0.115" + "0grad, 100%, 50%, 0.115" + "1turn 100% 50% / 0.115")) + (erase-buffer) + (save-excursion + (insert input ")")) + (should (equal (css--hsl-color) "#ff0000"))))) + (provide 'css-mode-tests) ;;; css-mode-tests.el ends here --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 04 13:46:43 2017 Received: (at 25525) by debbugs.gnu.org; 4 Mar 2017 18:46:43 +0000 Received: from localhost ([127.0.0.1]:40242 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ckEhX-0003uI-6m for submit@debbugs.gnu.org; Sat, 04 Mar 2017 13:46:43 -0500 Received: from mail-lf0-f47.google.com ([209.85.215.47]:36807) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ckEhU-0003u3-De for 25525@debbugs.gnu.org; Sat, 04 Mar 2017 13:46:40 -0500 Received: by mail-lf0-f47.google.com with SMTP id y193so58726213lfd.3 for <25525@debbugs.gnu.org>; Sat, 04 Mar 2017 10:46:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:message-id:in-reply-to:references :mime-version; bh=EG0CQylt2NJ253fDOHt4YeOVANltiTIkzXv65be04Uw=; b=VykcWfQHSa2gvh+f2vW4Z65MVfXeDWMIhnNKuOdmWhr9uii4oH7/sCRaB9Wryk9KUj 5XM7nHUS4AC8KnfeuLODs6UETTHedm3Ntt4/16Wm/pR8ztdP+cRvCGrFhk3h2NpGfyqH 3CC0Sp5A7Jep1SSVhGlQ8TIairlfu2N4lbLN2gAWPAsjK6yWdCwPQZFILh8KE3SPPBT6 1RvH7bmL7e6n4/k1n50LZQnHg7fW+BnbyoY3lsQUsbJRF2zeA5FuA+A3zLCXyrKAyFNG uPMHZfp1meEXsaePbeClZAcMuQO4+tGl2+sxh9MFy8djeldcmP5xOHMM1xi+/l29DOgd CyDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to :references:mime-version; bh=EG0CQylt2NJ253fDOHt4YeOVANltiTIkzXv65be04Uw=; b=RizFoSvChmamg3h2m4hPto4kYcunq+kgUORG1E5Px7bqG5vlt5mLPY3oBPW3wvMK7Z aEuZ7XCdLG7Mi/63SBa0gZ3+KVYzl/VxctSUIG5J8EDJg/WjLCqYJuGBVQTu3NZbA+mp yDMJnrrn+zMf8KI05Jcit+PzOD23OCAyLHrE4wv9o1T7PO85onGS9Zx20VjTPmuO1O4w aGMasNZUvaO/BMw+6YGKd4togro+GjYmY5VvNAm6XKXNPUbaYHPIZyGfmzNkmymFcqY5 RKupSUen3BDZDSs8FUm6plcJJ+Ji88GCsfKZxmD4qJes3NEye/OcAB0j/FEI8ZcCHNFo YTag== X-Gm-Message-State: AMke39ki/d9IKkW/m8QWi0awAsx8vOfzI2u+VmAJVnoBSMtJOT7d4kT+x0lI4x98bFmVAw== X-Received: by 10.46.83.88 with SMTP id t24mr2999441ljd.20.1488653194198; Sat, 04 Mar 2017 10:46:34 -0800 (PST) Received: from [192.168.100.9] (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id n20sm3009568lfb.53.2017.03.04.10.46.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 04 Mar 2017 10:46:33 -0800 (PST) Date: Sat, 04 Mar 2017 19:46:31 +0100 From: Simen =?iso-8859-1?q?Heggest=F8yl?= Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode To: Tom Tromey Message-Id: <1488653191.6153.0@smtp.gmail.com> In-Reply-To: <87a891j59a.fsf@tromey.com> References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <1487359774.1998.0@smtp.gmail.com> <"Simen \=\?utf-8\?Q\?Heggest\?\= \=\?utf-8\?Q\?\=C3\=B8yl\=22's\?\= message of "Fri, 17 Feb 2017 20:29:34 +0100"> X-Mailer: geary/0.11.3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On Sat, Mar 4, 2017 at 6:55 PM, Tom Tromey wrote: > I was able to reproduce the problem and I think I found the bug: > css--fontify-region was not respecting any region extension done by > font-lock-default-fontify-region, but this is what extended > fontification to include the whole line containing point when > searching. > > Please try this version. Nice, that seems to have fixed the bug! I found another one: in SCSS mode, when using the `rgba` function where one argument is a variable, subsequent colors aren't highlighted. An example: body { color: #ddd; color: rgba($color-var, 1); color: #abc; // Not highlighted } There is also a test failure when you rebase the patch on the latest master due to the changes in 7b00e956b4. It can be fixed by passing 2 as the last argument to `color-rgb-to-hex' in `css--hsl-color'. -- Simen From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 04 14:58:55 2017 Received: (at 25525) by debbugs.gnu.org; 4 Mar 2017 19:58:56 +0000 Received: from localhost ([127.0.0.1]:40264 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ckFpP-0005ba-ND for submit@debbugs.gnu.org; Sat, 04 Mar 2017 14:58:55 -0500 Received: from gproxy5-pub.mail.unifiedlayer.com ([67.222.38.55]:51927) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1ckFpN-0005bM-9Z for 25525@debbugs.gnu.org; Sat, 04 Mar 2017 14:58:53 -0500 Received: (qmail 14572 invoked by uid 0); 4 Mar 2017 19:58:45 -0000 Received: from unknown (HELO CMOut01) (10.0.90.82) by gproxy5.mail.unifiedlayer.com with SMTP; 4 Mar 2017 19:58:45 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id rvye1u00Z2f2jeq01vyhGG; Sat, 04 Mar 2017 12:58:45 -0700 X-Authority-Analysis: v=2.1 cv=U+QBU4bu 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=IkcTkHD0fZMA:10 a=6Iz7jQTuP9IA:10 a=pGLkceISAAAA:8 a=sfeLlzl1AUBhnYANJbEA:9 a=wKTUYRAmkEnMR62Q:21 a=NNDU_1bO2De1ZK0V:21 a=QEXdDO2ut3YA:10 a=6kGIvZw6iX1k4Y-7sg4_:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To: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=Nx161qf1sv66bU6WfCU9J1lLV/pxBGSv6/rAn+WbjgQ=; b=I9kCA6pTqrJBvV7km9mwinhgRn eqKtmnRbDAKcQpcItVCUSar5X7GsXj0XR2TB5oRVhKkG9le6KowEDDmesFnfJV479CPM8WERnyNhH hRSBJpOhVxWC8QYN372xAKCjm; Received: from 71-218-43-111.hlrn.qwest.net ([71.218.43.111]:52878 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1ckFp8-0006Yh-KY; Sat, 04 Mar 2017 12:58:38 -0700 From: Tom Tromey To: Simen =?utf-8?Q?Heggest=C3=B8yl?= Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <1487359774.1998.0@smtp.gmail.com> <1488653191.6153.0@smtp.gmail.com> X-Attribution: Tom Date: Sat, 04 Mar 2017 12:58:35 -0700 In-Reply-To: <1488653191.6153.0@smtp.gmail.com> ("Simen \=\?utf-8\?Q\?Heggest\?\= \=\?utf-8\?Q\?\=C3\=B8yl\=22's\?\= message of "Sat, 04 Mar 2017 19:46:31 +0100") Message-ID: <87r32cizkk.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 - debbugs.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: 71.218.43.111 X-Exim-ID: 1ckFp8-0006Yh-KY X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-218-43-111.hlrn.qwest.net (bapiya) [71.218.43.111]:52878 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: -0.1 (/) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Tom Tromey X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) >>>>> "Simen" =3D=3D Simen Heggest=C3=B8yl writes: Simen> I found another one: in SCSS mode, when using the `rgba` function Simen> where one argument is a variable, subsequent colors aren't Simen> highlighted. An example: Thank you. This was due to using the wrong block name in a call to cl-return-from. I must have changed the function name and forgotten about this bit. Anyway, apply the appended patch on top of what you've got and please try to find more bugs :) Simen> There is also a test failure when you rebase the patch on the latest Simen> master due to the changes in 7b00e956b4. It can be fixed by passing 2 Simen> as the last argument to `color-rgb-to-hex' in `css--hsl-color'. Thanks, I'll apply this to my patch. Tom diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 8cec7ca..7af9fdd 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -900,7 +900,7 @@ css--color-skip-blanks (while (< iter 4) (css--color-skip-blanks) (unless (looking-at css--number-or-percent-regexp) - (cl-return-from css--css-4-rgb nil)) + (cl-return-from css--rgb-color nil)) (let* ((is-percent (match-beginning 1)) (str (match-string (if is-percent 1 2))) (number (string-to-number str))) From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 04 21:42:55 2017 Received: (at 25525) by debbugs.gnu.org; 5 Mar 2017 02:42:55 +0000 Received: from localhost ([127.0.0.1]:40439 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ckM8N-0000FW-21 for submit@debbugs.gnu.org; Sat, 04 Mar 2017 21:42:55 -0500 Received: from gproxy7-pub.mail.unifiedlayer.com ([70.40.196.235]:41881) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1ckM8L-0000FG-OA for 25525@debbugs.gnu.org; Sat, 04 Mar 2017 21:42:54 -0500 Received: (qmail 17195 invoked by uid 0); 5 Mar 2017 02:42:41 -0000 Received: from unknown (HELO cmgw2) (10.0.90.83) by gproxy7.mail.unifiedlayer.com with SMTP; 5 Mar 2017 02:42:41 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id s2ic1u0032f2jeq012ifhW; Sat, 04 Mar 2017 19:42:41 -0700 X-Authority-Analysis: v=2.1 cv=H5NInYoi 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=IkcTkHD0fZMA:10 a=6Iz7jQTuP9IA:10 a=pGLkceISAAAA:8 a=32JuczK8xAGvGqqeEKgA:9 a=QEXdDO2ut3YA:10 a=6kGIvZw6iX1k4Y-7sg4_:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To: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=aRS65hMy3hnX8iP36AsOiCceRfqrWdYWpTEvs9dO1eY=; b=b0GDbUDX7vzBptg4yunPOsMUws mjb5V9UKtmV+b0jj6ikhuePYfeM1PZZkj0hvmJulXX81m87LUVLodZ6/bDEof5S1PPDE6vVBmrOQ8 HzMcANNIeHosh2TlA79Qa8Mvf; Received: from 71-218-43-111.hlrn.qwest.net ([71.218.43.111]:52940 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1ckM83-0004BN-Pq; Sat, 04 Mar 2017 19:42:35 -0700 From: Tom Tromey To: Simen =?utf-8?Q?Heggest=C3=B8yl?= Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <1487359774.1998.0@smtp.gmail.com> <1488653191.6153.0@smtp.gmail.com> X-Attribution: Tom Date: Sat, 04 Mar 2017 19:42:34 -0700 In-Reply-To: <1488653191.6153.0@smtp.gmail.com> ("Simen \=\?utf-8\?Q\?Heggest\?\= \=\?utf-8\?Q\?\=C3\=B8yl\=22's\?\= message of "Sat, 04 Mar 2017 19:46:31 +0100") Message-ID: <87mvd0igv9.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 - debbugs.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: 71.218.43.111 X-Exim-ID: 1ckM83-0004BN-Pq X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-218-43-111.hlrn.qwest.net (bapiya) [71.218.43.111]:52940 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: 0.4 (/) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Eli Zaretskii , Tom Tromey X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.4 (/) >>>>> "Simen" =3D=3D Simen Heggest=C3=B8yl writes: Simen> There is also a test failure when you rebase the patch on the latest Simen> master due to the changes in 7b00e956b4. It can be fixed by passing 2 Simen> as the last argument to `color-rgb-to-hex' in `css--hsl-color'. This happens due to the change in 7b00e956b485d8ade03c870cbdd0ae086348737b, which changed color-name-to-rgb in a backward-incompatible way. Eli, you made this change -- it seems to me that it would be safer if it defaulted to 2 digits, which was how it worked previously. This would be backward-compatible and allow the new functionality as well. Tom From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 05 10:35:02 2017 Received: (at 25525) by debbugs.gnu.org; 5 Mar 2017 15:35:02 +0000 Received: from localhost ([127.0.0.1]:41117 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ckYBa-00061K-8S for submit@debbugs.gnu.org; Sun, 05 Mar 2017 10:35:02 -0500 Received: from eggs.gnu.org ([208.118.235.92]:49156) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ckYBY-00060o-UO for 25525@debbugs.gnu.org; Sun, 05 Mar 2017 10:35:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ckYBQ-0000OJ-Jf for 25525@debbugs.gnu.org; Sun, 05 Mar 2017 10:34:55 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:60214) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ckYBQ-0000OF-Gw; Sun, 05 Mar 2017 10:34:52 -0500 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1405 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ckYBP-0004Ae-Tk; Sun, 05 Mar 2017 10:34:52 -0500 Date: Sun, 05 Mar 2017 17:34:41 +0200 Message-Id: <83efybka9a.fsf@gnu.org> From: Eli Zaretskii To: Tom Tromey In-reply-to: <87mvd0igv9.fsf@tromey.com> (message from Tom Tromey on Sat, 04 Mar 2017 19:42:34 -0700) Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <1487359774.1998.0@smtp.gmail.com> <1488653191.6153.0@smtp.gmail.com> <87mvd0igv9.fsf@tromey.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, simenheg@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > From: Tom Tromey > Cc: Tom Tromey , 25525@debbugs.gnu.org, Eli Zaretskii > Date: Sat, 04 Mar 2017 19:42:34 -0700 > > >>>>> "Simen" == Simen Heggestøyl writes: > > Simen> There is also a test failure when you rebase the patch on the latest > Simen> master due to the changes in 7b00e956b4. It can be fixed by passing 2 > Simen> as the last argument to `color-rgb-to-hex' in `css--hsl-color'. > > This happens due to the change in 7b00e956b485d8ade03c870cbdd0ae086348737b, > which changed color-name-to-rgb in a backward-incompatible way. > Eli, you made this change -- it seems to me that it would be safer if it > defaulted to 2 digits, which was how it worked previously. This would > be backward-compatible and allow the new functionality as well. If we leave the default at 2, people will never discover they need to use 4 there, and the original problem which prompted those changes will be still with us years from now. The reasons for using 4-digit (i.e. 16 bits per component) hex specifications are subtle and buried deep in the Emacs internals related to color calculations. I don't expect Lisp programmers to understand those reasons. I actually forgot about this subtlety myself, until that bug surfaced. When I worked on the change, it seemed harmless: the function has only one caller outside of color.el, and I changed that single caller to use the optional argument. css-mode is the second such caller, and if the code was there when I made the changes, I'd have fixed that as well. Both shr-color and css-mode manipulate Web-related color specs, where 2 hex digits per component are the rule. That's a niche application, as far as color management in Emacs is concerned, so, unfortunate as it is, it's up to the people who develop such applications to know that they need 2 digits rather than the default 4. If the change I made is nevertheless deemed too drastic, then what are our alternatives? The only one I could think of is to define a new function and deprecate color-name-to-rgb in favor of that new function, which will then display warnings when code using it is compiled, and eventually cause them to make changes in their code anyway. Is that better? Or are there any better ideas? From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 05 13:28:55 2017 Received: (at 25525) by debbugs.gnu.org; 5 Mar 2017 18:28:55 +0000 Received: from localhost ([127.0.0.1]:41277 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ckatr-0003m8-5L for submit@debbugs.gnu.org; Sun, 05 Mar 2017 13:28:55 -0500 Received: from mail-lf0-f45.google.com ([209.85.215.45]:34878) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ckato-0003lk-Qr for 25525@debbugs.gnu.org; Sun, 05 Mar 2017 13:28:53 -0500 Received: by mail-lf0-f45.google.com with SMTP id j90so27338685lfk.2 for <25525@debbugs.gnu.org>; Sun, 05 Mar 2017 10:28:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:message-id:in-reply-to:references :mime-version; bh=z2m/uGy67PO4x4vVXJSSgb9kwct08nxbdeTaUdKtEhc=; b=bPEMggXqDToW4+QfvFyc5vv98RTFUBYhSAK0BfLVE/Y34nJQRQr4hClSDGWPJmu12g gi+Iw6ldLIDnSpElsiOkDJ4nvJd0GLgH14SfT3xa9e6MiUCmY/PdModctGdWMu4jWt1R ASsVVm9DvejnhIXEDOifa2bE7wqBxWx+UlYQkPR4PZcWLQmvEeNLrVnAJfSZ1/4ok01O 7ReN+RneXKF0emXzPMJGBP2859a1Wq54JPkxOoIXo5p43ko8npOOyL98xGy2KaSPf/JN HzClC9x5x5GWVWHPeBXA1888cItn57idlxq7XoNJFL4+DykFZ/hwYeywnlatukHdyj1L OAEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to :references:mime-version; bh=z2m/uGy67PO4x4vVXJSSgb9kwct08nxbdeTaUdKtEhc=; b=YlYBPelJ206ga9KAsChdukr6kwNKOEq/fSCh6wYJy8gHnMm7xB1o/SJ/S4xTh26shF qG7lf8AW/FcebCVg9keDvEpZPYQKe7a29pbhzbvMV2g9w7N+I8WJA3Pnv1SDBKdK5Cu0 lWZFjIs6nfo/xbQKQRNn2D4NEId0dbLANKfdxlSUhS/mdB68zYn17v1M6Q9pZe3y5yx8 YoCTx+TYDBbQUFiLiWSXHFPlH2FWiZm06BxhcVFq2Rkx2Wzy6AuXhJwvTu1vmJ37jAzp BAVlsO/+6EuODUEr6I5CRdqUY2G+MvavdMTw7ujJHF++XsmFjiZMCM7cHg9u+VIXe2dw 1k/g== X-Gm-Message-State: AMke39mVwYuqew1oW/PqAwdAEeSFC79dnXngkKJG/5BpYs2iDZJatTPyDiozE/VG6Mey4w== X-Received: by 10.46.77.72 with SMTP id a69mr4225482ljb.104.1488738526755; Sun, 05 Mar 2017 10:28:46 -0800 (PST) Received: from [192.168.100.9] (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id o91sm3409778lfg.1.2017.03.05.10.28.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 05 Mar 2017 10:28:45 -0800 (PST) Date: Sun, 05 Mar 2017 19:28:44 +0100 From: Simen =?iso-8859-1?q?Heggest=F8yl?= Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode To: Tom Tromey Message-Id: <1488738524.13864.0@smtp.gmail.com> In-Reply-To: <87r32cizkk.fsf@tromey.com> References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <1487359774.1998.0@smtp.gmail.com> <1488653191.6153.0@smtp.gmail.com> <"Simen \=\?utf-8\?Q\?Heggest\?\= \=\?utf-8\?Q\?\=C3\=B8yl\=22's\?\= message of "Sat, 04 Mar 2017 19:46:31 +0100"> X-Mailer: geary/0.11.3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) On Sat, Mar 4, 2017 at 8:58 PM, Tom Tromey wrote: > Thank you. This was due to using the wrong block name in a call to > cl-return-from. I must have changed the function name and forgotten > about this bit. Anyway, apply the appended patch on top of what > you've > got and please try to find more bugs :) Yes, that fixed it, thanks. Here's another one: SCSS variables and mixins with the exact same name as a color are highlighted. So in the following, both instances of "black" are highlighted in black: @mixin black { $black: #000; } -- Simen From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 20 17:28:48 2017 Received: (at 25525) by debbugs.gnu.org; 20 Mar 2017 21:28:48 +0000 Received: from localhost ([127.0.0.1]:36784 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cq4rA-0002ey-5t for submit@debbugs.gnu.org; Mon, 20 Mar 2017 17:28:48 -0400 Received: from gproxy3-pub.mail.unifiedlayer.com ([69.89.30.42]:48744) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1cq4r8-0002ei-Pw for 25525@debbugs.gnu.org; Mon, 20 Mar 2017 17:28:47 -0400 Received: (qmail 18669 invoked by uid 0); 20 Mar 2017 21:28:38 -0000 Received: from unknown (HELO cmgw3) (10.0.90.84) by gproxy3.mail.unifiedlayer.com with SMTP; 20 Mar 2017 21:28:38 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id yMUa1u0052f2jeq01MUdFz; Mon, 20 Mar 2017 15:28:38 -0600 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=6Iz7jQTuP9IA:10 a=OMxaGbVGeYZlZD2423QA:9 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=LA2CfeXq+A8cJ7TE2DH4NI+zxcXlkiC0gokwK8+fK2U=; b=i0urP0sseOBpihqbRihRXj7SZD 5EhZnEoCuGc2WFBI+NNeRfQIUxgEMglkHiYIIUJedLaFf5Vkt9YMh9Ch/MXmknISIdJ22w4UgLrXZ OHsdkjOc+s3v9tAxQKuGdvNW0; Received: from 75-166-14-202.hlrn.qwest.net ([75.166.14.202]:60022 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1cq4qv-0008Gc-W2; Mon, 20 Mar 2017 15:28:34 -0600 From: Tom Tromey To: Tom Tromey Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <1487359774.1998.0@smtp.gmail.com> <1488653191.6153.0@smtp.gmail.com> <1488738524.13864.0@smtp.gmail.com> <871str3b48.fsf@tromey.com> X-Attribution: Tom Date: Mon, 20 Mar 2017 15:28:33 -0600 In-Reply-To: <871str3b48.fsf@tromey.com> (Tom Tromey's message of "Mon, 20 Mar 2017 15:13:27 -0600") Message-ID: <87wpbj1vum.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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 - debbugs.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: 75.166.14.202 X-Exim-ID: 1cq4qv-0008Gc-W2 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-14-202.hlrn.qwest.net (bapiya) [75.166.14.202]:60022 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Simen =?utf-8?Q?Heggest=C3=B8yl?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Simen> Here's another one: SCSS variables and mixins with the exact same name Simen> as a color are highlighted. So in the following, both instances of Simen> "black" are highlighted in black: Simen> @mixin black { Simen> $black: #000; Simen> } Tom> Fixing "$black" seems possible. I'll take a look. I just tried my patch and "$black" is not highlighted here in scss mode. I think that's expected, now that I look at it, because css--colors-regexp starts with a "\_<", so it only matches at symbol boundaries. Tom From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 22 18:08:03 2017 Received: (at 25525) by debbugs.gnu.org; 22 Mar 2017 22:08:03 +0000 Received: from localhost ([127.0.0.1]:39870 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cqoQD-0004xD-JV for submit@debbugs.gnu.org; Wed, 22 Mar 2017 18:08:03 -0400 Received: from gproxy3-pub.mail.unifiedlayer.com ([69.89.30.42]:35380) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1cqoQB-0004wk-6P for 25525@debbugs.gnu.org; Wed, 22 Mar 2017 18:07:59 -0400 Received: (qmail 25316 invoked by uid 0); 22 Mar 2017 22:07:40 -0000 Received: from unknown (HELO cmgw3) (10.0.90.84) by gproxy3.mail.unifiedlayer.com with SMTP; 22 Mar 2017 22:07:40 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id zA7c1u0042f2jeq01A7fb8; Wed, 22 Mar 2017 16:07:40 -0600 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=6Iz7jQTuP9IA:10 a=WiVod9pSvdkA:10 a=AVQlZYFg8UXY9J76sGEA:9 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=+AfuScPjD0pRpmNqnt7XR3IeYwpqArQhNGrI/KjxJQA=; b=gX47X8a/L9e9V5Ed1z4NPTcpj6 j//fuxyU9cdf1HQRJxHs83QrtGt0ONXo29/TuCaxTU/HxGjgESJiqekl9z0pCw/KQKF/pajOo9pWk L3sco/Ap+eF3NR8AY1hcqkPv9; Received: from 97-118-172-192.hlrn.qwest.net ([97.118.172.192]:52396 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1cqoPn-0004vA-Pj; Wed, 22 Mar 2017 16:07:35 -0600 From: Tom Tromey To: Tom Tromey Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <1487359774.1998.0@smtp.gmail.com> <1488653191.6153.0@smtp.gmail.com> <1488738524.13864.0@smtp.gmail.com> <871str3b48.fsf@tromey.com> X-Attribution: Tom Date: Wed, 22 Mar 2017 16:07:33 -0600 In-Reply-To: <871str3b48.fsf@tromey.com> (Tom Tromey's message of "Mon, 20 Mar 2017 15:13:27 -0600") Message-ID: <87poh90xui.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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 - debbugs.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: 97.118.172.192 X-Exim-ID: 1cqoPn-0004vA-Pj X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-118-172-192.hlrn.qwest.net (bapiya) [97.118.172.192]:52396 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Simen =?utf-8?Q?Heggest=C3=B8yl?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.8 (--) Tom> I'm not sure the @mixin problem can be fixed without doing more parsing. On second thought, I suppose checking backward one word isn't such a big deal. I don't know SCSS though. Is @mixin the only problem case or are there others? Tom From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 29 14:27:47 2017 Received: (at 25525) by debbugs.gnu.org; 29 Mar 2017 18:27:47 +0000 Received: from localhost ([127.0.0.1]:51577 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ctIJv-0001da-A6 for submit@debbugs.gnu.org; Wed, 29 Mar 2017 14:27:47 -0400 Received: from mail-lf0-f53.google.com ([209.85.215.53]:35613) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ctIJt-0001dN-Ln for 25525@debbugs.gnu.org; Wed, 29 Mar 2017 14:27:46 -0400 Received: by mail-lf0-f53.google.com with SMTP id j90so14342937lfk.2 for <25525@debbugs.gnu.org>; Wed, 29 Mar 2017 11:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:message-id:in-reply-to:references :mime-version; bh=D5owC5YC5do37tShowzL1WHzFCxZsCkq5rKDBcGV46I=; b=Affja9nQr51BhxI2D6s6kS3qZalrHv5d6e4ChLa9k2zHvQgbhYhgwkzJ1V3zDhRN61 KUBvLXSLTFFwwlzOJPdynvej4XVkKQ9qNZg+clbyD2Bsm65OGTXtB7HrZLR2q2bzQquI 5ZSIPAwFbcQCikgu/NDFK4WzAe15PqLCG0B7sIb1P6tWlPG91SVNh0sXsZnY4etRy4Rf sHNSY1E9dSX1phThpWjXOy7+0VapNQeA5U2ItMGR6XJLGKBcU1YpzwZELT6veAfebp6t dqAMlsHkOlQ2UqXIJnuR5v8yUpkBdrNwFS1WeYKtbAoxPNKu/Davp+hQWMYVAiHEZHJW 4pJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to :references:mime-version; bh=D5owC5YC5do37tShowzL1WHzFCxZsCkq5rKDBcGV46I=; b=kU9qfdAlu1audr1HQr7Efc964f2+DQh7XP+c2AtRGXG+fRU4kS01GoS8cHNMDc0kdd EIeRJJVK5+nylB19C6fn5MpNj5vbUnp6hYOYtuJqy/oQql8cBwcExIB9cmZaCk5t/f7O 3yqoR0+WVRFONQ/ElsZY6IHBq+AW91nm78MRpzXSiX0DatRA3hCZ04ZGiybcZqdXF+ED FOKH2bP3TCyhPvjKxw+IsE3oW3v5qbUY+Ru6UNM1/eguQflBuQPzIOmXfl+H/S+Co5mV thhITdOEwTaVrYJdpZuYw9DzyeK1VVlfyOz7r+TnKi54yrwOrcgR73AX+ETIvFqHNkR8 4q5w== X-Gm-Message-State: AFeK/H3AF35g8fvpUAojDjr1agx3gAPFmkCgbcHW84t7JoQaDCEKmGfqXobw8Y2buP8hNg== X-Received: by 10.46.14.17 with SMTP id 17mr689834ljo.40.1490812059696; Wed, 29 Mar 2017 11:27:39 -0700 (PDT) Received: from [192.168.100.9] (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id t125sm1426323lff.31.2017.03.29.11.27.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 Mar 2017 11:27:38 -0700 (PDT) Date: Wed, 29 Mar 2017 20:27:36 +0200 From: Simen =?iso-8859-1?q?Heggest=F8yl?= Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode To: Tom Tromey Message-Id: <1490812056.14782.1@smtp.gmail.com> In-Reply-To: <87poh90xui.fsf@tromey.com> References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <1487359774.1998.0@smtp.gmail.com> <1488653191.6153.0@smtp.gmail.com> <1488738524.13864.0@smtp.gmail.com> <871str3b48.fsf@tromey.com> X-Mailer: geary/0.11.3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) > I just tried my patch and "$black" is not highlighted here in scss mode. > I think that's expected, now that I look at it, because > css--colors-regexp starts with a "\_<", so it only matches at symbol > boundaries. Hm, I'm still seeing it here with the patch from March 4. Maybe that one is outdated? > On second thought, I suppose checking backward one word isn't such a big > deal. I don't know SCSS though. Is @mixin the only problem case or are > there others? I think the names of mixins and placeholders are most important, because it's not unlikely for them to have colors for names. Examples of usage: @mixin black {} .foo { @include black; } %black {} .foo { @extend %black; } There's also maps, but I think they're less important if it's hard to solve: $foo: (bar: 1, black: 2); -- Simen From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 20 23:41:08 2017 Received: (at 25525) by debbugs.gnu.org; 21 Apr 2017 03:41:08 +0000 Received: from localhost ([127.0.0.1]:59598 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d1PRT-0006wo-Eb for submit@debbugs.gnu.org; Thu, 20 Apr 2017 23:41:08 -0400 Received: from gproxy10-pub.mail.unifiedlayer.com ([69.89.20.226]:35126 helo=gproxy10.mail.unifiedlayer.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d1PRQ-0006vg-52 for 25525@debbugs.gnu.org; Thu, 20 Apr 2017 23:41:05 -0400 Received: from cmgw3 (unknown [10.0.90.84]) by gproxy10.mail.unifiedlayer.com (Postfix) with ESMTP id 467781405A8 for <25525@debbugs.gnu.org>; Thu, 20 Apr 2017 21:40:53 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id Argp1v0032f2jeq01rgsV2; Thu, 20 Apr 2017 21:40:53 -0600 X-Authority-Analysis: v=2.2 cv=VKStp5HX c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=AzvcPWV-tVgA:10 a=pGLkceISAAAA:8 a=HfW9UNEZNpKdSpP3phQA:9 a=QEXdDO2ut3YA:10 a=zstS-IiYAAAA:8 a=WxUXrq8xl85NNRlDl-AA:9 a=-h-0T419LePNFRIQ:21 a=OBeojw1dOw5GutBD:21 a=6kGIvZw6iX1k4Y-7sg4_:22 a=4G6NA9xxw8l3yy4pmD5M: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=WQQ6MdcdpCZ/AWXBnzNUGjKLZJvmNeREqJwJQB1kzm8=; b=qYINw5gTknTrKT8IT5aOQNrgh9 bLtD7QtGjKND8OGLIUP8vAHE7thqyZlUzc+a8c9F21xap4/Hk/MQGEka/wZErj01G/BJLiCpfafIh OizEoiDXU9xvc0qSgqiNRwz2H; Received: from 75-166-40-121.hlrn.qwest.net ([75.166.40.121]:54256 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1d1PRA-0005HP-PD; Thu, 20 Apr 2017 21:40:48 -0600 From: Tom Tromey To: Simen =?utf-8?Q?Heggest=C3=B8yl?= Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <1487359774.1998.0@smtp.gmail.com> <1488653191.6153.0@smtp.gmail.com> <1488738524.13864.0@smtp.gmail.com> <871str3b48.fsf@tromey.com> <1490812056.14782.1@smtp.gmail.com> X-Attribution: Tom Date: Thu, 20 Apr 2017 21:40:46 -0600 In-Reply-To: <1490812056.14782.1@smtp.gmail.com> ("Simen \=\?utf-8\?Q\?Heggest\?\= \=\?utf-8\?Q\?\=C3\=B8yl\=22's\?\= message of "Wed, 29 Mar 2017 20:27:36 +0200") Message-ID: <874lxi5sxt.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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 - debbugs.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: 75.166.40.121 X-Exim-ID: 1d1PRA-0005HP-PD X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-40-121.hlrn.qwest.net (bapiya) [75.166.40.121]:54256 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Tom Tromey X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >>>>> "Simen" =3D=3D Simen Heggest=C3=B8yl writes: Sorry about the delay on this. I've been busy with other things. Simen> Hm, I'm still seeing it here with the patch from March 4. Maybe Simen> that one is outdated? I wouldn't think so, but I'm attaching a rolled-up patch here. Simen> I think the names of mixins and placeholders are most important, bec= ause Simen> it's not unlikely for them to have colors for names. Examples of usa= ge: Ok, I can easily exclude @mixin and @extend. Simen> There's also maps, but I think they're less important if it's hard to Simen> solve: Simen> $foo: (bar: 1, black: 2); I'm not sure there's a good way to distinguish these. Let me know what you think. I appreciate you taking the time to try this out. FWIW I've been using this in my work. It works with mhtml-mode, so I've been seeing colors show up in Firefox mochitests... fun! Tom --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=P Content-Description: latest patch commit 44c67a067d7759fb15af032416bce51714bb12eb Author: Tom Tromey Date: Wed Jan 25 00:53:49 2017 -0700 Add color highlighting to css-mode * lisp/textmodes/css-mode.el (css--color-map): New constant. (css-value-class-alist): Use css--color-map. (css--number-regexp, css--percent-regexp) (css--number-or-percent-regexp, css--angle-regexp): New constants. (css--color-skip-blanks, css--rgb-color, css--hsl-color): New functions. (css--colors-regexp): New constant. (css--hex-color, css--named-color, css--compute-color) (css--contrasty-color, css--fontify-colors) (css--fontify-region): New functions. (css-mode): Set font-lock-fontify-region-function. (css-mode-syntax-table): Set syntax on more characters. (css-fontify-colors): New defcustom. * test/lisp/textmodes/css-mode-tests.el (css-test-property-values): Update. (css-test-rgb-parser, css-test-hsl-parser) (css-test-named-color): New tests. * etc/NEWS: Add entry. diff --git a/etc/NEWS b/etc/NEWS index 7281827..2b0841d 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -719,6 +719,11 @@ pseudo-element, with the default being guessed from context). By default the information is looked up on the Mozilla Developer Network, but this can be customized using 'css-lookup-url-format'. +--- +*** CSS colors are fontified using the color they represent as the +background. For instance, #ff0000 would be fontified with a red +background. + +++ ** Emacs now supports character name escape sequences in character and string literals. The syntax variants \N{character name} and diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index d4a5cfe..89c7cb9 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -33,6 +33,8 @@ ;;; Code: (require 'eww) +(require 'cl-lib) +(require 'color) (require 'seq) (require 'sgml-mode) (require 'smie) @@ -487,8 +489,157 @@ css-property-ids (mapcar #'car css-property-alist) "Identifiers for properties.") +(defconst css--color-map + '(("black" . "#000000") + ("silver" . "#c0c0c0") + ("gray" . "#808080") + ("white" . "#ffffff") + ("maroon" . "#800000") + ("red" . "#ff0000") + ("purple" . "#800080") + ("fuchsia" . "#ff00ff") + ("green" . "#008000") + ("lime" . "#00ff00") + ("olive" . "#808000") + ("yellow" . "#ffff00") + ("navy" . "#000080") + ("blue" . "#0000ff") + ("teal" . "#008080") + ("aqua" . "#00ffff") + ("orange" . "#ffa500") + ("aliceblue" . "#f0f8ff") + ("antiquewhite" . "#faebd7") + ("aquamarine" . "#7fffd4") + ("azure" . "#f0ffff") + ("beige" . "#f5f5dc") + ("bisque" . "#ffe4c4") + ("blanchedalmond" . "#ffebcd") + ("blueviolet" . "#8a2be2") + ("brown" . "#a52a2a") + ("burlywood" . "#deb887") + ("cadetblue" . "#5f9ea0") + ("chartreuse" . "#7fff00") + ("chocolate" . "#d2691e") + ("coral" . "#ff7f50") + ("cornflowerblue" . "#6495ed") + ("cornsilk" . "#fff8dc") + ("crimson" . "#dc143c") + ("darkblue" . "#00008b") + ("darkcyan" . "#008b8b") + ("darkgoldenrod" . "#b8860b") + ("darkgray" . "#a9a9a9") + ("darkgreen" . "#006400") + ("darkgrey" . "#a9a9a9") + ("darkkhaki" . "#bdb76b") + ("darkmagenta" . "#8b008b") + ("darkolivegreen" . "#556b2f") + ("darkorange" . "#ff8c00") + ("darkorchid" . "#9932cc") + ("darkred" . "#8b0000") + ("darksalmon" . "#e9967a") + ("darkseagreen" . "#8fbc8f") + ("darkslateblue" . "#483d8b") + ("darkslategray" . "#2f4f4f") + ("darkslategrey" . "#2f4f4f") + ("darkturquoise" . "#00ced1") + ("darkviolet" . "#9400d3") + ("deeppink" . "#ff1493") + ("deepskyblue" . "#00bfff") + ("dimgray" . "#696969") + ("dimgrey" . "#696969") + ("dodgerblue" . "#1e90ff") + ("firebrick" . "#b22222") + ("floralwhite" . "#fffaf0") + ("forestgreen" . "#228b22") + ("gainsboro" . "#dcdcdc") + ("ghostwhite" . "#f8f8ff") + ("gold" . "#ffd700") + ("goldenrod" . "#daa520") + ("greenyellow" . "#adff2f") + ("grey" . "#808080") + ("honeydew" . "#f0fff0") + ("hotpink" . "#ff69b4") + ("indianred" . "#cd5c5c") + ("indigo" . "#4b0082") + ("ivory" . "#fffff0") + ("khaki" . "#f0e68c") + ("lavender" . "#e6e6fa") + ("lavenderblush" . "#fff0f5") + ("lawngreen" . "#7cfc00") + ("lemonchiffon" . "#fffacd") + ("lightblue" . "#add8e6") + ("lightcoral" . "#f08080") + ("lightcyan" . "#e0ffff") + ("lightgoldenrodyellow" . "#fafad2") + ("lightgray" . "#d3d3d3") + ("lightgreen" . "#90ee90") + ("lightgrey" . "#d3d3d3") + ("lightpink" . "#ffb6c1") + ("lightsalmon" . "#ffa07a") + ("lightseagreen" . "#20b2aa") + ("lightskyblue" . "#87cefa") + ("lightslategray" . "#778899") + ("lightslategrey" . "#778899") + ("lightsteelblue" . "#b0c4de") + ("lightyellow" . "#ffffe0") + ("limegreen" . "#32cd32") + ("linen" . "#faf0e6") + ("mediumaquamarine" . "#66cdaa") + ("mediumblue" . "#0000cd") + ("mediumorchid" . "#ba55d3") + ("mediumpurple" . "#9370db") + ("mediumseagreen" . "#3cb371") + ("mediumslateblue" . "#7b68ee") + ("mediumspringgreen" . "#00fa9a") + ("mediumturquoise" . "#48d1cc") + ("mediumvioletred" . "#c71585") + ("midnightblue" . "#191970") + ("mintcream" . "#f5fffa") + ("mistyrose" . "#ffe4e1") + ("moccasin" . "#ffe4b5") + ("navajowhite" . "#ffdead") + ("oldlace" . "#fdf5e6") + ("olivedrab" . "#6b8e23") + ("orangered" . "#ff4500") + ("orchid" . "#da70d6") + ("palegoldenrod" . "#eee8aa") + ("palegreen" . "#98fb98") + ("paleturquoise" . "#afeeee") + ("palevioletred" . "#db7093") + ("papayawhip" . "#ffefd5") + ("peachpuff" . "#ffdab9") + ("peru" . "#cd853f") + ("pink" . "#ffc0cb") + ("plum" . "#dda0dd") + ("powderblue" . "#b0e0e6") + ("rosybrown" . "#bc8f8f") + ("royalblue" . "#4169e1") + ("saddlebrown" . "#8b4513") + ("salmon" . "#fa8072") + ("sandybrown" . "#f4a460") + ("seagreen" . "#2e8b57") + ("seashell" . "#fff5ee") + ("sienna" . "#a0522d") + ("skyblue" . "#87ceeb") + ("slateblue" . "#6a5acd") + ("slategray" . "#708090") + ("slategrey" . "#708090") + ("snow" . "#fffafa") + ("springgreen" . "#00ff7f") + ("steelblue" . "#4682b4") + ("tan" . "#d2b48c") + ("thistle" . "#d8bfd8") + ("tomato" . "#ff6347") + ("turquoise" . "#40e0d0") + ("violet" . "#ee82ee") + ("wheat" . "#f5deb3") + ("whitesmoke" . "#f5f5f5") + ("yellowgreen" . "#9acd32") + ("rebeccapurple" . "#663399")) + "Map CSS named colors to their hex RGB value.") + (defconst css-value-class-alist - '((absolute-size + `((absolute-size "xx-small" "x-small" "small" "medium" "large" "x-large" "xx-large") (alphavalue number) @@ -550,36 +701,7 @@ css-value-class-alist (line-width length "thin" "medium" "thick") (linear-gradient "linear-gradient()") (margin-width "auto" length percentage) - (named-color - "aliceblue" "antiquewhite" "aqua" "aquamarine" "azure" "beige" - "bisque" "black" "blanchedalmond" "blue" "blueviolet" "brown" - "burlywood" "cadetblue" "chartreuse" "chocolate" "coral" - "cornflowerblue" "cornsilk" "crimson" "cyan" "darkblue" - "darkcyan" "darkgoldenrod" "darkgray" "darkgreen" "darkkhaki" - "darkmagenta" "darkolivegreen" "darkorange" "darkorchid" - "darkred" "darksalmon" "darkseagreen" "darkslateblue" - "darkslategray" "darkturquoise" "darkviolet" "deeppink" - "deepskyblue" "dimgray" "dodgerblue" "firebrick" "floralwhite" - "forestgreen" "fuchsia" "gainsboro" "ghostwhite" "gold" - "goldenrod" "gray" "green" "greenyellow" "honeydew" "hotpink" - "indianred" "indigo" "ivory" "khaki" "lavender" "lavenderblush" - "lawngreen" "lemonchiffon" "lightblue" "lightcoral" "lightcyan" - "lightgoldenrodyellow" "lightgray" "lightgreen" "lightpink" - "lightsalmon" "lightseagreen" "lightskyblue" "lightslategray" - "lightsteelblue" "lightyellow" "lime" "limegreen" "linen" - "magenta" "maroon" "mediumaquamarine" "mediumblue" "mediumorchid" - "mediumpurple" "mediumseagreen" "mediumslateblue" - "mediumspringgreen" "mediumturquoise" "mediumvioletred" - "midnightblue" "mintcream" "mistyrose" "moccasin" "navajowhite" - "navy" "oldlace" "olive" "olivedrab" "orange" "orangered" - "orchid" "palegoldenrod" "palegreen" "paleturquoise" - "palevioletred" "papayawhip" "peachpuff" "peru" "pink" "plum" - "powderblue" "purple" "rebeccapurple" "red" "rosybrown" - "royalblue" "saddlebrown" "salmon" "sandybrown" "seagreen" - "seashell" "sienna" "silver" "skyblue" "slateblue" "slategray" - "snow" "springgreen" "steelblue" "tan" "teal" "thistle" "tomato" - "turquoise" "violet" "wheat" "white" "whitesmoke" "yellow" - "yellowgreen") + (named-color . ,(mapcar #'car css--color-map)) (number "calc()") (numeric-figure-values "lining-nums" "oldstyle-nums") (numeric-fraction-values "diagonal-fractions" "stacked-fractions") @@ -663,11 +785,23 @@ css-mode-syntax-table (modify-syntax-entry ?\[ "(]" st) (modify-syntax-entry ?\] ")[" st) ;; Special chars that sometimes come at the beginning of words. - (modify-syntax-entry ?@ "'" st) - ;; (modify-syntax-entry ?: "'" st) - (modify-syntax-entry ?# "'" st) + ;; We'll treat them as symbol constituents. + (modify-syntax-entry ?@ "_" st) + (modify-syntax-entry ?# "_" st) + (modify-syntax-entry ?. "_" st) ;; Distinction between words and symbols. (modify-syntax-entry ?- "_" st) + + (modify-syntax-entry ?! "." st) + (modify-syntax-entry ?$ "." st) + (modify-syntax-entry ?% "." st) + (modify-syntax-entry ?& "." st) + (modify-syntax-entry ?+ "." st) + (modify-syntax-entry ?, "." st) + (modify-syntax-entry ?< "." st) + (modify-syntax-entry ?> "." st) + (modify-syntax-entry ?= "." st) + (modify-syntax-entry ?? "." st) st)) (defvar css-mode-map @@ -782,6 +916,218 @@ css-font-lock-keywords (defvar css-font-lock-defaults '(css-font-lock-keywords nil t)) +(defconst css--number-regexp + "\\(\\(?:[0-9]*\\.[0-9]+\\(?:[eE][0-9]+\\)?\\)\\|[0-9]+\\)" + "A regular expression matching a CSS number.") + +(defconst css--percent-regexp "\\([0-9]+\\)%" + "A regular expression matching a CSS percentage.") + +(defconst css--number-or-percent-regexp + (concat "\\(?:" css--percent-regexp "\\)\\|\\(?:" css--number-regexp "\\)") + "A regular expression matching a CSS number or a CSS percentage.") + +(defconst css--angle-regexp + (concat css--number-regexp + (regexp-opt '("deg" "grad" "rad" "turn") t) + "?") + "A regular expression matching a CSS angle.") + +(defun css--color-skip-blanks () + "Skip blanks and comments." + (while (forward-comment 1))) + +(cl-defun css--rgb-color () + "Parse a CSS rgb() or rgba() color. +Point should be just after the open paren. +Returns a hex RGB color, or nil if the color could not be recognized. +This recognizes CSS-color-4 extensions." + (let ((result '()) + (iter 0)) + (while (< iter 4) + (css--color-skip-blanks) + (unless (looking-at css--number-or-percent-regexp) + (cl-return-from css--rgb-color nil)) + (let* ((is-percent (match-beginning 1)) + (str (match-string (if is-percent 1 2))) + (number (string-to-number str))) + (when is-percent + (setq number (* 255 (/ number 100.0)))) + ;; Don't push the alpha. + (when (< iter 3) + (push (min (max 0 (truncate number)) 255) result)) + (goto-char (match-end 0)) + (css--color-skip-blanks) + (cl-incf iter) + ;; Accept a superset of the CSS syntax since I'm feeling lazy. + (when (and (= (skip-chars-forward ",/") 0) + (= iter 3)) + ;; The alpha is optional. + (cl-incf iter)) + (css--color-skip-blanks))) + (when (looking-at ")") + (forward-char) + (apply #'format "#%02x%02x%02x" (nreverse result))))) + +(cl-defun css--hsl-color () + "Parse a CSS hsl() or hsla() color. +Point should be just after the open paren. +Returns a hex RGB color, or nil if the color could not be recognized. +This recognizes CSS-color-4 extensions." + (let ((result '())) + ;; First parse the hue. + (css--color-skip-blanks) + (unless (looking-at css--angle-regexp) + (cl-return-from css--hsl-color nil)) + (let ((hue (string-to-number (match-string 1))) + (unit (match-string 2))) + (goto-char (match-end 0)) + ;; Note that here "turn" is just passed through. + (cond + ((or (not unit) (equal unit "deg")) + ;; Degrees. + (setq hue (/ hue 360.0))) + ((equal unit "grad") + (setq hue (/ hue 400.0))) + ((equal unit "rad") + (setq hue (/ hue (* 2 float-pi))))) + (push (mod hue 1.0) result)) + (dotimes (_ 2) + (skip-chars-forward ",") + (css--color-skip-blanks) + (unless (looking-at css--percent-regexp) + (cl-return-from css--hsl-color nil)) + (let ((number (string-to-number (match-string 1)))) + (setq number (/ number 100.0)) + (push (min (max number 0.0) 1.0) result) + (goto-char (match-end 0)) + (css--color-skip-blanks))) + (css--color-skip-blanks) + ;; Accept a superset of the CSS syntax since I'm feeling lazy. + (when (> (skip-chars-forward ",/") 0) + (css--color-skip-blanks) + (unless (looking-at css--number-or-percent-regexp) + (cl-return-from css--hsl-color nil)) + (goto-char (match-end 0)) + (css--color-skip-blanks)) + (when (looking-at ")") + (forward-char) + (apply #'color-rgb-to-hex + (nconc (apply #'color-hsl-to-rgb (nreverse result)) '(2)))))) + +(defconst css--colors-regexp + (concat + ;; Named colors. + (regexp-opt (mapcar #'car css--color-map) 'symbols) + "\\|" + ;; Short hex. css-color-4 adds alpha. + "\\(#[0-9a-fA-F]\\{3,4\\}\\b\\)" + "\\|" + ;; Long hex. css-color-4 adds alpha. + "\\(#\\(?:[0-9a-fA-F][0-9a-fA-F]\\)\\{3,4\\}\\b\\)" + "\\|" + ;; RGB. + "\\(\\_ (length str) 4) + (substring str 0 7) + (substring str 0 4))) + +(defun css--named-color (str) + "Check whether STR, seen at point, is CSS named color. +Returns STR if it is a valid color. Special care is taken +to exclude some SCSS contructs." + (when-let ((color (assoc str css--color-map))) + (save-excursion + ;; We still have the match from the caller of + ;; css--compute-color. + (goto-char (match-beginning 0)) + (forward-comment (- (point))) + (skip-chars-backward "@[:alpha:]") + (unless (looking-at-p "@\\(mixin\\|include\\)") + (cdr color))))) + +(defun css--compute-color () + "Return the CSS color at point. +Point should be just after the start of a CSS color, as recognized +by `css--colors-regexp'. This function will either return the color, +as a hex RGB string; or `nil' if no color could be recognized. When +this function returns, point will be at the end of the recognized +color." + (let ((match (downcase (match-string 0)))) + (cond + ((eq (aref match 0) ?#) + (css--hex-color match)) + ((member match '("rgb(" "rgba(")) + (css--rgb-color)) + ((member match '("hsl(" "hsla(")) + (css--hsl-color)) + ;; Evaluate to the color if the name is found. + ((css--named-color match))))) + +(defun css--contrasty-color (name) + "Return a color that contrasts with NAME. +NAME is of any form accepted by `color-distance'. +The returned color will be usable by Emacs and will contrast +with NAME; in particular so that if NAME is used as a background +color, the returned color can be used as the foreground and still +be readable." + ;; See bug#25525 for a discussion of this. + (if (> (color-distance name "black") 292485) + "black" "white")) + +(defcustom css-fontify-colors t + "Whether CSS colors should be fontified using the color as the background. +When non-`nil', a text representing CSS color will be fontified +such that its background is the color itself. E.g., #ff0000 will +be fontified with a red background." + :version "26.1" + :group 'css + :type 'boolean + :safe 'booleanp) + +(defun css--fontify-region (start end &optional loudly) + "Fontify a CSS buffer between START and END. +START and END are buffer positions." + (let ((extended-region (font-lock-default-fontify-region start end loudly))) + (when css-fontify-colors + (when (and (consp extended-region) + (eq (car extended-region) 'jit-lock-bounds)) + (setq start (cadr extended-region)) + (setq end (cddr extended-region))) + (save-excursion + (let ((case-fold-search t)) + (goto-char start) + (while (re-search-forward css--colors-regexp end t) + ;; Skip comments and strings. + (unless (nth 8 (syntax-ppss)) + (let ((start (match-beginning 0)) + (color (css--compute-color))) + (when color + (with-silent-modifications + ;; Use the color as the background, to make it more + ;; clear. Use a contrasting color as the foreground, + ;; to make it readable. Finally, have a small box + ;; using the existing foreground color, to make sure + ;; it stands out a bit from any other text; in + ;; particular this is nice when the color matches the + ;; buffer's background color. + (add-text-properties + start (point) + (list 'face (list :background color + :foreground (css--contrasty-color color) + :box '(:line-width -1)))))))))))) + extended-region)) + (defcustom css-indent-offset 4 "Basic size of one indentation step." :version "22.2" @@ -1048,6 +1394,7 @@ css-mode :backward-token #'css-smie--backward-token) (setq-local electric-indent-chars (append css-electric-keys electric-indent-chars)) + (setq-local font-lock-fontify-region-function #'css--fontify-region) (add-hook 'completion-at-point-functions #'css-completion-at-point nil 'local)) diff --git a/test/lisp/textmodes/css-mode-tests.el b/test/lisp/textmodes/css-mode-tests.el index d601f43..0e7e945 100644 --- a/test/lisp/textmodes/css-mode-tests.el +++ b/test/lisp/textmodes/css-mode-tests.el @@ -58,7 +58,7 @@ ;; Check that the `color' property doesn't cause infinite recursion ;; because it refers to the value class of the same name. - (should (= (length (css--property-values "color")) 147))) + (should (= (length (css--property-values "color")) 152))) (ert-deftest css-test-property-value-cache () "Test that `css--property-value-cache' is in use." @@ -234,5 +234,48 @@ css-mode-tests--completions (save-excursion (insert (nth 1 item))) (should (equal (nth 2 item) (css--mdn-find-symbol)))))) +(ert-deftest css-test-rgb-parser () + (with-temp-buffer + (css-mode) + (dolist (input '("255, 0, 127" + "255, /* comment */ 0, 127" + "255 0 127" + "255, 0, 127, 0.75" + "255 0 127 / 0.75" + "100%, 0%, 50%" + "100%, 0%, 50%, 0.115" + "100% 0% 50%" + "100% 0% 50% / 0.115")) + (erase-buffer) + (save-excursion + (insert input ")")) + (should (equal (css--rgb-color) "#ff007f"))))) + +(ert-deftest css-test-hsl-parser () + (with-temp-buffer + (css-mode) + (dolist (input '("0, 100%, 50%" + "0 100% 50%" + "0 /* two */ /* comments */100% 50%" + "0, 100%, 50%, 0.75" + "0 100% 50% / 0.75" + "0deg 100% 50%" + "360deg 100% 50%" + "0rad, 100%, 50%, 0.115" + "0grad, 100%, 50%, 0.115" + "1turn 100% 50% / 0.115")) + (erase-buffer) + (save-excursion + (insert input ")")) + (should (equal (css--hsl-color) "#ff0000"))))) + +(ert-deftest css-test-named-color () + (dolist (text '("@mixin black" "@include black")) + (with-temp-buffer + (insert text) + (backward-word) + (should (and (looking-at "black") + (not (css--named-color "black"))))))) + (provide 'css-mode-tests) ;;; css-mode-tests.el ends here --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 21 05:33:49 2017 Received: (at 25525) by debbugs.gnu.org; 21 Apr 2017 09:33:49 +0000 Received: from localhost ([127.0.0.1]:59790 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d1Uwn-0005m7-1t for submit@debbugs.gnu.org; Fri, 21 Apr 2017 05:33:49 -0400 Received: from mail-out.m-online.net ([212.18.0.10]:42174) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d1Uwj-0005lx-O5 for 25525@debbugs.gnu.org; Fri, 21 Apr 2017 05:33:47 -0400 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3w8Vt04fw3z1qsfh; Fri, 21 Apr 2017 11:33:44 +0200 (CEST) Received: from localhost (dynscan01.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 3w8Vt02gSBz3hhtH; Fri, 21 Apr 2017 11:33:44 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan01.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id Bw4y3VTNkYvq; Fri, 21 Apr 2017 11:33:43 +0200 (CEST) X-Auth-Info: 0kbbk9eKY5RKFcSKvxmHP1LQSxO+EdAfTkPSkyewOvGef5PBlSthAFkI/sfl2uOT Received: from igel.home (ppp-88-217-8-198.dynamic.mnet-online.de [88.217.8.198]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Fri, 21 Apr 2017 11:33:43 +0200 (CEST) Received: by igel.home (Postfix, from userid 1000) id 0492F2C3049; Fri, 21 Apr 2017 11:33:42 +0200 (CEST) From: Andreas Schwab To: Tom Tromey Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <1487359774.1998.0@smtp.gmail.com> <1488653191.6153.0@smtp.gmail.com> <1488738524.13864.0@smtp.gmail.com> <871str3b48.fsf@tromey.com> <1490812056.14782.1@smtp.gmail.com> <874lxi5sxt.fsf@tromey.com> X-Yow: ... I live in a FUR-LINE FALLOUT SHELTER Date: Fri, 21 Apr 2017 11:33:42 +0200 In-Reply-To: <874lxi5sxt.fsf@tromey.com> (Tom Tromey's message of "Thu, 20 Apr 2017 21:40:46 -0600") Message-ID: <871ssmyuix.fsf@linux-m68k.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Simen =?utf-8?Q?Heggest=C3=B8yl?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On Apr 20 2017, Tom Tromey wrote: > +(defun css--named-color (str) > + "Check whether STR, seen at point, is CSS named color. > +Returns STR if it is a valid color. Special care is taken > +to exclude some SCSS contructs." > + (when-let ((color (assoc str css--color-map))) > + (save-excursion > + ;; We still have the match from the caller of > + ;; css--compute-color. > + (goto-char (match-beginning 0)) > + (forward-comment (- (point))) > + (skip-chars-backward "@[:alpha:]") > + (unless (looking-at-p "@\\(mixin\\|include\\)") > + (cdr color))))) > + > +(defun css--compute-color () > + "Return the CSS color at point. > +Point should be just after the start of a CSS color, as recognized > +by `css--colors-regexp'. This function will either return the color, > +as a hex RGB string; or `nil' if no color could be recognized. When > +this function returns, point will be at the end of the recognized > +color." > + (let ((match (downcase (match-string 0)))) > + (cond > + ((eq (aref match 0) ?#) > + (css--hex-color match)) > + ((member match '("rgb(" "rgba(")) > + (css--rgb-color)) > + ((member match '("hsl(" "hsla(")) > + (css--hsl-color)) > + ;; Evaluate to the color if the name is found. > + ((css--named-color match))))) It would be better to pass the match string as an argument instead of depending on the caller to establish a match. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 21 20:44:17 2017 Received: (at 25525) by debbugs.gnu.org; 22 Apr 2017 00:44:17 +0000 Received: from localhost ([127.0.0.1]:33071 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d1j9s-0007vx-Se for submit@debbugs.gnu.org; Fri, 21 Apr 2017 20:44:17 -0400 Received: from gproxy10-pub.mail.unifiedlayer.com ([69.89.20.226]:60168 helo=gproxy10.mail.unifiedlayer.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d1j9p-0007vh-HZ for 25525@debbugs.gnu.org; Fri, 21 Apr 2017 20:44:14 -0400 Received: from cmgw3 (unknown [10.0.90.84]) by gproxy10.mail.unifiedlayer.com (Postfix) with ESMTP id 97C931405E6 for <25525@debbugs.gnu.org>; Fri, 21 Apr 2017 18:44:06 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id BCk31v0092f2jeq01Ck6Vs; Fri, 21 Apr 2017 18:44:06 -0600 X-Authority-Analysis: v=2.2 cv=VKStp5HX c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=AzvcPWV-tVgA:10 a=_JnN_Zv1Z0gK-jCpxKgA:9 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=TJlQ3pxfMD3P9frKlmFdenpwNpI3JpMaUFooaHmFHc4=; b=JVIbqI98lY8sybXVN2es3vghX4 Fa33+GgMnB3ijs+Hd78nso/wiAQdh7azys3qDfEGgaPZq7zUm0zhUUZLfjtV8uT0QTDHJMtcogEy6 b7XjlCXoFplPRI3VDYy6NPYEP; Received: from 75-166-63-71.hlrn.qwest.net ([75.166.63.71]:58556 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1d1j9e-00045w-Sp; Fri, 21 Apr 2017 18:44:02 -0600 From: Tom Tromey To: Andreas Schwab Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <1487359774.1998.0@smtp.gmail.com> <1488653191.6153.0@smtp.gmail.com> <1488738524.13864.0@smtp.gmail.com> <871str3b48.fsf@tromey.com> <1490812056.14782.1@smtp.gmail.com> <874lxi5sxt.fsf@tromey.com> <871ssmyuix.fsf@linux-m68k.org> X-Attribution: Tom Date: Fri, 21 Apr 2017 18:44:01 -0600 In-Reply-To: <871ssmyuix.fsf@linux-m68k.org> (Andreas Schwab's message of "Fri, 21 Apr 2017 11:33:42 +0200") Message-ID: <87vapx46ge.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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 - debbugs.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: 75.166.63.71 X-Exim-ID: 1d1j9e-00045w-Sp X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-63-71.hlrn.qwest.net (bapiya) [75.166.63.71]:58556 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Tom Tromey , Simen =?utf-8?Q?Heggest=C3=B8yl?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Andreas> It would be better to pass the match string as an argument instead of Andreas> depending on the caller to establish a match. Yes, thanks. I made this change. Tom From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 22 11:07:57 2017 Received: (at 25525) by debbugs.gnu.org; 22 Apr 2017 15:07:57 +0000 Received: from localhost ([127.0.0.1]:34569 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d1wdh-0006Ga-IW for submit@debbugs.gnu.org; Sat, 22 Apr 2017 11:07:57 -0400 Received: from mail-lf0-f49.google.com ([209.85.215.49]:33045) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d1wdf-0006GO-Qz for 25525@debbugs.gnu.org; Sat, 22 Apr 2017 11:07:56 -0400 Received: by mail-lf0-f49.google.com with SMTP id 88so56584965lfr.0 for <25525@debbugs.gnu.org>; Sat, 22 Apr 2017 08:07:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:message-id:in-reply-to:references :mime-version; bh=RZvW97tX4BWf6GVjpiBWI8HcHN2sy8lghyDRiucpZvs=; b=fMEcgxKqmrIi8CYOGTLRU2DejC5Lfk0xXUx1WJmpBtWRlN/ocpvCRUcwrwVl+XfROp 5iD6G0EKWTkdDjVt4hGHCRHw8+YlHHPv3cOVaxrxHO6+Fexmwyu9HLSO8j/mrV0YqmRT Ung7mpmY/N3TD4Qsg4uADeHEuEek9rf7x+jwJs67Puvv7FdJ75Ibn/6mlX40tv2HqM6e hSj8Jbr8ST6fIPYimO12m9uvAF3uPyTtzhysGoIOYa2kXne5+poyT+aV4GwuZqX9s+nn OY+kecTU3YArwxwoMItC+1/oHbOSxtoR7lFXJkyLqqrTPyEHX6DUK/N38p/lIMacLDcE YjUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to :references:mime-version; bh=RZvW97tX4BWf6GVjpiBWI8HcHN2sy8lghyDRiucpZvs=; b=ionyjGoM6AbPUd6aYKd2uSkRJTA+uESvJs5BvjPH+Dw1vzj43Sq4FQ2CRTLzL5A4i8 UPhrf3EYpZ6c32ZggKK0b52cfGG+XIwUduYchbLSAf/S01pjxFiKDlJRMbsZd9qmr9TS 34IxvF4IavZnlYSHb9uDmSEdlrfzM2RpSwR8hcCfX8HhDw8MA4NKjyIcp1U65EufJ/Nb 2SMrGA0ihg7s9nFqigoWdpAcxLTQCcO31kTFxr1dn72yAdMOF5vOCtA6zBCe+IyLeeId ZcOp7D23XEiQhR/HogLogHkhi1j6ksAq04mOrpDsZykNgZR+Ty/vbEJDgVEVhJtbBOXD rObw== X-Gm-Message-State: AN3rC/7iE5w+s/iwBoqvgFZTk7D31U1IqO+jeIG9uwVxKkFrC5wU65Uz anZM/8w+LQS/vaM7 X-Received: by 10.46.71.193 with SMTP id u184mr6485290lja.16.1492873668901; Sat, 22 Apr 2017 08:07:48 -0700 (PDT) Received: from [192.168.100.12] (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id p188sm2190883lfe.11.2017.04.22.08.07.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 22 Apr 2017 08:07:48 -0700 (PDT) Date: Sat, 22 Apr 2017 17:07:45 +0200 From: Simen =?iso-8859-1?q?Heggest=F8yl?= Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode To: Tom Tromey Message-Id: <1492873665.3376.0@smtp.gmail.com> In-Reply-To: <874lxi5sxt.fsf@tromey.com> References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <1487359774.1998.0@smtp.gmail.com> <1488653191.6153.0@smtp.gmail.com> <1488738524.13864.0@smtp.gmail.com> <871str3b48.fsf@tromey.com> <1490812056.14782.1@smtp.gmail.com> <"Simen \=\?utf-8\?Q\?Heggest\?\= \=\?utf-8\?Q\?\=C3\=B8yl\=22's\?\= message of "Wed, 29 Mar 2017 20:27:36 +0200"> X-Mailer: geary/0.11.3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) Hi Tom, thanks for this update. On Fri, Apr 21, 2017 at 5:40 AM, Tom Tromey wrote: > Sorry about the delay on this. I've been busy with other things. No problem. > Let me know what you think. I appreciate you taking the time to try > this out. I think it's starting to look very good (I hope you're not getting discouraged by my nitpickery). The problem with SCSS variable names remains for me, even with the newest patch. See the following image: http://folk.uio.no/simenheg/tmp/screenshot-2017-04-22-16-53-25.png. Are you able to reproduce it? I think that's the last important problem to fix before we land this. > FWIW I've been using this in my work. It works with mhtml-mode, so > I've > been seeing colors show up in Firefox mochitests... fun! Cool! I'm looking forward to getting this in. -- Simen From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 24 09:54:31 2017 Received: (at 25525) by debbugs.gnu.org; 24 Apr 2017 13:54:32 +0000 Received: from localhost ([127.0.0.1]:37245 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d2eRj-0007bg-N4 for submit@debbugs.gnu.org; Mon, 24 Apr 2017 09:54:31 -0400 Received: from gproxy1-pub.mail.unifiedlayer.com ([69.89.25.95]:44472 helo=outbound-ss-1812.hostmonster.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d2eRi-0007bR-23 for 25525@debbugs.gnu.org; Mon, 24 Apr 2017 09:54:30 -0400 Received: from CMOut01 (cmgw2 [10.0.90.82]) by gproxy1.mail.unifiedlayer.com (Postfix) with ESMTP id 4973A176937 for <25525@debbugs.gnu.org>; Mon, 24 Apr 2017 07:44:29 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id CDkR1v00m2f2jeq01DkUtw; Mon, 24 Apr 2017 07:44:29 -0600 X-Authority-Analysis: v=2.2 cv=K+5SJ2eI c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=AzvcPWV-tVgA:10 a=ba5hEkx7Gv2z-6J-xf8A:9 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=lWEICTlxl9eoqz5t0q23wsPbOQ6GkhLYY9J1Cchp1Q0=; b=rnQC54ZerlptjS1n4AYNP4QikS W9boUmFIMB/4WcvLtPkIDtsZJLhvnEKBZFWtTgcqSczr3rIvvK6WXpjSqW0RKsrj1y9dZ+zG9Rs5C 9nHncSEp9hcgKHBMrM7WaUU/L; Received: from 75-166-63-71.hlrn.qwest.net ([75.166.63.71]:38720 helo=pokyo) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1d2eHx-0008WI-Kz; Mon, 24 Apr 2017 07:44:25 -0600 From: Tom Tromey To: Simen =?utf-8?Q?Heggest=C3=B8yl?= Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <1487359774.1998.0@smtp.gmail.com> <1488653191.6153.0@smtp.gmail.com> <1488738524.13864.0@smtp.gmail.com> <871str3b48.fsf@tromey.com> <1490812056.14782.1@smtp.gmail.com> <1492873665.3376.0@smtp.gmail.com> X-Attribution: Tom Date: Mon, 24 Apr 2017 07:44:21 -0600 In-Reply-To: <1492873665.3376.0@smtp.gmail.com> ("Simen \=\?utf-8\?Q\?Heggest\?\= \=\?utf-8\?Q\?\=C3\=B8yl\=22's\?\= message of "Sat, 22 Apr 2017 17:07:45 +0200") Message-ID: <87lgqpyl6y.fsf@pokyo> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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 - debbugs.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: 75.166.63.71 X-Exim-ID: 1d2eHx-0008WI-Kz X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-63-71.hlrn.qwest.net (pokyo) [75.166.63.71]:38720 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Tom Tromey X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.8 (--) Simen> Are you able to reproduce it? I think that's the last important Simen> problem to fix before we land this. I finally was, I will look into it soon. Thanks again. Tom From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 29 00:17:52 2017 Received: (at 25525) by debbugs.gnu.org; 29 Apr 2017 04:17:52 +0000 Received: from localhost ([127.0.0.1]:45362 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d4JpQ-00028b-1I for submit@debbugs.gnu.org; Sat, 29 Apr 2017 00:17:52 -0400 Received: from gproxy7-pub.mail.unifiedlayer.com ([70.40.196.235]:54997) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1d4JpN-00028K-T7 for 25525@debbugs.gnu.org; Sat, 29 Apr 2017 00:17:50 -0400 Received: (qmail 20952 invoked by uid 0); 29 Apr 2017 04:17:38 -0000 Received: from unknown (HELO cmgw2) (10.0.90.83) by gproxy7.mail.unifiedlayer.com with SMTP; 29 Apr 2017 04:17:38 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id E4Ha1v00H2f2jeq014HdHS; Fri, 28 Apr 2017 22:17:38 -0600 X-Authority-Analysis: v=2.2 cv=Ibz3YSia c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=AzvcPWV-tVgA:10 a=AZ1AqLNKeXhY4gl7ilYA:9 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=IX6G6vXW+AwpxDZ8+SYmhvYWlcUD7dqRuDvAMb5M06M=; b=A/t8G4WlpLJbGsuYIiLQnD5hB/ v6O2b7kWAt7pJg+U5vbeStMw1vUSbxd4FIK0UbPxb/SCdF0MMeDYZLfTqx7iuvJ/cGzevPUHH8TUq wkHhUS8zoEZngHYYGRgOf82GG; Received: from 75-166-63-71.hlrn.qwest.net ([75.166.63.71]:58166 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1d4Jp8-0002w0-Me; Fri, 28 Apr 2017 22:17:34 -0600 From: Tom Tromey To: Tom Tromey Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <1487359774.1998.0@smtp.gmail.com> <1488653191.6153.0@smtp.gmail.com> <1488738524.13864.0@smtp.gmail.com> <871str3b48.fsf@tromey.com> <1490812056.14782.1@smtp.gmail.com> <1492873665.3376.0@smtp.gmail.com> <87lgqpyl6y.fsf@pokyo> X-Attribution: Tom Date: Fri, 28 Apr 2017 22:17:33 -0600 In-Reply-To: <87lgqpyl6y.fsf@pokyo> (Tom Tromey's message of "Mon, 24 Apr 2017 07:44:21 -0600") Message-ID: <87vapn3l0i.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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 - debbugs.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: 75.166.63.71 X-Exim-ID: 1d4Jp8-0002w0-Me X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-63-71.hlrn.qwest.net (bapiya) [75.166.63.71]:58166 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Simen =?utf-8?Q?Heggest=C3=B8yl?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Tom> I finally was, I will look into it soon. Thanks again. This patch on top of my current patch was enough. However I'm not sure it is the best way. It does pass the css mode tests, but I'm also not sure that is sufficient. Could you try it out? Tom diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 9584bd2..2c81710 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1506,7 +1506,8 @@ scss-mode-syntax-table (modify-syntax-entry ?/ ". 124" st) (modify-syntax-entry ?\n ">" st) ;; Variable names are prefixed by $. - (modify-syntax-entry ?$ "'" st) + (modify-syntax-entry ?$ "_" st) + (modify-syntax-entry ?% "_" st) st)) (defun scss-font-lock-keywords () From debbugs-submit-bounces@debbugs.gnu.org Mon May 01 15:15:42 2017 Received: (at 25525) by debbugs.gnu.org; 1 May 2017 19:15:42 +0000 Received: from localhost ([127.0.0.1]:49931 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d5GnN-0001Ba-SX for submit@debbugs.gnu.org; Mon, 01 May 2017 15:15:42 -0400 Received: from mail-lf0-f52.google.com ([209.85.215.52]:34930) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d5GnM-0001BM-EU for 25525@debbugs.gnu.org; Mon, 01 May 2017 15:15:40 -0400 Received: by mail-lf0-f52.google.com with SMTP id 75so64286621lfs.2 for <25525@debbugs.gnu.org>; Mon, 01 May 2017 12:15:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:message-id:in-reply-to:references :mime-version; bh=lSYv31zd4PgGHRZcAlUjghsLHZmw6sx5qJaiI4DGCIg=; b=fyTpeEiyOz9ubw629UNLZ0ln3/bBtsZl6LOOL98V6LT/a1V2gN5W+HCZTUHNBpk3jK J3aOyE/zFOhQ9HIvB1c7C3vQfcuwwgw6jkTlVUjgCl+02T/IeteDyDMsEghS/XQeKHcP OZqd0+nIVNT3nb1Gvlb/8+aFZdEAQEXS2TJ3qcWiWPCSMTpjBYXhRh7rvItKRXJGhQ1i sSiJQSoAX/fg0ymr3Om77x68Z8yOFJiBoEXZBJv9U3kuE3hP86RR9fO+YIajcLYhOSYq Yn0jqJg7vM8d2mGFt4ZUkBz/bcNy7A9Yw/4U3ETQFYKaF3yvm/DMriFZdXkCufYpTa+L 0spQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to :references:mime-version; bh=lSYv31zd4PgGHRZcAlUjghsLHZmw6sx5qJaiI4DGCIg=; b=H23VE2VQT9voO82/PLsjpUt5N6dqBB0JaJXNHcv7ci+ZMJOB+N9LBmKW7PapN+vEA+ Zx/PCRUvkTzFbDnrF3pUvgp+2ReQ2zPdP8c7wdvUQm8r1GuKm5nxsgBCsZSUJa8VhfXN JeR5a1SgRVhwJoElIcTRdDmSL7dKLIjhhTjI3GEdw0c+5+nExnN4XDdDZInWMMgT8yB9 j+VBB2ol9/EBZ8qLBelPpB945q680s3A0xnXviejppEhWBsARRLBFrLyZgbty4LMFJ5c 7wY4TS2yePBFs4/NdWQ2iWpN3Oo11iKPbnMDyG8T3XzQMtnw5g3Jczx2psQrzU3YYQdk RQ7Q== X-Gm-Message-State: AN3rC/4ZrAS77CXDAwExjpfk4HKpYEwNkfAocUoo+pQ1/BONlPvXpFHb yhTRBramdvBimPhq X-Received: by 10.46.20.7 with SMTP id u7mr8626209ljd.66.1493666134161; Mon, 01 May 2017 12:15:34 -0700 (PDT) Received: from [192.168.100.12] (cm-84.210.143.4.getinternet.no. [84.210.143.4]) by smtp.gmail.com with ESMTPSA id b8sm2789349lfg.32.2017.05.01.12.15.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 May 2017 12:15:33 -0700 (PDT) Date: Mon, 01 May 2017 21:15:31 +0200 From: Simen =?iso-8859-1?q?Heggest=F8yl?= Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode To: Tom Tromey Message-Id: <1493666131.1965.0@smtp.gmail.com> In-Reply-To: <87vapn3l0i.fsf@tromey.com> References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <1487359774.1998.0@smtp.gmail.com> <1488653191.6153.0@smtp.gmail.com> <1488738524.13864.0@smtp.gmail.com> <871str3b48.fsf@tromey.com> <1490812056.14782.1@smtp.gmail.com> <1492873665.3376.0@smtp.gmail.com> <87lgqpyl6y.fsf@pokyo> X-Mailer: geary/0.11.3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) On Sat, Apr 29, 2017 at 6:17 AM, Tom Tromey wrote: > Tom> I finally was, I will look into it soon. Thanks again. > > This patch on top of my current patch was enough. However I'm not > sure > it is the best way. It does pass the css mode tests, but I'm also not > sure that is sufficient. Could you try it out? I'm not sure either, but it does seem to fix the issue. I haven't discovered any more issues since last time, so the feature seems good to go as far as I'm concerned! -- Simen From debbugs-submit-bounces@debbugs.gnu.org Mon May 01 17:26:04 2017 Received: (at 25525) by debbugs.gnu.org; 1 May 2017 21:26:04 +0000 Received: from localhost ([127.0.0.1]:50021 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d5IpY-0004BH-Ix for submit@debbugs.gnu.org; Mon, 01 May 2017 17:26:04 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:35781) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d5IpX-0004Ao-1f for 25525@debbugs.gnu.org; Mon, 01 May 2017 17:26:03 -0400 Received: by mail-qk0-f196.google.com with SMTP id u68so3382064qkd.2 for <25525@debbugs.gnu.org>; Mon, 01 May 2017 14:26:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=mhuoLiqCbqsgmA8VFidfB0ywU8ttvmFIWFLw/f5rJ5E=; b=b6YcTSCAow2Gol63S3nAPc6bPHhd+Wo+7IYYFbGlY4U9cPbP/Xth3aAvUUu1XIku5r nC1nxXRStYeZKWU4FBENkRO6E/7d2tSplVJ/hsmfuNzw3Pl8CIgUnU/UjT2kCtfuiMQq 91X074/83h9fPZmNBFQqASlyk9a6SPltvYJXqJsVEek9Ksk6Uf8qCo4hVfgfJfJTRJUG 0SCTa2nqOLrTNx+XB/OMPDjtUkk73k9QiFXuJDq9h7KyCm0I52ID28RXOC39BFeT2lJT 6ZoLANBBXYkhVZQuchMLRX2kK9vIGwU8AatFXF8CGFaHZLoABzBTIjGH6d611XSATS23 10qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=mhuoLiqCbqsgmA8VFidfB0ywU8ttvmFIWFLw/f5rJ5E=; b=RR6ZrkpFbNU8riEaL4Nphnz9FJz2WkqKk3/34NTiKscpLAvoYGJHDr+wqAWCVaiwol 7Odl6XRwA1xfivlmaKe07ljNyCT2xnl3owaIj1bc6+lteikQH2EMPSzG+PkaxPA41nZ4 HLwxrIja3pXPwG0PLbkkTotVEqIHlzp1D2BEJys3gzlpMOEB/pihWXjd5KdKtDYRyiaT ucCcR26zThy0osQk4C7gwDsV8nltrWnihC0thVHSp6IWJMhtl7l1GBT2VredHObh9nmI CjPO8lBMJrr/8C4U0MXvIfnKt5A/SNXjbwXqvWycDtHZdTtbXI0vi8oq/eqTISZ01+hi CR6A== X-Gm-Message-State: AN3rC/6opdTwoXLXdW7mSwJWcjCZzY1J/YPDzhFfe1eY1XSw8tie6Dez 5UiE1AXg5VSrJg== X-Received: by 10.55.204.16 with SMTP id r16mr24770626qki.169.1493673957192; Mon, 01 May 2017 14:25:57 -0700 (PDT) Received: from localhost (modemcable232.49-20-96.mc.videotron.ca. [96.20.49.232]) by smtp.gmail.com with ESMTPSA id n42sm12402246qta.17.2017.05.01.14.25.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 May 2017 14:25:56 -0700 (PDT) From: e.e.f.prudhomme@gmail.com (Etienne =?utf-8?Q?Prud=E2=80=99homme?=) To: Tom Tromey Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <1487359774.1998.0@smtp.gmail.com> <1488653191.6153.0@smtp.gmail.com> <1488738524.13864.0@smtp.gmail.com> <871str3b48.fsf@tromey.com> <1490812056.14782.1@smtp.gmail.com> <1492873665.3376.0@smtp.gmail.com> <87lgqpyl6y.fsf@pokyo> <87vapn3l0i.fsf@tromey.com> Date: Mon, 01 May 2017 17:25:55 -0400 In-Reply-To: <87vapn3l0i.fsf@tromey.com> (Tom Tromey's message of "Fri, 28 Apr 2017 22:17:33 -0600") Message-ID: <87a86wb76k.fsf@x230.lts> User-Agent: Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Simen =?utf-8?Q?Heggest=C3=B8yl?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) Tom Tromey writes: > This patch on top of my current patch was enough. However I'm not sure > it is the best way. It does pass the css mode tests, but I'm also not > sure that is sufficient. Could you try it out? I=E2=80=99ve thought in the pass it would be nicer if we had a real (S)CSS parser. I don=E2=80=99t mean by that a renderer (it would be a completely different project). Instead I mean something that tells us the generated =E2=80=9Ccascade=E2=80=9D. This would give us the ability to fontify (S)CSS color variables with what color they got. We could also fontify color transformations. What do you think? -- Etienne From debbugs-submit-bounces@debbugs.gnu.org Wed May 03 18:04:11 2017 Received: (at 25525) by debbugs.gnu.org; 3 May 2017 22:04:11 +0000 Received: from localhost ([127.0.0.1]:53304 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d62NX-0006c7-9g for submit@debbugs.gnu.org; Wed, 03 May 2017 18:04:11 -0400 Received: from gproxy10-pub.mail.unifiedlayer.com ([69.89.20.226]:48038 helo=gproxy10.mail.unifiedlayer.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d62NV-0006bt-VZ for 25525@debbugs.gnu.org; Wed, 03 May 2017 18:04:10 -0400 Received: from CMOut01 (unknown [10.0.90.82]) by gproxy10.mail.unifiedlayer.com (Postfix) with ESMTP id 34CF0140427 for <25525@debbugs.gnu.org>; Wed, 3 May 2017 16:03:59 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id Fy3t1v00E2f2jeq01y3wSA; Wed, 03 May 2017 16:03:59 -0600 X-Authority-Analysis: v=2.2 cv=K+5SJ2eI c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=IkcTkHD0fZMA:10 a=tJ8p9aeEuA8A:10 a=59rSE4TzPUZg80CgqOcA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To: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=o6VpwznC4fkbsUixlc5DZ5F+/UnYbM5TIuaPxpcu/Qc=; b=BbEdIbzTvSySPR++QKmHR1GJzI +hfWnipwcoMot/qoxyiPbBfeDTNDRb7y89DRBCWoaIJK6Icfl4AHzn07/IFzI4R+6rrLYtAAgPXvQ YeCCjhVpYAxNgFWA+dq3P1wBP; Received: from 75-166-63-71.hlrn.qwest.net ([75.166.63.71]:46440 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1d62NF-0007lR-1N; Wed, 03 May 2017 16:03:53 -0600 From: Tom Tromey To: e.e.f.prudhomme@gmail.com (Etienne =?utf-8?Q?Prud=E2=80=99homme?=) Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <1487359774.1998.0@smtp.gmail.com> <1488653191.6153.0@smtp.gmail.com> <1488738524.13864.0@smtp.gmail.com> <871str3b48.fsf@tromey.com> <1490812056.14782.1@smtp.gmail.com> <1492873665.3376.0@smtp.gmail.com> <87lgqpyl6y.fsf@pokyo> <87vapn3l0i.fsf@tromey.com> <87a86wb76k.fsf@x230.lts> X-Attribution: Tom Date: Wed, 03 May 2017 16:03:52 -0600 In-Reply-To: <87a86wb76k.fsf@x230.lts> ("Etienne \=\?utf-8\?Q\?Prud\=E2\=80\=99ho\?\= \=\?utf-8\?Q\?mme\=22's\?\= message of "Mon, 01 May 2017 17:25:55 -0400") Message-ID: <87wp9xegxj.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 - debbugs.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: 75.166.63.71 X-Exim-ID: 1d62NF-0007lR-1N X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-63-71.hlrn.qwest.net (bapiya) [75.166.63.71]:46440 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Tom Tromey , Simen =?utf-8?Q?Heggest=C3=B8yl?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.8 (--) Etienne> I=E2=80=99ve thought in the pass it would be nicer if we had a rea= l (S)CSS Etienne> parser. I don=E2=80=99t mean by that a renderer (it would be a com= pletely Etienne> different project). Instead I mean something that tells us the gen= erated Etienne> =E2=80=9Ccascade=E2=80=9D. Etienne> This would give us the ability to fontify (S)CSS color variables w= ith Etienne> what color they got. We could also fontify color transformations. Etienne> What do you think? I think it would be good, but it would require more than just a CSS parser - you also need the DOM, so you'd need a way for Emacs to associate CSS and HTML files. Tom From debbugs-submit-bounces@debbugs.gnu.org Wed May 03 18:04:21 2017 Received: (at 25525) by debbugs.gnu.org; 3 May 2017 22:04:21 +0000 Received: from localhost ([127.0.0.1]:53309 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d62Nh-0006cW-Hb for submit@debbugs.gnu.org; Wed, 03 May 2017 18:04:21 -0400 Received: from gproxy10-pub.mail.unifiedlayer.com ([69.89.20.226]:35808 helo=gproxy10.mail.unifiedlayer.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d62Ng-0006cJ-7Z for 25525@debbugs.gnu.org; Wed, 03 May 2017 18:04:20 -0400 Received: from cmgw3 (unknown [10.0.90.84]) by gproxy10.mail.unifiedlayer.com (Postfix) with ESMTP id D90A3140467 for <25525@debbugs.gnu.org>; Wed, 3 May 2017 16:04:14 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id Fy4B1v00B2f2jeq01y4E8z; Wed, 03 May 2017 16:04:14 -0600 X-Authority-Analysis: v=2.2 cv=VKStp5HX c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=tJ8p9aeEuA8A:10 a=21-s9sOeKQ9_viOsaN4A:9 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=PH1bQ8rS+H0KKrbssFvOGEdOBDVgbZX5v10+40uCvCg=; b=VqZVUmn88291QlEfShKJ99uyoC ZZMudVLQlO26+wWEMINof6jirx05uL0FUsTIxWkU2wbmyWCzf8aM3IUdDWmZgVoXToCVx1zUroPEd g9/p/3MT6K9kChNjz1pPq+k6v; Received: from 75-166-63-71.hlrn.qwest.net ([75.166.63.71]:46450 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1d62NX-0007yV-1S; Wed, 03 May 2017 16:04:11 -0600 From: Tom Tromey To: Simen =?utf-8?Q?Heggest=C3=B8yl?= Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <1487359774.1998.0@smtp.gmail.com> <1488653191.6153.0@smtp.gmail.com> <1488738524.13864.0@smtp.gmail.com> <871str3b48.fsf@tromey.com> <1490812056.14782.1@smtp.gmail.com> <1492873665.3376.0@smtp.gmail.com> <87lgqpyl6y.fsf@pokyo> <1493666131.1965.0@smtp.gmail.com> X-Attribution: Tom Date: Wed, 03 May 2017 16:04:07 -0600 In-Reply-To: <1493666131.1965.0@smtp.gmail.com> ("Simen \=\?utf-8\?Q\?Heggest\?\= \=\?utf-8\?Q\?\=C3\=B8yl\=22's\?\= message of "Mon, 01 May 2017 21:15:31 +0200") Message-ID: <87shklegx4.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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 - debbugs.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: 75.166.63.71 X-Exim-ID: 1d62NX-0007yV-1S X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-63-71.hlrn.qwest.net (bapiya) [75.166.63.71]:46450 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Tom Tromey X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.8 (--) Simen> I haven't discovered any more issues since last time, so the feature Simen> seems good to go as far as I'm concerned! I'm going to check it in now. Thanks once again. Tom From debbugs-submit-bounces@debbugs.gnu.org Wed May 03 18:05:08 2017 Received: (at 25525-done) by debbugs.gnu.org; 3 May 2017 22:05:08 +0000 Received: from localhost ([127.0.0.1]:53314 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d62OR-0006e3-Qx for submit@debbugs.gnu.org; Wed, 03 May 2017 18:05:07 -0400 Received: from gproxy1-pub.mail.unifiedlayer.com ([69.89.25.95]:57010 helo=outbound-ss-1812.hostmonster.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d62OQ-0006dI-Cy for 25525-done@debbugs.gnu.org; Wed, 03 May 2017 18:05:06 -0400 Received: from cmgw2 (cmgw3 [10.0.90.83]) by gproxy1.mail.unifiedlayer.com (Postfix) with ESMTP id 007B4175BE8 for <25525-done@debbugs.gnu.org>; Wed, 3 May 2017 16:04:58 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id Fy4v1v00e2f2jeq01y4yG4; Wed, 03 May 2017 16:04:58 -0600 X-Authority-Analysis: v=2.2 cv=Ibz3YSia c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=tJ8p9aeEuA8A:10 a=FxKpEnC0CrsV8nijWlEA:9 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:Date:Subject:To:From: Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Kaqahs4BGVl13mnQrGicPt81twyfd1kJCj63vVXngqk=; b=gyNtrtDV21gpLtubEcZ+zvoBIm hPp9kLarpDg+iebY5XUH5YuhGzzHcDLiKHWbkY7cDLHkcwdGKJvJqPLhWPhbuJdEVnQZjG13oQctB A+y071hkXR/GlXMD38rFbY7Up; Received: from 75-166-63-71.hlrn.qwest.net ([75.166.63.71]:46456 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1d62OF-000062-5d; Wed, 03 May 2017 16:04:55 -0600 From: Tom Tromey To: 25525-done@debbugs.gnu.org Subject: done X-Attribution: Tom Date: Wed, 03 May 2017 16:04:54 -0600 Message-ID: <87o9v9egvt.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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 - debbugs.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: 75.166.63.71 X-Exim-ID: 1d62OF-000062-5d X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-63-71.hlrn.qwest.net (bapiya) [75.166.63.71]:46456 X-Source-Auth: tom+tromey.com X-Email-Count: 6 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 25525-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.8 (--) Fix checked in. Tom From debbugs-submit-bounces@debbugs.gnu.org Wed May 03 19:24:51 2017 Received: (at 25525) by debbugs.gnu.org; 3 May 2017 23:24:51 +0000 Received: from localhost ([127.0.0.1]:53356 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d63db-0008Pw-0x for submit@debbugs.gnu.org; Wed, 03 May 2017 19:24:51 -0400 Received: from mail-io0-f193.google.com ([209.85.223.193]:36327) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d63dZ-0008Pj-Eo for 25525@debbugs.gnu.org; Wed, 03 May 2017 19:24:49 -0400 Received: by mail-io0-f193.google.com with SMTP id x86so39059550ioe.3 for <25525@debbugs.gnu.org>; Wed, 03 May 2017 16:24:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=5B+9eftcFHbeJ55loeSKZygVc7kgGM/vhN+cMF4oPnM=; b=io4njL44Wz3bdJimQsiYa0vNYxqychN9fKvS8fGqUs2sNV9DVzeXFCEN5u+Gt484Sb uZjJr5dWKKc1iNO7Y1ELzt6UtA4ZKAoXMZUz+sjNtVNJ8ANnMwKoI7pGqCmpj/HQ00is yjJGgQw6+iPZ0xQT06RC31VwtqcsDwjaKpK2GiiV0oK5Nr+yPTa/xCwFHdunRvu4EN/E tZXpD54eiYEgf2SwqkpRyyYzI+SZ8qGfYpvvjgFcv0hRN/9llzwPArRXNbjMLjOdOx4v 1j7t1STv/Hy99LYmueRy+ivflJ/gwz0R8Id0MXf53rz3pBdYhkP8IQY8hNmWFoW6tMlL 6bpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=5B+9eftcFHbeJ55loeSKZygVc7kgGM/vhN+cMF4oPnM=; b=jefoANPjqLFtoXOqyDa/tA1PPhUfBLCoHCDV/Hu+Ey6J7tIJwYB38LpTq4iEzoyir0 37x04ZHoUYz94bKsioxpD9XunJ700N4gVXhA2u6Y/plYsydSqFVYSX/i6OxNbJ7yvLQC VrFgaVvpZDi4dI//inzEMeA3yPYKQhKuI8GbjOpb00t351ao4z1o/9MDle8HaJ6XxeKj nQ5EZM4btUu4C3vM9eXQF2Z/ppdp/+lhLtJw82qhY2daGWW7oAK53nlVsTuUo0q8NUsv iaXVKDPqZB8Q+gPfs4ztBFUTjy0I1WkAYwqTiCjhH3MgOQZkk7jy77s8u3059+ePY3yv /pFw== X-Gm-Message-State: AN3rC/4YfAJxpp5fh1zkAqQkjQU6y3k2ItJU6uDl6gyH8i51m58UgSiJ lCK8D6RMLJpiNQ== X-Received: by 10.107.8.154 with SMTP id h26mr10842955ioi.111.1493853883814; Wed, 03 May 2017 16:24:43 -0700 (PDT) Received: from localhost (modemcable232.49-20-96.mc.videotron.ca. [96.20.49.232]) by smtp.gmail.com with ESMTPSA id 77sm2429924ios.19.2017.05.03.16.24.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 May 2017 16:24:42 -0700 (PDT) From: =?utf-8?Q?Etienne_Prud=E2=80=99homme?= To: Tom Tromey Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <1487359774.1998.0@smtp.gmail.com> <1488653191.6153.0@smtp.gmail.com> <1488738524.13864.0@smtp.gmail.com> <871str3b48.fsf@tromey.com> <1490812056.14782.1@smtp.gmail.com> <1492873665.3376.0@smtp.gmail.com> <87lgqpyl6y.fsf@pokyo> <87vapn3l0i.fsf@tromey.com> <87a86wb76k.fsf@x230.lts> <87wp9xegxj.fsf@tromey.com> Date: Wed, 03 May 2017 19:24:42 -0400 In-Reply-To: <87wp9xegxj.fsf@tromey.com> (Tom Tromey's message of "Wed, 03 May 2017 16:03:52 -0600") Message-ID: <87bmr9r0at.fsf@x230.lts> User-Agent: Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Simen =?utf-8?Q?Heggest=C3=B8yl?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Tom Tromey writes: > I think it would be good, but it would require more than just a CSS > parser - you also need the DOM, so you'd need a way for Emacs to > associate CSS and HTML files. > > Tom Of course, I wasn=E2=80=99t talking about HTML. CSS is not confined only to HTML. Sure HTML (the DOM) can set styles, but the styles are coming from either an external style sheet or the browser default style sheet. CSS in itself is a set of cascading style rules that apply according to a tree structure. What we could do with the parser is to tell us which rules are applied in a given node path. We could even apply CSS to the Emacs widget system (although it would require lots of work). -- Etienne From debbugs-submit-bounces@debbugs.gnu.org Wed May 03 23:52:03 2017 Received: (at 25525) by debbugs.gnu.org; 4 May 2017 03:52:03 +0000 Received: from localhost ([127.0.0.1]:53437 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d67oB-0005vP-5z for submit@debbugs.gnu.org; Wed, 03 May 2017 23:52:03 -0400 Received: from gproxy8-pub.mail.unifiedlayer.com ([67.222.33.93]:49016 helo=gproxy8.mail.unifiedlayer.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d67o9-0005ut-NG for 25525@debbugs.gnu.org; Wed, 03 May 2017 23:52:02 -0400 Received: from CMOut01 (unknown [10.0.90.82]) by gproxy8.mail.unifiedlayer.com (Postfix) with ESMTP id 526731AB139 for <25525@debbugs.gnu.org>; Wed, 3 May 2017 21:51:49 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id G3rl1v0052f2jeq013roje; Wed, 03 May 2017 21:51:49 -0600 X-Authority-Analysis: v=2.2 cv=K+5SJ2eI c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=tJ8p9aeEuA8A:10 a=HGHmGCRJ1caRbWpxtDQA:9 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=5kM84WAfjYDwJ3aTmpWR3cOwsbL6ouFZMJ2DpxyP3D4=; b=MGE45ZiLkkXIC5q9+X8f+LQjLg AZhNkf0Rtju1tQ3JozZ2wZgHYe8QcTfCjQbjdCPw1RFi/kxt4w5MQoxTgNr27+NmLQkzeZMvKxpo2 FxYAYWRwJ1D77uAanMYtd/gNY; Received: from 75-166-63-71.hlrn.qwest.net ([75.166.63.71]:49148 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1d67ns-0007Qq-UD; Wed, 03 May 2017 21:51:45 -0600 From: Tom Tromey To: Etienne =?utf-8?Q?Prud=E2=80=99homme?= Subject: Re: bug#25525: 25.1.90; add color highlighting to css mode References: <87mvefh8br.fsf@tromey.com> <1485375833.1960.0@smtp.gmail.com> <1485455113.4245.1@smtp.gmail.com> <1487359774.1998.0@smtp.gmail.com> <1488653191.6153.0@smtp.gmail.com> <1488738524.13864.0@smtp.gmail.com> <871str3b48.fsf@tromey.com> <1490812056.14782.1@smtp.gmail.com> <1492873665.3376.0@smtp.gmail.com> <87lgqpyl6y.fsf@pokyo> <87vapn3l0i.fsf@tromey.com> <87a86wb76k.fsf@x230.lts> <87wp9xegxj.fsf@tromey.com> <87bmr9r0at.fsf@x230.lts> X-Attribution: Tom Date: Wed, 03 May 2017 21:51:44 -0600 In-Reply-To: <87bmr9r0at.fsf@x230.lts> ("Etienne \=\?utf-8\?Q\?Prud\=E2\=80\=99ho\?\= \=\?utf-8\?Q\?mme\=22's\?\= message of "Wed, 03 May 2017 19:24:42 -0400") Message-ID: <87k25xe0tr.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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 - debbugs.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: 75.166.63.71 X-Exim-ID: 1d67ns-0007Qq-UD X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-63-71.hlrn.qwest.net (bapiya) [75.166.63.71]:49148 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 25525 Cc: 25525@debbugs.gnu.org, Tom Tromey , Simen =?utf-8?Q?Heggest=C3=B8yl?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.8 (--) Etienne> What we could do with the parser is to tell us which rules are applied Etienne> in a given node path. I'm not sure I understand what you are proposing, but I'm generally in favor of anything making Emacs more useful. Perhaps we should discuss it not in this bug. Tom From unknown Tue Aug 19 07:09:36 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 01 Jun 2017 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator