Function: erc--warn-once-before-connect

erc--warn-once-before-connect is a byte-compiled function defined in erc.el.gz.

Signature

(erc--warn-once-before-connect MODE-VAR &rest ARGS)

Documentation

Display an "error notice" once.

Expect ARGS to be erc-button--display-error-notice-with-keys compatible parameters, except without any leading buffers or processes. If the current buffer has an erc-server-process, print the notice immediately. Otherwise, if it's a server buffer without a process, arrange to do so on erc-connect-pre-hook. In non-ERC buffers, so long as MODE-VAR belongs to a global module, try again at most once the next time erc-mode-hook runs for any connection.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
(defun erc--warn-once-before-connect (mode-var &rest args)
  "Display an \"error notice\" once.
Expect ARGS to be `erc-button--display-error-notice-with-keys'
compatible parameters, except without any leading buffers or processes.
If the current buffer has an `erc-server-process', print the notice
immediately.  Otherwise, if it's a server buffer without a process,
arrange to do so on `erc-connect-pre-hook'.  In non-ERC buffers, so long
as MODE-VAR belongs to a global module, try again at most once the next
time `erc-mode-hook' runs for any connection."
  (declare (indent 1))
  (cl-assert (stringp (car args)))
  (if (derived-mode-p 'erc-mode)
      (unless (or (erc-with-server-buffer ; needs `erc-server-process'
                    (apply #'erc-button--display-error-notice-with-keys
                           (current-buffer) args)
                    t)
                  erc--target) ; unlikely
        (let (hook)
          (setq hook
                (lambda (_)
                  (remove-hook 'erc-connect-pre-hook hook t)
                  (apply #'erc-button--display-error-notice-with-keys args)))
          (add-hook 'erc-connect-pre-hook hook nil t)))
    (when (custom-variable-p mode-var)
      (let (hook)
        (setq hook (lambda ()
                     (remove-hook 'erc-mode-hook hook)
                     (apply #'erc--warn-once-before-connect 'erc-fake args)))
        (add-hook 'erc-mode-hook hook)))))