From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: [Patch] rcirc-color: Allow recoloring nicks Date: Thu, 29 Sep 2022 15:42:31 +0000 Message-ID: <87v8p6xk48.fsf@posteo.net> References: <87wn9ntdi6.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15259"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Thuna Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Sep 29 19:37:04 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1odxT6-0003nh-3J for ged-emacs-devel@m.gmane-mx.org; Thu, 29 Sep 2022 19:37:04 +0200 Original-Received: from localhost ([::1]:55852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odxT4-0002fe-PG for ged-emacs-devel@m.gmane-mx.org; Thu, 29 Sep 2022 13:37:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odvgN-0002UE-El for emacs-devel@gnu.org; Thu, 29 Sep 2022 11:42:40 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:38767) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odvgL-00028g-Gn for emacs-devel@gnu.org; Thu, 29 Sep 2022 11:42:39 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 945B7240101 for ; Thu, 29 Sep 2022 17:42:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1664466153; bh=qYx9/vOqOsHj+oGAnNrYVq7IEJQZNttJQxbvaool2Ok=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=lygW2p2Mb+qGZBsmWueVrZRV/t6YDEAvTqM09RkhdJ4d0FOBsIGrtzj6E5HAFlBGO aB2Nfbe+eyDDikci/Wh6+Y00DLwTjhf3pU/8Zfb47BuebwwYoxAa90xwfTPJLNnpjj 4KtcXqLNI5ze2GDYKBVcqZokWvAhSG17Hs9SAPhca6xeKdzh8kSj68d88OoHw5IY/l fla8JRFpZ3Zn7F/rVhXSoevK2Czb0y+B+AwqK5O+V+p3PfrY88Qe2+95K+zRpdwpwF OgIMFID3Tbzk68A5dE2/WncO70Pnnf1cuDCh2/BiD7PUkYMyY0Bc2XuHm77ytoX+kS ZzW+gXCUEbXfA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Mdd0S0M01z9rxH; Thu, 29 Sep 2022 17:42:31 +0200 (CEST) In-Reply-To: <87wn9ntdi6.fsf@gmail.com> (Thuna's message of "Wed, 28 Sep 2022 23:06:41 +0200") Autocrypt: addr=philipk@posteo.net; prefer-encrypt=nopreference; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:296475 Archived-At: Thuna writes: > 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. It looks about right, but is random really the best we can do? Would it not be possible to try and find the most "distant" color to avoid accidentally assigning similar colors to different names. On the topic of rcirc-color, I had always assumed it would color all nicks by default, not when manually selected. There is /bright in IRC by default. It seems like it would be pretty easy to assign a random color depending on the hash of the nickname. > From 8bd21515f31a5e3cfedce623d8ebc9907b82b2a5 Mon Sep 17 00:00:00 2001 > From: Thuna > 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 > error. > --- > 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 > 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." > @@ -151,9 +153,11 @@ 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 > + (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)