unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#60794: [PATCH] (rainbow.el) Add matching option to rainbow-colorize-hexadecimal-without-sharp
@ 2023-01-13 20:24 Dimitri Belopopsky
  0 siblings, 0 replies; only message in thread
From: Dimitri Belopopsky @ 2023-01-13 20:24 UTC (permalink / raw)
  To: 60794


[-- Attachment #1.1: Type: text/plain, Size: 350 bytes --]

Hello,

I made a modification to "rainbow-colorize-hexadecimal-without-sharp" in
rainbow-mode which allows passing a "match" option. I needed this to match
subgroups on complex strings, in my case to highlight the hexadecimal
inside Color::hex("FFF") without colouring the whole expression.

I think it could be useful to more people.

Kind regards,

[-- Attachment #1.2: Type: text/html, Size: 460 bytes --]

[-- Attachment #2: 0001-Add-matching-option-to-rainbow-colorize-hexadecimal-.patch --]
[-- Type: text/x-patch, Size: 1221 bytes --]

From 691545fda48fd30261b62503a8bdbcbcbbe9e49d Mon Sep 17 00:00:00 2001
From: Dimitri Belopopsky <dimitri@belopopsky.com>
Date: Mon, 28 Nov 2022 23:15:03 +0100
Subject: [PATCH] Add matching option to
 rainbow-colorize-hexadecimal-without-sharp

* rainbow-mode.el (rainbow-colorize-hexadecimal-without-sharp) Add
Add matching option to rainbow-colorize-hexadecimal-without-sharp
---
 rainbow-mode.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rainbow-mode.el b/rainbow-mode.el
index 14bf442..9bd4a83 100644
--- a/rainbow-mode.el
+++ b/rainbow-mode.el
@@ -1033,9 +1033,9 @@ background is COLOR. The foreground is computed using
   "Colorize a match with itself."
   (rainbow-colorize-match (match-string-no-properties (or match 0)) match))
 
-(defun rainbow-colorize-hexadecimal-without-sharp ()
+(defun rainbow-colorize-hexadecimal-without-sharp (&optional match)
   "Colorize an hexadecimal colors and prepend # to it."
-  (rainbow-colorize-match (concat "#" (match-string-no-properties 1))))
+  (rainbow-colorize-match (concat "#" (match-string-no-properties 1)) match))
 
 (defun rainbow-colorize-by-assoc (assoc-list)
   "Colorize a match with its association from ASSOC-LIST."
-- 
2.34.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-13 20:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-13 20:24 bug#60794: [PATCH] (rainbow.el) Add matching option to rainbow-colorize-hexadecimal-without-sharp Dimitri Belopopsky

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).