Function: erc-track--select-mode-line-face
erc-track--select-mode-line-face is a byte-compiled function defined
in erc-track.el.gz.
Signature
(erc-track--select-mode-line-face CUR-FACE NEW-FACES RANKS NORMALS)
Documentation
Return CUR-FACE or a replacement for displaying in the mode-line, or nil.
Expect RANKS to be a list of faces and both NORMALS and the car
of NEW-FACES to be hash tables mapping faces to non-nil values.
Assume the latter's makeup and that of RANKS to resemble
erc-track-faces-normal-list and erc-track-faces-priority-list.
If NEW-FACES has a cdr, expect it to be its car's contents
ordered from most recently seen (later in the buffer) to
earliest. In general, act like erc-track-select-mode-line-face
except appeal to erc-track--alt-normals-function if it's
non-nil, falling back on reconsidering NEW-FACES when CUR-FACE
outranks all its members. That is, choose the first among RANKS
in NEW-FACES not equal to CUR-FACE. Failing that, choose the
first face in NEW-FACES that's also in NORMALS, assuming
NEW-FACES has a cdr.
Source Code
;; Defined in /usr/src/emacs/lisp/erc/erc-track.el.gz
(defun erc-track--select-mode-line-face (cur-face new-faces ranks normals)
"Return CUR-FACE or a replacement for displaying in the mode-line, or nil.
Expect RANKS to be a list of faces and both NORMALS and the car
of NEW-FACES to be hash tables mapping faces to non-nil values.
Assume the latter's makeup and that of RANKS to resemble
`erc-track-faces-normal-list' and `erc-track-faces-priority-list'.
If NEW-FACES has a cdr, expect it to be its car's contents
ordered from most recently seen (later in the buffer) to
earliest. In general, act like `erc-track-select-mode-line-face'
except appeal to `erc-track--alt-normals-function' if it's
non-nil, falling back on reconsidering NEW-FACES when CUR-FACE
outranks all its members. That is, choose the first among RANKS
in NEW-FACES not equal to CUR-FACE. Failing that, choose the
first face in NEW-FACES that's also in NORMALS, assuming
NEW-FACES has a cdr."
(cl-check-type erc-track-ignore-normal-contenders-p null)
(cl-check-type new-faces cons)
(when-let ((choice (catch 'face
(dolist (candidate ranks)
(when (or (equal candidate cur-face)
(gethash candidate (car new-faces)))
(throw 'face candidate))))))
(or (and erc-track--alt-normals-function
(funcall erc-track--alt-normals-function
cur-face choice new-faces normals))
(and (equal choice cur-face)
(gethash choice normals)
(catch 'face
(progn
(dolist (candidate ranks)
(when (and (not (equal candidate choice))
(gethash candidate (car new-faces))
(gethash choice normals))
(throw 'face candidate)))
(dolist (candidate (cdr new-faces))
(when (and (not (equal candidate choice))
(gethash candidate normals))
(throw 'face candidate))))))
choice)))