Function: eca-chat--apply-face-to-line-prefixes

eca-chat--apply-face-to-line-prefixes is a natively compiled function defined in eca-chat-expandable.el.

Signature

(eca-chat--apply-face-to-line-prefixes START END FACE)

Documentation

Add FACE to every line-prefix string between START and END.

The face symbol itself is stored instead of its resolved background color, so prefixes follow theme switches (#301). FACE only defines a background, so existing foreground colors (e.g. icon faces) are preserved.

Source Code

;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat-expandable.el
(defun eca-chat--apply-face-to-line-prefixes (start end face)
  "Add FACE to every `line-prefix' string between START and END.
The face symbol itself is stored instead of its resolved background
color, so prefixes follow theme switches (#301).  FACE only defines a
background, so existing foreground colors (e.g. icon faces) are
preserved."
  (let ((pos start))
    (while (< pos end)
      (let* ((next-change (or (next-single-property-change pos 'line-prefix nil end) end))
             (prefix (get-text-property pos 'line-prefix)))
        (when (and prefix (stringp prefix))
          (let ((existing (get-text-property 0 'face prefix)))
            ;; Skip when already painted to avoid re-consing the same
            ;; face onto frequently repainted prefixes.
            (unless (or (eq existing face)
                        (and (listp existing) (memq face existing)))
              (let ((new-prefix (copy-sequence prefix)))
                (add-face-text-property 0 (length new-prefix) face nil new-prefix)
                (put-text-property pos next-change 'line-prefix new-prefix)))))
        (setq pos next-change)))))