Function: completion-preview--bg-color

completion-preview--bg-color is a byte-compiled function defined in completion-preview.el.gz.

Signature

(completion-preview--bg-color POS)

Documentation

Return background color at POS.

Source Code

;; Defined in /usr/src/emacs/lisp/completion-preview.el.gz
(defun completion-preview--bg-color (pos)
  "Return background color at POS."
  ;; This takes into account face remappings and multiple overlays that
  ;; specify the `face' property, unlike `background-color-at-point'.
  (catch 'found
    (named-let rec ((spec (seq-keep (lambda (ov) (overlay-get ov 'face))
                                    (overlays-at pos t)))
                    (trace nil))
      (dolist (face (if (face-list-p spec) spec (list spec)))
        (let (cur)
          (if (and (setq cur (alist-get face face-remapping-alist))
                   (not (memq face trace)))
              (rec cur (cons face trace))
            (cond ((and face (symbolp face))
                   (let ((value (face-attribute face :background nil t)))
                     (unless (member value '(nil "unspecified-bg" unspecified))
                       (throw 'found value))))
                  ((consp face)
                   (when-let* ((value (or (cdr (memq 'background-color face))
                                          (cadr (memq :background face)))))
                     (throw 'found value)))))))
      (unless trace
        (save-excursion
          (goto-char pos)
          (font-lock-ensure (pos-bol) (pos-eol)))
        (rec (or (and font-lock-mode
                      (get-text-property pos 'font-lock-face))
                 (get-text-property pos 'face))
             '(nil))
        (rec 'default '(nil))))))