Function: rcirc-color-attributes

rcirc-color-attributes is a byte-compiled function defined in rcirc.el.gz.

Signature

(rcirc-color-attributes SENDER RESPONSE)

Documentation

Highlight IRC color-codes, indicated by ASCII control codes.

Source Code

;; Defined in /usr/src/emacs/lisp/net/rcirc.el.gz
(defun rcirc-color-attributes (_sender _response)
  "Highlight IRC color-codes, indicated by ASCII control codes."
  (while (re-search-forward
          (rx #x03
              (? (group (= 2 digit)) (? "," (group (= 2 digit))))
              (*? nonl)
              (or #x03 #x0f eol))
          nil t)
    (let (foreground background)
      (when-let ((fg-raw (match-string 1))
                 (fg (string-to-number fg-raw))
                 ((<= 0 fg (1- (length rcirc-color-codes)))))
        (setq foreground (aref rcirc-color-codes fg)))
      (when-let ((bg-raw (match-string 2))
                 (bg (string-to-number bg-raw))
                 ((<= 0 bg (1- (length rcirc-color-codes)))))
        (setq background (aref rcirc-color-codes bg)))
      (rcirc-add-face (match-beginning 0) (match-end 0)
                           `(face (:foreground
                                   ,foreground
                                   :background
                                   ,background))))))