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 NEW-FACES to be a cons cell whose car is a hash table mapping
faces present in the applicable region to t and whose cdr is its car's
contents ordered from most recently seen (later in the buffer) to
earliest. Expect RANKS to be a cons cell whose car is a hash table
similar to erc-track--priority-faces and whose cdr is a list of
prioritized faces resembling erc-track-faces-priority-list. Expect
NORMALS to be a hash table mapping faces to themselves. In general, act
identically to erc-track-select-mode-line-face, except appeal to
erc-track--alt-normals-function if it's non-nil, and fall back on
reconsidering only NEW-FACES appearing in NORMALS when CUR-FACE is
itself "normal" and outranks all NEW-FACES. That is, choose the first
among RANKS in both NEW-FACES and NORMALS not equal to CUR-FACE.
Failing that, choose the first face in both NEW-FACES and NORMALS.
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 NEW-FACES to be a cons cell whose car is a hash table mapping
faces present in the applicable region to t and whose cdr is its car's
contents ordered from most recently seen (later in the buffer) to
earliest. Expect RANKS to be a cons cell whose car is a hash table
similar to `erc-track--priority-faces' and whose cdr is a list of
prioritized faces resembling `erc-track-faces-priority-list'. Expect
NORMALS to be a hash table mapping faces to themselves. In general, act
identically to `erc-track-select-mode-line-face', except appeal to
`erc-track--alt-normals-function' if it's non-nil, and fall back on
reconsidering only NEW-FACES appearing in NORMALS when CUR-FACE is
itself \"normal\" and outranks all NEW-FACES. That is, choose the first
among RANKS in both NEW-FACES and NORMALS not equal to CUR-FACE.
Failing that, choose the first face in both NEW-FACES and NORMALS."
(cl-check-type erc-track-ignore-normal-contenders-p null)
(cl-check-type new-faces cons)
;; Choose the highest ranked face in `erc-track-faces-priority-list'
;; that's either `cur-face' itself or one appearing in the region
;; being processed.
(when-let* ((choice (catch 'face
(dolist (candidate (cdr 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 ranks normals))
;; If `choice' is still `cur-face' and also a "normal", attempt
;; to choose another normal in order to produce the flickering
;; effect mentioned in the doc of `erc-track-faces-normal-list'.
(and (equal choice cur-face)
(gethash choice normals)
(catch 'face
;; If ranked "normal" faces other than `choice' appear in
;; the region, return the most important one.
(progn
(dolist (candidate (cdr ranks))
(when (and (not (equal candidate choice))
(gethash candidate (car new-faces))
(gethash choice normals))
(throw 'face candidate)))
;; Otherwise, go with any "normal" face other than
;; `choice' in the region.
(dolist (candidate (cdr new-faces))
(when (and (not (equal candidate choice))
(gethash candidate normals))
(throw 'face candidate))))))
choice)))