Function: erc-track--setup
erc-track--setup is a byte-compiled function defined in
erc-track.el.gz.
Signature
(erc-track--setup)
Documentation
Initialize a buffer for use with the track module.
If this is a server buffer or either erc-track-faces-normal-list or
erc-track-faces-priority-list is locally bound, create a new cache
table with corresponding local variable erc-track--normal-faces or
erc-track--priority-faces. Otherwise, in target buffers with no local
binding, set the cache variable's local value to that of server's.
Source Code
;; Defined in /usr/src/emacs/lisp/erc/erc-track.el.gz
(defun erc-track--setup ()
"Initialize a buffer for use with the `track' module.
If this is a server buffer or either `erc-track-faces-normal-list' or
`erc-track-faces-priority-list' is locally bound, create a new cache
table with corresponding local variable `erc-track--normal-faces' or
`erc-track--priority-faces'. Otherwise, in target buffers with no local
binding, set the cache variable's local value to that of server's."
(if erc-track-mode
(let (warnp)
;; Don't bother warning users who've disabled `button'.
(unless (or erc--target
(not (or (bound-and-true-p erc-button-mode)
(memq 'button erc-modules))))
(dolist (opt '(erc-track-faces-normal-list
erc-track-faces-priority-list))
(when (local-variable-p opt)
(erc-track--massage-nick-button-faces opt (symbol-value opt)
#'set))
(when-let* ((migrations (get opt 'erc-track--obsolete-faces))
((consp migrations)))
(push (cons opt
(mapcar (pcase-lambda (`(,old . ,new))
(format (if new "changed %s to %s"
"removed %s")
old new))
migrations))
warnp)
(put opt 'erc-track--obsolete-faces nil)))
(when warnp
(pcase-dolist (`(,opt . ,migrations) warnp)
(erc--warn-once-before-connect 'erc-track-mode
"Option `%S' contains "
(if (cdr migrations) "obsolete items." "an obsolete item.")
" ERC has done the following for the current session: %s."
" Please review these changes and, if convinced,"
" silence this message by saving the current value."
opt (string-join migrations ", ")))))
;; Set `erc-track--priority-faces' cache to new or shared value.
(let* ((localp (and erc--target
(local-variable-p 'erc-track-faces-priority-list)))
(existing (erc-with-server-buffer erc-track--priority-faces))
(table (or (and (not localp) existing)
(let ((p 0))
(map-into
(mapcar (lambda (f) (cons f (cl-incf p)))
(append erc-track--attn-faces
erc-track-faces-priority-list))
`(hash-table :test equal))))))
(setq erc-track--priority-faces table)
(unless (or localp existing)
(erc-with-server-buffer (setq erc-track--priority-faces table))))
;; Likewise for `erc-track--normal-faces' cache.
(let* ((localp (and erc--target
(local-variable-p 'erc-track-faces-normal-list)))
(existing (erc-with-server-buffer erc-track--normal-faces))
(table (or (and (not localp) existing)
(map-into (mapcar (lambda (f) (cons f f))
erc-track-faces-normal-list)
`(hash-table :test equal
:weakness value)))))
(setq erc-track--normal-faces table)
(unless (or localp existing)
(erc-with-server-buffer (setq erc-track--normal-faces table)))))
(kill-local-variable 'erc-track--priority-faces)
(kill-local-variable 'erc-track--normal-faces)))