[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Patch] rcirc-color: Allow recoloring nicks

From: Thuna
Subject: [Patch] rcirc-color: Allow recoloring nicks
Date: Wed, 28 Sep 2022 23:06:41 +0200

I think rcirc-color should allow a nick to be "recolored" with the
command `/color nick', instead of signalling an error as it does now.

This is useful, for example, when two similar nicks are assigned the
same color but there's no specific color you want to reassign to either
of them.

I haven't tested the patch, but I can't see why it would fail.

>From 8bd21515f31a5e3cfedce623d8ebc9907b82b2a5 Mon Sep 17 00:00:00 2001
From: Thuna <thuna.cing@gmail.com>
Date: Wed, 28 Sep 2022 22:58:00 +0200
Subject: [PATCH] rcirc-color: Select a random color on `/color nick'

* rcirc-color.el: When `/color' is called with a nick but no color,
choose a random color from `rcirc-colors' instead of signalling an
 rcirc-color.el | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/rcirc-color.el b/rcirc-color.el
index 872d1d8298..0f6f2adea9 100644
--- a/rcirc-color.el
+++ b/rcirc-color.el
@@ -136,7 +136,9 @@ NICK is the nick for which the new color ist set; if nil, 
all the
 nicks in `rcirc-color-mapping' are shown with their corresponding
-COLOR is the color to use as the new foreground-color.
+COLOR is the color to use as the new foreground-color.  If COLOR
+is not supplied, a random color from `rcirc-colors' is used
 PROCESS and TARGET are the standard arguments for rcirc
@@ -151,9 +153,11 @@ commands."
         (rcirc-print process (rcirc-nick process) "NOTICE" target
                      (mapconcat 'identity names " ")))
-    (unless color
-      (error "Use what color?"))
-    (puthash nick (cons 'foreground-color color) rcirc-color-mapping)))
+    (puthash nick
+             (cons 'foreground-color
+                   (elt rcirc-colors
+                        (random (length rcirc-colors))))
+             rcirc-color-mapping)))
 (advice-add 'rcirc-handler-NICK :before #'rcirc-color--handler-NICK)
 (defun rcirc-color--handler-NICK (_process sender args _text)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]