Function: erc--define-catalog

erc--define-catalog is a macro defined in erc-common.el.gz.

Signature

(erc--define-catalog NAME ENTRIES)

Documentation

Define erc-display-message formatting templates for NAME, a symbol.

See erc-define-message-format-catalog for the meaning of ENTRIES, an alist, and erc-tests-common-pp-propertized-parts in tests/lisp/erc/erc-tests.el for a convenience command to convert a literal string into a sequence of propertize forms, which are much easier to review and edit. When ENTRIES begins with a sequence of keyword-value pairs remove them and consider their evaluated values before processing the alist proper.

Currently, the only recognized keyword is :parent, which tells ERC to search recursively for a given template key using the keyword's associated value, another catalog symbol, if not found in catalog NAME.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-common.el.gz
;; This internal variant exists as a transition aid to avoid
;; immediately having to reflow lengthy definition lists, like the one
;; in erc.el.  These sites should switch to using the public macro
;; when undergoing their next major edit.
(defmacro erc--define-catalog (name entries)
  "Define `erc-display-message' formatting templates for NAME, a symbol.

See `erc-define-message-format-catalog' for the meaning of
ENTRIES, an alist, and `erc-tests-common-pp-propertized-parts' in
tests/lisp/erc/erc-tests.el for a convenience command to convert
a literal string into a sequence of `propertize' forms, which are
much easier to review and edit.  When ENTRIES begins with a
sequence of keyword-value pairs remove them and consider their
evaluated values before processing the alist proper.

Currently, the only recognized keyword is `:parent', which tells
ERC to search recursively for a given template key using the
keyword's associated value, another catalog symbol, if not found
in catalog NAME."
  (declare (indent 1))
  (let (out)
    (while (keywordp (car entries))
      (push (pcase-exhaustive (pop entries)
              (:parent `(put ',name 'erc--base-format-catalog
                             ,(pop entries))))
            out))
    (dolist (e entries (cons 'progn (nreverse out)))
      (push `(defvar ,(intern (format "erc-message-%s-%s" name (car e)))
               ,(cdr e)
               ,(let* ((first (format "Message template for key `%s'" (car e)))
                       (last (format "catalog `%s'." name))
                       (combined (concat first " in " last)))
                  (if (< (length combined) 80)
                      combined
                    (concat first ".\nFor use with " last))))
            out))))