Function: erc-compat--defer-format-spec-in-buffer

erc-compat--defer-format-spec-in-buffer is a macro defined in erc-compat.el.gz.

Signature

(erc-compat--defer-format-spec-in-buffer &rest SPEC)

Documentation

Transform SPEC forms into functions that run in the current buffer.

For convenience, ensure function wrappers return "" as a fallback.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-compat.el.gz
(defmacro erc-compat--defer-format-spec-in-buffer (&rest spec)
  "Transform SPEC forms into functions that run in the current buffer.
For convenience, ensure function wrappers return \"\" as a
fallback."
  (cl-check-type (car spec) cons)
  (let ((buffer (make-symbol "buffer")))
    `(let ((,buffer (current-buffer)))
       ,(list '\`
              (mapcar
               (pcase-lambda (`(,k . ,v))
                 (cons k
                       (list '\,(if (>= emacs-major-version 29)
                                    `(lambda ()
                                       (or (if (eq ,buffer (current-buffer))
                                               ,v
                                             (with-current-buffer ,buffer
                                               ,v))
                                           ""))
                                  `(or ,v "")))))
               spec)))))