Function: erc-with-initialized-session

erc-with-initialized-session is a macro defined in erc-common.el.gz.

Signature

(erc-with-initialized-session &rest BODY)

Documentation

Run BODY in all ERC buffers if outside erc-open and soon otherwise.

When inside erc-open, run BODY after session variables have been initialized and after all erc-mode-hook members but before any after-change-major-mode-hook members. Expect caller to know this is only useful in global-module setup and that they're still responsible for teardown, which is often done with erc-buffer-do or similar.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-common.el.gz
(defmacro erc-with-initialized-session (&rest body)
  "Run BODY in all ERC buffers if outside `erc-open' and soon otherwise.
When inside `erc-open', run BODY after session variables have been
initialized and after all `erc-mode-hook' members but before any
`after-change-major-mode-hook' members.  Expect caller to know this is
only useful in global-module setup and that they're still responsible
for teardown, which is often done with `erc-buffer-do' or similar."
  (let ((fn (make-symbol "fn"))
        (hook-var (make-symbol "hook-var")))
    `(let ((,fn (lambda () ,@body)))
       (if erc--updating-modules-p
           (let ((,hook-var (gensym "erc--oneoff-major-mode-hook-")))
             (set ,hook-var ,fn)
             (push ,hook-var delayed-mode-hooks))
         (erc-buffer-do ,fn)))))