unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Thuna <thuna.cing@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: [Patch] rcirc-color: Allow recoloring nicks
Date: Thu, 29 Sep 2022 14:14:34 +0200	[thread overview]
Message-ID: <87sfkawf6d.fsf@gmail.com> (raw)
In-Reply-To: <87wn9ntdi6.fsf@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 135 bytes --]

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

Alright, it did in fact fail.  Here's the (hopefully) correct patch.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: The *actual* patch --]
[-- Type: text/x-patch, Size: 1691 bytes --]

From 4462df8aa6c0f9986629d5fab7df43e502552ba3 Mon Sep 17 00:00:00 2001
From: Thuna <thuna.cing@gmail.com>
Date: Thu, 29 Sep 2022 14:12:20 +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
error.
---
 rcirc-color.el | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/rcirc-color.el b/rcirc-color.el
index 2eff965267..7bcc46c91d 100644
--- a/rcirc-color.el
+++ b/rcirc-color.el
@@ -134,7 +134,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
 faces.
 
-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
+instead.
 
 PROCESS and TARGET are the standard arguments for rcirc
 commands."
@@ -149,9 +151,12 @@ commands."
                  rcirc-color-mapping)
         (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
+                   (or 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)
-- 
2.35.1


  reply	other threads:[~2022-09-29 12:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-28 21:06 [Patch] rcirc-color: Allow recoloring nicks Thuna
2022-09-29 12:14 ` Thuna [this message]
2022-09-29 13:30 ` Stefan Kangas
2022-09-29 15:42 ` Philip Kaludercic
2022-09-29 15:48   ` Philip Kaludercic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sfkawf6d.fsf@gmail.com \
    --to=thuna.cing@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).