emacs-diffs
[Top][All Lists]
Advanced

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

master c266c22b418 1/3: Fix regression in erc-nicks involving color pool


From: F. Jason Park
Subject: master c266c22b418 1/3: Fix regression in erc-nicks involving color pools
Date: Tue, 7 Jan 2025 20:39:02 -0500 (EST)

branch: master
commit c266c22b418541714889e85831de93c10a3c3fde
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>

    Fix regression in erc-nicks involving color pools
    
    * lisp/erc/erc-nicks.el (erc-nicks-colors): Tweak doc.
    (erc-nicks--create-pool-function): On graphic displays, set value to
    `erc-nicks--create-culled-pool', the original default.  This fixes a bug
    in which ERC mapped all pool members to a primary color, thus excluding
    the bulk of them.  Thanks to Trevor Arjeski for discovering it.
    (erc-nicks--create-coerced-pool): Mention the text-terminal-only
    requirement in doc.
    (erc-nicks-refresh): Improve doc.
    * test/lisp/erc/erc-nicks-tests.el (erc-nicks-tests--track-faces):
    Enable `erc-track-mode' prior to running body.
---
 lisp/erc/erc-nicks.el            | 26 ++++++++++++--------------
 test/lisp/erc/erc-nicks-tests.el |  1 +
 2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/lisp/erc/erc-nicks.el b/lisp/erc/erc-nicks.el
index a2f1c6f4fa8..3429bcb33af 100644
--- a/lisp/erc/erc-nicks.el
+++ b/lisp/erc/erc-nicks.el
@@ -156,7 +156,7 @@ List of colors as strings (hex or named) or, alternatively, 
a
 single symbol representing a set of colors, like that produced by
 the function `defined-colors', which ERC associates with the
 symbol `defined'.  Similarly, `all' tells ERC to use any 24-bit
-color.  To change the value mid-session, try
+color.  After updating this option's value mid-session, try
 \\[erc-nicks-refresh]."
   :type `(choice (const :tag "All 24-bit colors" all)
                  (const :tag "Defined terminal colors" defined)
@@ -382,16 +382,13 @@ Return a hex string."
                      erc-nicks-color-adjustments
                      (if (stringp color) (color-name-to-rgb color) color))))
 
-(defvar erc-nicks--create-pool-function #'erc-nicks--create-coerced-pool
+(defvar erc-nicks--create-pool-function (if (display-graphic-p)
+                                            #'erc-nicks--create-culled-pool
+                                          #'erc-nicks--create-coerced-pool)
   "Filter function for initializing the pool of colors.
 Takes a list of adjustment functions, such as those named in
-`erc-nicks-color-adjustments', and a list of colors.  Returns
-another list whose members need not be among the original
-candidates.  Users should note that this variable, along with its
-predefined function values, `erc-nicks--create-coerced-pool' and
-`erc-nicks--create-culled-pool', can be made public in a future
-version of this module, perhaps as a single user option, given
-sufficient demand.")
+`erc-nicks-color-adjustments', and a list of colors.  Returns another
+list whose members need not be among the original candidates.")
 
 (defun erc-nicks--create-coerced-pool (adjustments colors)
   "Return COLORS that fall within parameters heeded by ADJUSTMENTS.
@@ -401,7 +398,8 @@ That is, accept the nearest initially found as \"close 
enough,\"
 knowing that values may fall outside desired parameters and thus
 yield a larger pool than simple culling might produce.  When
 debugging, add candidates to `erc-nicks--colors-rejects' that map
-to the same output color as some prior candidate."
+to the same output color as some prior candidate.  Only effective
+on non-graphical displays."
   (let* ((seen (make-hash-table :test #'equal))
          (erc-nicks-color-adjustments adjustments)
          pool)
@@ -675,10 +673,10 @@ Abandon search after examining LIMIT faces."
 
 (defun erc-nicks-refresh (debug)
   "Recompute faces for all nicks on current network.
-With DEBUG, review affected faces or colors.  Exactly which of
-the two depends on the value of `erc-nicks-colors'.  Note that
-the list of rejected faces may include duplicates of accepted
-ones."
+With DEBUG (\\[universal-argument]), review affected faces or colors,
+exactly which depends on the value of `erc-nicks-colors'.  Expect users
+to know that the list of rejected faces may include candidates that are
+effectively duplicates because they map to already admitted ones."
   (interactive "P")
   (unless (derived-mode-p 'erc-mode)
     (user-error "Not an ERC buffer"))
diff --git a/test/lisp/erc/erc-nicks-tests.el b/test/lisp/erc/erc-nicks-tests.el
index 1e9808d1bed..a6d2f6034d4 100644
--- a/test/lisp/erc/erc-nicks-tests.el
+++ b/test/lisp/erc/erc-nicks-tests.el
@@ -579,6 +579,7 @@
   (defvar erc-track--normal-faces)
 
   (erc-tests-common-make-server-buf)
+  (erc-track-mode +1)
   (erc-nicks-mode +1)
 
   (let ((erc-modules (cons 'nicks erc-modules))



reply via email to

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