Function: erc-nicks--create-coerced-pool

erc-nicks--create-coerced-pool is a byte-compiled function defined in erc-nicks.el.gz.

Signature

(erc-nicks--create-coerced-pool ADJUSTMENTS COLORS)

Documentation

Return COLORS that fall within parameters heeded by ADJUSTMENTS.

Apply ADJUSTMENTS and dedupe after replacing adjusted values with those nearest defined for the terminal. Only perform one pass. 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. Only effective on non-graphical displays.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-nicks.el.gz
(defun erc-nicks--create-coerced-pool (adjustments colors)
  "Return COLORS that fall within parameters heeded by ADJUSTMENTS.
Apply ADJUSTMENTS and dedupe after replacing adjusted values with
those nearest defined for the terminal.  Only perform one pass.
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.  Only effective
on non-graphical displays."
  (let* ((seen (make-hash-table :test #'equal))
         (erc-nicks-color-adjustments adjustments)
         pool)
    (dolist (color colors)
      (let ((quantized (car (tty-color-approximate
                             (color-values (erc-nicks--reduce color))))))
        (if (gethash quantized seen)
            (when erc-nicks--colors-rejects
              (push color erc-nicks--colors-rejects))
          (push quantized pool)
          (puthash quantized color seen))))
    (nreverse pool)))