From unknown Fri Sep 19 21:46:11 2025 X-Loop: help-debbugs@gnu.org Subject: bug#71724: 30.0.50; [PATCH] php-ts-mode: Colorize CSS property value like `css--fontify-region' Resent-From: Vincenzo Pupillo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 22 Jun 2024 21:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 71724 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 71724@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.171909218020448 (code B ref -1); Sat, 22 Jun 2024 21:37:02 +0000 Received: (at submit) by debbugs.gnu.org; 22 Jun 2024 21:36:20 +0000 Received: from localhost ([127.0.0.1]:32910 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sL8PE-0005Jj-70 for submit@debbugs.gnu.org; Sat, 22 Jun 2024 17:36:20 -0400 Received: from lists.gnu.org ([209.51.188.17]:47776) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sL8PC-0005Jb-LB for submit@debbugs.gnu.org; Sat, 22 Jun 2024 17:36:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sL8PC-0004kT-6n for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2024 17:36:18 -0400 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sL8PA-00065I-FB for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2024 17:36:17 -0400 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2eaafda3b5cso33227071fa.3 for ; Sat, 22 Jun 2024 14:36:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719092175; x=1719696975; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=S5EtkX+886HhOFSbl/Yz97vGxreOjLpapgkM5TKfqlU=; b=KBHttf9I7/gkxvwg+xoqkMDx6H0IYOBNLn8qwZGq+d2jI7ZwHzx24+iW38GjX3Lp7F Mj65zzB2Szm0YIbQEuDZ/d8ZvszT2Rmw5nHGF/uSOvMJS56dx5oUcMo60bN9W3IknYks jFtCaREODQG+1GEmGlhOXZ4WITgs+Rr06bMyoHAdVx/axZT45fjdk8X2GEvkZtnCg17V m355NO8UQVLhuJliAcx84EzH1YwQeO8rda9R9ON+rv+sb1BLH+hJONfIlqJxrNH26QIs oogYgpyYBu+LkD5t5X01+689afLEoDqzK+oBld4tAkMSXJWRHQdIZMOPXX4F2aLnAbTo 3J8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719092175; x=1719696975; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=S5EtkX+886HhOFSbl/Yz97vGxreOjLpapgkM5TKfqlU=; b=vt7/2qXYOuptVWDaIG6dyOZsICNUTiVlJpP6cVe0WCuZz+XeHNdENkoNjH2kEZ1yiA O1R3Wrn3si1DUrEudS5NmaNrisyOAM+AgBgL2ZVVFpazcP9fcHDISiEmKDS6ACu2fwxX mthvqeHITm5/V45RY99zXDhjkpkKw1PrP7VzLp/xjBBWoUiNAcmDvz6EUv8bZbOxIwxI EshSXT1RHOiYJeCswR/8/xd7iGePw6zvu21SoyoWPvXgw7A7a2n0MsnVWsgReBdyg1zZ LOYjTHj0HFRFq2A+yzdkRZBZca8/ixkhIUkWZTYhqetBE4JteutjCMehDfMs39dKfqAu Ti5g== X-Gm-Message-State: AOJu0YwjjtYnrrnioNmdx3cOXQhGfElwZssFDqTG2qgAgX28JkMvEhK7 9b3Lw7BY8hjqbbUoGmuo2PbHOCwM3n9VDh0R8fB9ruIE9NxVhBAn7AwHSSmp X-Google-Smtp-Source: AGHT+IELs8xWvcPY4jdD7/b0v44k1rTfJHZKv4NUzt1vpnqL1Hkh+D6yALg5Ca21YiCl6rvSiofGSA== X-Received: by 2002:a2e:8744:0:b0:2ec:5736:e903 with SMTP id 38308e7fff4ca-2ec5956b8a7mr7190751fa.46.1719092174303; Sat, 22 Jun 2024 14:36:14 -0700 (PDT) Received: from fedora.localnet (2-230-139-124.ip202.fastwebnet.it. [2.230.139.124]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57d303da378sm2729983a12.18.2024.06.22.14.36.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jun 2024 14:36:13 -0700 (PDT) From: Vincenzo Pupillo Date: Sat, 22 Jun 2024 23:36:13 +0200 Message-ID: <2215304.Hq7AAxBmiT@fedora> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart3618128.aCxCBeP46V" Content-Transfer-Encoding: 7Bit Received-SPF: pass client-ip=2a00:1450:4864:20::233; envelope-from=v.pupillo@gmail.com; helo=mail-lj1-x233.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) 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 (--) This is a multi-part message in MIME format. --nextPart3618128.aCxCBeP46V Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Hi, this patch adds a new feature to colorize a property when it's value is a text that represents a CSS color. It will be fontified such that its background is the color itself, like in 'cs-ts-mode'. A new custom var 'php-ts-mode-css-fontify-colors' can be used to toggle this behavior. Thanks. Vincenzo --nextPart3618128.aCxCBeP46V Content-Disposition: attachment; filename="0001-Colorize-CSS-property-value-like-css-fontify-region.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="x-UTF_8J"; name="0001-Colorize-CSS-property-value-like-css-fontify-region.patch" >From 46c7e8adb0adb107892531ea067ba75256720a59 Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo Date: Sat, 22 Jun 2024 23:11:17 +0200 Subject: [PATCH] Colorize CSS property value like `css--fontify-region' If the value of a property is text representing a CSS color, it will be fontified such that its background is the color itself. 'php-ts-mode-css-fontify-colors' can be used to disable this behaviour. * lisp/progmodes/php-ts-mode.el (php-ts-mode-css-fontify-colors): New custom var. * lisp/progmodes/php-ts-mode.el (php-ts-mode--colorize-css-value): New function. * lisp/progmodes/php-ts-mode.el (php-ts-mode): Use the new function. --- lisp/progmodes/php-ts-mode.el | 44 ++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/php-ts-mode.el b/lisp/progmodes/php-ts-mode.el index f1dfac59c2e..d2d8377ee88 100644 --- a/lisp/progmodes/php-ts-mode.el +++ b/lisp/progmodes/php-ts-mode.el @@ -121,6 +121,16 @@ php-ts-mode-js-css-indent-offset :type 'integer :safe 'integerp) +(defcustom php-ts-mode-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. +Works like `css--fontify-region'." + :tag "PHP colors the CSS properties values." + :version "30.1" + :type 'boolean + :safe 'booleanp) + (defcustom php-ts-mode-php-executable (or (executable-find "php") "/usr/bin/php") "The location of PHP executable." :tag "PHP Executable" @@ -999,6 +1009,26 @@ php-ts-mode--phpdoc-font-lock-settings '((variable_name (name) @font-lock-variable-name-face))) "Tree-sitter font-lock settings for phpdoc.") +(defun php-ts-mode--colorize-css-value (node override start end &rest _) + "Colorize CSS property value like `css--fontify-region'. +For NODE, OVERRIDE, START, and END, see `treesit-font-lock-rules'." + (if (and php-ts-mode-css-fontify-colors + (string-equal "plain_value" (treesit-node-type node))) + (let ((color (css--compute-color start (treesit-node-text node t)))) + (when color + (treesit-fontify-with-override + (treesit-node-start node) (treesit-node-end node) + (list 'face + (list :background color + :foreground (readable-foreground-color + color) + :box '(:line-width -1))) + override start end))) + (treesit-fontify-with-override + (treesit-node-start node) (treesit-node-end node) + 'font-lock-variable-name-face + override start end))) + (defun php-ts-mode--fontify-error (node override start end &rest _) "Fontify the error nodes. For NODE, OVERRIDE, START, and END, see `treesit-font-lock-rules'." @@ -1393,12 +1423,20 @@ php-ts-mode ("Constant" "\\`const_element\\'" nil nil))) ;; Font-lock. - (setq-local treesit-font-lock-settings (php-ts-mode--font-lock-settings)) (setq-local treesit-font-lock-settings - (append treesit-font-lock-settings + (append (php-ts-mode--font-lock-settings) php-ts-mode--custom-html-font-lock-settings js--treesit-font-lock-settings - css--treesit-settings + (append + ;; Rule for coloring CSS property values. + ;; Placed before `css--treesit-settings' + ;; to win against the same rule contained therein. + (treesit-font-lock-rules + :language 'css + :override t + :feature 'variable + '((plain_value) @php-ts-mode--colorize-css-value)) + css--treesit-settings) php-ts-mode--phpdoc-font-lock-settings)) (setq-local treesit-font-lock-feature-list php-ts-mode--feature-list) -- 2.45.2 --nextPart3618128.aCxCBeP46V-- From unknown Fri Sep 19 21:46:11 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Vincenzo Pupillo Subject: bug#71724: closed (Re: bug#71724: 30.0.50; [PATCH] php-ts-mode: Colorize CSS property value like `css--fontify-region') Message-ID: References: <86iky0fdtp.fsf@gnu.org> <2215304.Hq7AAxBmiT@fedora> X-Gnu-PR-Message: they-closed 71724 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 71724@debbugs.gnu.org Date: Sun, 23 Jun 2024 05:07:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1719119222-21717-1" This is a multi-part message in MIME format... ------------=_1719119222-21717-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #71724: 30.0.50; [PATCH] php-ts-mode: Colorize CSS property value like `css= --fontify-region' which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 71724@debbugs.gnu.org. --=20 71724: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D71724 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1719119222-21717-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 71724-done) by debbugs.gnu.org; 23 Jun 2024 05:06:20 +0000 Received: from localhost ([127.0.0.1]:44508 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sLFQi-0005cW-Ab for submit@debbugs.gnu.org; Sun, 23 Jun 2024 01:06:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60602) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sLFQg-0005cB-B2 for 71724-done@debbugs.gnu.org; Sun, 23 Jun 2024 01:06:18 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLFQa-0002d2-Gi; Sun, 23 Jun 2024 01:06:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=tn0q7MLmb3thqE6JowjxUubI/h7chsuiDwT4MLYngQc=; b=QP9XZc7pkNQk rjxduJ7bxBvQiWhnVhxJ/63wiTn0tQjhbuwPWunam97ZTSFI027ic7rfz4yDc+EH/uWxjTwiogF4W dRj7Reg1SA4ea3jb14tOPYfBYZYy+H6DID3n7Jr2eUbSWYJmo9OfOGtDiVoDwoTbVrFldtOluaI3g 1OAm20Jp0FRTzP1Ma6hZfHYqCVkyIKPCT/bGG7DG0cXC+X5m5gucVW6tPa/fPUdtZTD2Fwta9BLTB rj1KncKodDc8alZ9H8b04YC1IFt8YqJCDEv00ysCGCO15Xbo7pR0eoEsVWwKkOS/mCHwI9VwQLJxJ JhqxTt1Z/M61Apj6tAFHHQ==; Date: Sun, 23 Jun 2024 08:06:10 +0300 Message-Id: <86iky0fdtp.fsf@gnu.org> From: Eli Zaretskii To: Vincenzo Pupillo In-Reply-To: <2215304.Hq7AAxBmiT@fedora> (message from Vincenzo Pupillo on Sat, 22 Jun 2024 23:36:13 +0200) Subject: Re: bug#71724: 30.0.50; [PATCH] php-ts-mode: Colorize CSS property value like `css--fontify-region' References: <2215304.Hq7AAxBmiT@fedora> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 71724-done Cc: 71724-done@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: -3.3 (---) > From: Vincenzo Pupillo > Date: Sat, 22 Jun 2024 23:36:13 +0200 > > this patch adds a new feature to colorize a property when it's value is a text > that represents a CSS color. It will be fontified such that its background is > the color itself, like in 'cs-ts-mode'. > A new custom var 'php-ts-mode-css-fontify-colors' can be used to toggle this > behavior. Thanks, installed, and closing the bug. Please in the future observe our conventions for the commit log messages: > Subject: [PATCH] Colorize CSS property value like `css--fontify-region' > > If the value of a property is text representing a CSS color, it will be > fontified such that its background is the color itself. > 'php-ts-mode-css-fontify-colors' can be used to disable this behaviour. These lines are too long. They will be indented by a TAB in the generated ChangeLog file, so they should preferably be no longer than 65 characters. > * lisp/progmodes/php-ts-mode.el (php-ts-mode-css-fontify-colors): > New custom var. ^^^ Please don't leave this whitespace at the beginning of lines. > * lisp/progmodes/php-ts-mode.el (php-ts-mode): Use the new function. This line is also too long. I usually correct any log messages that need it, but if you observe these conventions better, it will make my job easier. Thanks. ------------=_1719119222-21717-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 22 Jun 2024 21:36:20 +0000 Received: from localhost ([127.0.0.1]:32910 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sL8PE-0005Jj-70 for submit@debbugs.gnu.org; Sat, 22 Jun 2024 17:36:20 -0400 Received: from lists.gnu.org ([209.51.188.17]:47776) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sL8PC-0005Jb-LB for submit@debbugs.gnu.org; Sat, 22 Jun 2024 17:36:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sL8PC-0004kT-6n for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2024 17:36:18 -0400 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sL8PA-00065I-FB for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2024 17:36:17 -0400 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2eaafda3b5cso33227071fa.3 for ; Sat, 22 Jun 2024 14:36:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719092175; x=1719696975; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=S5EtkX+886HhOFSbl/Yz97vGxreOjLpapgkM5TKfqlU=; b=KBHttf9I7/gkxvwg+xoqkMDx6H0IYOBNLn8qwZGq+d2jI7ZwHzx24+iW38GjX3Lp7F Mj65zzB2Szm0YIbQEuDZ/d8ZvszT2Rmw5nHGF/uSOvMJS56dx5oUcMo60bN9W3IknYks jFtCaREODQG+1GEmGlhOXZ4WITgs+Rr06bMyoHAdVx/axZT45fjdk8X2GEvkZtnCg17V m355NO8UQVLhuJliAcx84EzH1YwQeO8rda9R9ON+rv+sb1BLH+hJONfIlqJxrNH26QIs oogYgpyYBu+LkD5t5X01+689afLEoDqzK+oBld4tAkMSXJWRHQdIZMOPXX4F2aLnAbTo 3J8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719092175; x=1719696975; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=S5EtkX+886HhOFSbl/Yz97vGxreOjLpapgkM5TKfqlU=; b=vt7/2qXYOuptVWDaIG6dyOZsICNUTiVlJpP6cVe0WCuZz+XeHNdENkoNjH2kEZ1yiA O1R3Wrn3si1DUrEudS5NmaNrisyOAM+AgBgL2ZVVFpazcP9fcHDISiEmKDS6ACu2fwxX mthvqeHITm5/V45RY99zXDhjkpkKw1PrP7VzLp/xjBBWoUiNAcmDvz6EUv8bZbOxIwxI EshSXT1RHOiYJeCswR/8/xd7iGePw6zvu21SoyoWPvXgw7A7a2n0MsnVWsgReBdyg1zZ LOYjTHj0HFRFq2A+yzdkRZBZca8/ixkhIUkWZTYhqetBE4JteutjCMehDfMs39dKfqAu Ti5g== X-Gm-Message-State: AOJu0YwjjtYnrrnioNmdx3cOXQhGfElwZssFDqTG2qgAgX28JkMvEhK7 9b3Lw7BY8hjqbbUoGmuo2PbHOCwM3n9VDh0R8fB9ruIE9NxVhBAn7AwHSSmp X-Google-Smtp-Source: AGHT+IELs8xWvcPY4jdD7/b0v44k1rTfJHZKv4NUzt1vpnqL1Hkh+D6yALg5Ca21YiCl6rvSiofGSA== X-Received: by 2002:a2e:8744:0:b0:2ec:5736:e903 with SMTP id 38308e7fff4ca-2ec5956b8a7mr7190751fa.46.1719092174303; Sat, 22 Jun 2024 14:36:14 -0700 (PDT) Received: from fedora.localnet (2-230-139-124.ip202.fastwebnet.it. [2.230.139.124]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57d303da378sm2729983a12.18.2024.06.22.14.36.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jun 2024 14:36:13 -0700 (PDT) From: Vincenzo Pupillo To: bug-gnu-emacs@gnu.org Subject: 30.0.50; [PATCH] php-ts-mode: Colorize CSS property value like `css--fontify-region' Date: Sat, 22 Jun 2024 23:36:13 +0200 Message-ID: <2215304.Hq7AAxBmiT@fedora> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart3618128.aCxCBeP46V" Content-Transfer-Encoding: 7Bit Received-SPF: pass client-ip=2a00:1450:4864:20::233; envelope-from=v.pupillo@gmail.com; helo=mail-lj1-x233.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) 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: -2.3 (--) This is a multi-part message in MIME format. --nextPart3618128.aCxCBeP46V Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Hi, this patch adds a new feature to colorize a property when it's value is a text that represents a CSS color. It will be fontified such that its background is the color itself, like in 'cs-ts-mode'. A new custom var 'php-ts-mode-css-fontify-colors' can be used to toggle this behavior. Thanks. Vincenzo --nextPart3618128.aCxCBeP46V Content-Disposition: attachment; filename="0001-Colorize-CSS-property-value-like-css-fontify-region.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="x-UTF_8J"; name="0001-Colorize-CSS-property-value-like-css-fontify-region.patch" >From 46c7e8adb0adb107892531ea067ba75256720a59 Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo Date: Sat, 22 Jun 2024 23:11:17 +0200 Subject: [PATCH] Colorize CSS property value like `css--fontify-region' If the value of a property is text representing a CSS color, it will be fontified such that its background is the color itself. 'php-ts-mode-css-fontify-colors' can be used to disable this behaviour. * lisp/progmodes/php-ts-mode.el (php-ts-mode-css-fontify-colors): New custom var. * lisp/progmodes/php-ts-mode.el (php-ts-mode--colorize-css-value): New function. * lisp/progmodes/php-ts-mode.el (php-ts-mode): Use the new function. --- lisp/progmodes/php-ts-mode.el | 44 ++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/php-ts-mode.el b/lisp/progmodes/php-ts-mode.el index f1dfac59c2e..d2d8377ee88 100644 --- a/lisp/progmodes/php-ts-mode.el +++ b/lisp/progmodes/php-ts-mode.el @@ -121,6 +121,16 @@ php-ts-mode-js-css-indent-offset :type 'integer :safe 'integerp) +(defcustom php-ts-mode-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. +Works like `css--fontify-region'." + :tag "PHP colors the CSS properties values." + :version "30.1" + :type 'boolean + :safe 'booleanp) + (defcustom php-ts-mode-php-executable (or (executable-find "php") "/usr/bin/php") "The location of PHP executable." :tag "PHP Executable" @@ -999,6 +1009,26 @@ php-ts-mode--phpdoc-font-lock-settings '((variable_name (name) @font-lock-variable-name-face))) "Tree-sitter font-lock settings for phpdoc.") +(defun php-ts-mode--colorize-css-value (node override start end &rest _) + "Colorize CSS property value like `css--fontify-region'. +For NODE, OVERRIDE, START, and END, see `treesit-font-lock-rules'." + (if (and php-ts-mode-css-fontify-colors + (string-equal "plain_value" (treesit-node-type node))) + (let ((color (css--compute-color start (treesit-node-text node t)))) + (when color + (treesit-fontify-with-override + (treesit-node-start node) (treesit-node-end node) + (list 'face + (list :background color + :foreground (readable-foreground-color + color) + :box '(:line-width -1))) + override start end))) + (treesit-fontify-with-override + (treesit-node-start node) (treesit-node-end node) + 'font-lock-variable-name-face + override start end))) + (defun php-ts-mode--fontify-error (node override start end &rest _) "Fontify the error nodes. For NODE, OVERRIDE, START, and END, see `treesit-font-lock-rules'." @@ -1393,12 +1423,20 @@ php-ts-mode ("Constant" "\\`const_element\\'" nil nil))) ;; Font-lock. - (setq-local treesit-font-lock-settings (php-ts-mode--font-lock-settings)) (setq-local treesit-font-lock-settings - (append treesit-font-lock-settings + (append (php-ts-mode--font-lock-settings) php-ts-mode--custom-html-font-lock-settings js--treesit-font-lock-settings - css--treesit-settings + (append + ;; Rule for coloring CSS property values. + ;; Placed before `css--treesit-settings' + ;; to win against the same rule contained therein. + (treesit-font-lock-rules + :language 'css + :override t + :feature 'variable + '((plain_value) @php-ts-mode--colorize-css-value)) + css--treesit-settings) php-ts-mode--phpdoc-font-lock-settings)) (setq-local treesit-font-lock-feature-list php-ts-mode--feature-list) -- 2.45.2 --nextPart3618128.aCxCBeP46V-- ------------=_1719119222-21717-1-- From unknown Fri Sep 19 21:46:11 2025 X-Loop: help-debbugs@gnu.org Subject: bug#71724: 30.0.50; [PATCH] php-ts-mode: Colorize CSS property value like `css--fontify-region' Resent-From: Vincenzo Pupillo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 23 Jun 2024 10:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71724 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii Cc: 71724-done@debbugs.gnu.org Received: via spool by 71724-done@debbugs.gnu.org id=D71724.17191375377568 (code D ref 71724); Sun, 23 Jun 2024 10:13:02 +0000 Received: (at 71724-done) by debbugs.gnu.org; 23 Jun 2024 10:12:17 +0000 Received: from localhost ([127.0.0.1]:52714 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sLKCn-0001xz-2X for submit@debbugs.gnu.org; Sun, 23 Jun 2024 06:12:17 -0400 Received: from mail-ed1-f49.google.com ([209.85.208.49]:60788) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sLKCl-0001xi-8A for 71724-done@debbugs.gnu.org; Sun, 23 Jun 2024 06:12:15 -0400 Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-57cc1c00ba6so4026535a12.1 for <71724-done@debbugs.gnu.org>; Sun, 23 Jun 2024 03:12:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719137469; x=1719742269; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8igQ6S66eyYjWZ0XwnCJPIUAKvF5v7jo8o6cTPN9OG0=; b=RV3SP3u/88GyCHNucJW1wZZRGafGVjw2g6qRq6mQmKSJmtgP8xL5zHq14FtWAWsfhp cnNfW5R0cfr3OgrTa997gv72uNB+UkOaZQQhuOAsOJRjvvyAfVSS7lpCxJBYr6zwRyUa J8jfQTjR8Lxt7d1/sWjOMm+bVtN9nQMRMNMgPJYhHINcJw189RMkX0jV/YaQk+QNi5Y5 zFsNRlqdF24byg+JIA6He+v911VET9FTZKRjdjHgErXghccDtQrDizkHLqNHYwcyWLvD Tux3CBv9LG/ADazCyGhV/Ze6we3s1v+s9VdIMxRKQKZJTfm5m3fZzcLhKp/QCpdACaw5 gE4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719137469; x=1719742269; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8igQ6S66eyYjWZ0XwnCJPIUAKvF5v7jo8o6cTPN9OG0=; b=aYlX07x8Zl1gQWPhN5DqLF8DAu0T8+aFRwEapGJz3+NMtuDer9kZdMobrMI58T+zu9 EvrDjF2+O0fE0E+DhdDenrkZv8pPAv9vnbRS6aQjLpFRB6Wh0XJ5pliYq7aIsy4/XYf0 NaW1fe/VlAuFiN9GSGiN7tDwG2H1mqJyT2byEwjUrIe3rOvvFgiEFHvEymJjvABn3BZw 9FuixEUjH3aTqfeVnAplwrtcbUOJntsASeWZjmTCaqsEnLUgQP6KhkjR/p8wmmtAwsfK I8Q6Fd/zFH1yX4NvuJ5tDYoYHZnd4hOm/EL5ZuYLDDqcKeuuwu0D+RL98ahXPvZQmtns ahrg== X-Gm-Message-State: AOJu0Yzk0aHGcq7SCtiCRPuuUn1YgCPIB1xvfsPDLlR5kXCQPiK92mV6 kuKgTHPfBYQb6EN3E+5HhPiMgD5WEugtQto3NYvMf6knxx3rRHif X-Google-Smtp-Source: AGHT+IFD+6z37MA56qDR+3ADyWLGEn8Ge2x67i/WDH2uS+RW5lN26cQmJ3/DAUrVMLdafWo5eyQQEQ== X-Received: by 2002:a50:d557:0:b0:57c:935d:2881 with SMTP id 4fb4d7f45d1cf-57d4bdbfb59mr1077691a12.32.1719137468700; Sun, 23 Jun 2024 03:11:08 -0700 (PDT) Received: from fedora.localnet (2-230-139-124.ip202.fastwebnet.it. [2.230.139.124]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57d303d7ddcsm3340514a12.17.2024.06.23.03.11.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jun 2024 03:11:08 -0700 (PDT) From: Vincenzo Pupillo Date: Sun, 23 Jun 2024 12:11:07 +0200 Message-ID: <2139705.9o76ZdvQCi@fedora> In-Reply-To: <86iky0fdtp.fsf@gnu.org> References: <2215304.Hq7AAxBmiT@fedora> <86iky0fdtp.fsf@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" X-Spam-Score: -0.0 (/) 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.0 (-) In data domenica 23 giugno 2024 07:06:10 CEST, Eli Zaretskii ha scritto: > > From: Vincenzo Pupillo > > Date: Sat, 22 Jun 2024 23:36:13 +0200 > > > > this patch adds a new feature to colorize a property when it's value is a > > text that represents a CSS color. It will be fontified such that its > > background is the color itself, like in 'cs-ts-mode'. > > A new custom var 'php-ts-mode-css-fontify-colors' can be used to toggle > > this behavior. > > Thanks, installed, and closing the bug. > > Please in the future observe our conventions for the commit log > > messages: > > Subject: [PATCH] Colorize CSS property value like `css--fontify-region' > > > > If the value of a property is text representing a CSS color, it will be > > fontified such that its background is the color itself. > > 'php-ts-mode-css-fontify-colors' can be used to disable this behaviour. > > These lines are too long. They will be indented by a TAB in the > generated ChangeLog file, so they should preferably be no longer than > 65 characters. > > > * lisp/progmodes/php-ts-mode.el (php-ts-mode-css-fontify-colors): > > New custom var. > > ^^^ > Please don't leave this whitespace at the beginning of lines. > > > * lisp/progmodes/php-ts-mode.el (php-ts-mode): Use the new function. > > This line is also too long. > > I usually correct any log messages that need it, but if you observe > these conventions better, it will make my job easier. > > Thanks. I apologize, I will be more accurate with the commit log messages. Thank you very much Eli. Vincenzo From unknown Fri Sep 19 21:46:11 2025 X-Loop: help-debbugs@gnu.org Subject: bug#71724: 30.0.50; [PATCH] php-ts-mode: Colorize CSS property value like `css--fontify-region' Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 23 Jun 2024 10:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71724 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Vincenzo Pupillo Cc: 71724@debbugs.gnu.org Received: via spool by 71724-submit@debbugs.gnu.org id=B71724.17191377658154 (code B ref 71724); Sun, 23 Jun 2024 10:17:02 +0000 Received: (at 71724) by debbugs.gnu.org; 23 Jun 2024 10:16:05 +0000 Received: from localhost ([127.0.0.1]:52833 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sLKGS-00027R-Jd for submit@debbugs.gnu.org; Sun, 23 Jun 2024 06:16:05 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56356) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sLKGP-00026Y-5r for 71724@debbugs.gnu.org; Sun, 23 Jun 2024 06:16:01 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLKGJ-0000Ra-F9; Sun, 23 Jun 2024 06:15:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=cxjFACxL5FX7E0bLy87YpIbPkJY66WY4iqVQLZ3903A=; b=GbVBF+c6IWa/ k1YfkskSa00iwsjiYSjURl6s/QLt1DyX2ZjupxDtEVR6r+hWMcYEv5SoBs4diDhTKAhCxpvgzbD82 51GeyLBZnsqfAq7Y14Bq11IJVlp5an9I4SFtpOcRLqAAZrrAW6lzujuqBEYNLvj6RJBI9Dy6LUYy6 611bpS2S1JcUFwwkrD7YNU9oOBdqOpH4cZUFlGXAl2FTpxBztPIFQ4aYw47Gh0VyyiPMxhbuefYug xJzVPoPqEtUg/vKidG1UtHLoCPVH1YARSgG1C9CQxxNrhi96iMobpvzjY8JRUHW6Z6+ILzRHeEcOk Ye76elTg7RGPDoZDO2zHJg==; Date: Sun, 23 Jun 2024 13:15:52 +0300 Message-Id: <86tthkdkx3.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <2139705.9o76ZdvQCi@fedora> (message from Vincenzo Pupillo on Sun, 23 Jun 2024 12:11:07 +0200) References: <2215304.Hq7AAxBmiT@fedora> <86iky0fdtp.fsf@gnu.org> <2139705.9o76ZdvQCi@fedora> X-Spam-Score: -2.3 (--) 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: -3.3 (---) > From: Vincenzo Pupillo > Cc: 71724-done@debbugs.gnu.org > Date: Sun, 23 Jun 2024 12:11:07 +0200 > > I apologize, I will be more accurate with the commit log messages. No need to apologize, we aren't born with this knowledge. Thank you for you continuing contributions.