Function: erc-nicks-refresh

erc-nicks-refresh is an interactive and byte-compiled function defined in erc-nicks.el.gz.

Signature

(erc-nicks-refresh DEBUG)

Documentation

Recompute faces for all nicks on current network.

With DEBUG, review affected faces or colors. Exactly which of the two depends on the value of erc-nicks-colors. Note that the list of rejected faces may include duplicates of accepted ones.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-nicks.el.gz
(defun erc-nicks-refresh (debug)
  "Recompute faces for all nicks on current network.
With DEBUG, review affected faces or colors.  Exactly which of
the two depends on the value of `erc-nicks-colors'.  Note that
the list of rejected faces may include duplicates of accepted
ones."
  (interactive "P")
  (unless (derived-mode-p 'erc-mode)
    (user-error "Not an ERC buffer"))
  (erc-with-server-buffer
    (unless erc-nicks-mode (user-error "Module `nicks' disabled"))
    (let ((erc-nicks--colors-rejects (and debug (list t))))
      (erc-nicks--init-pool)
      (unless erc-nicks--colors-pool
        (user-error "Pool empty: all colors rejected"))
      (dolist (nick (hash-table-keys erc-nicks--face-table))
        ;; User-tuned faces do not have an `erc-nicks--key' property.
        (when-let ((face (gethash nick erc-nicks--face-table))
                   (key (get face 'erc-nicks--key)))
          (setq key (erc-nicks--gen-key-from-format-spec nick))
          (put face 'erc-nicks--key key)
          (set-face-foreground face (erc-nicks--determine-color key))))
      (when debug
        (if (eq erc-nicks-colors 'all)
            (erc-nicks-list-faces)
          (pcase-dolist (`(,name ,pool)
                         `(("*erc-nicks-pool*" ,erc-nicks--colors-pool)
                           ("*erc-nicks-rejects*"
                            ,(cdr (nreverse erc-nicks--colors-rejects)))))
            (when (buffer-live-p (get-buffer name))
              (kill-buffer name))
            (when pool
              (save-excursion
                (list-colors-display
                 pool name
                 (lambda (c)
                   (message "contrast: %.3f :saturation: %.3f"
                            (erc-nicks--get-contrast c)
                            (cadr (apply #'color-rgb-to-hsl
                                         (color-name-to-rgb c))))))))))))))