]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix regression in erc-nicks involving color pools
authorF. Jason Park <jp@neverwas.me>
Mon, 6 Jan 2025 00:58:50 +0000 (16:58 -0800)
committerEshel Yaron <me@eshelyaron.com>
Wed, 8 Jan 2025 08:58:20 +0000 (09:58 +0100)
* 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.

(cherry picked from commit c266c22b418541714889e85831de93c10a3c3fde)

lisp/erc/erc-nicks.el
test/lisp/erc/erc-nicks-tests.el

index a59d11ca26b0af222a4f8fb7188f67806eeb2f6a..30f9be1bda5fc019b480c0654ff99f5b28c3c3c9 100644 (file)
@@ -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"))
index 1e9808d1bed9eb465a4f5919bb959de533640bb8..a6d2f6034d4ec9d48e3929bcf691adb818543571 100644 (file)
   (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))