Function: erc-load-irc-script-lines

erc-load-irc-script-lines is an autoloaded and byte-compiled function defined in erc-goodies.el.gz.

Signature

(erc-load-irc-script-lines LINES &optional FORCE NOEXPAND)

Documentation

Process a list of LINES as prompt input submissions.

If optional NOEXPAND is non-nil, do not expand script-specific substitution sequences via erc-process-script-line and instead process LINES as literal prompt input. With FORCE, bypass flood protection.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-goodies.el.gz
;;;###autoload
(defun erc-load-irc-script-lines (lines &optional force noexpand)
  "Process a list of LINES as prompt input submissions.
If optional NOEXPAND is non-nil, do not expand script-specific
substitution sequences via `erc-process-script-line' and instead
process LINES as literal prompt input.  With FORCE, bypass flood
protection."
  ;; The various erc-cmd-CMDs were designed to return non-nil when
  ;; their command line should be echoed.  But at some point, these
  ;; handlers began displaying their own output, which naturally
  ;; appeared *above* the echoed command.  This tries to intercept
  ;; these insertions, deferring them until the command has returned
  ;; and its command line has been printed.
  (cl-assert (eq 'erc-mode major-mode))
  (let ((args (and erc-script-args
                   (if (string-match "^ " erc-script-args)
                       (substring erc-script-args 1)
                     erc-script-args))))
    (with-silent-modifications
      (dolist (line lines)
        (erc-log (concat "erc-load-script: CMD: " line))
        (unless (string-match (rx bot (* (syntax whitespace)) eot) line)
          (unless noexpand
            (setq line (erc-process-script-line line args)))
          (let ((erc--current-line-input-split (erc--make-input-split line))
                calls insertp)
            (add-function :around (local 'erc--send-message-nested-function)
                          (lambda (&rest args) (push args calls))
                          '((name . erc-script-lines-fn) (depth . -80)))
            (add-function :around (local 'erc--send-action-function)
                          (lambda (&rest args) (push args calls))
                          '((name . erc-script-lines-fn) (depth . -80)))
            (setq insertp
                  (unwind-protect (erc-process-input-line line force)
                    (remove-function (local 'erc--send-action-function)
                                     'erc-script-lines-fn)
                    (remove-function (local 'erc--send-message-nested-function)
                                     'erc-script-lines-fn)))
            (when (and insertp erc-script-echo)
              (erc--command-indicator-display line)
              (dolist (call calls)
                (apply (car call) (cdr call))))))))))