Function: rcirc-handler-BATCH

rcirc-handler-BATCH is a byte-compiled function defined in rcirc.el.gz.

Signature

(rcirc-handler-BATCH PROCESS SENDER ARGS TEXT)

Documentation

Open or close a batch.

ARGS should have the form (tag type . parameters) when starting a batch, or (tag) when closing a batch. PROCESS is the process object for the current connection.

Source Code

;; Defined in /usr/src/emacs/lisp/net/rcirc.el.gz
(defun rcirc-handler-BATCH (process _sender args _text)
  "Open or close a batch.
ARGS should have the form (tag type . parameters) when starting a
batch, or (tag) when closing a batch.  PROCESS is the process
object for the current connection."
  (with-rcirc-process-buffer process
    (let ((type (cadr args))
          (id (substring (car args) 1)))
      (cond
       ((= (aref (car args) 0) ?+)      ;start a new batch
        (when (assoc id rcirc-batch-attributes)
          (error "Starting batch with already used ID"))
        (setf (alist-get id rcirc-batch-attributes nil nil #'string=)
              (cons type (cddr args))))
       ((= (aref (car args) 0) ?-)      ;close a batch
        (unless (assoc id rcirc-batch-attributes)
          (error "Closing a unknown batch"))
        (let ((type (car (alist-get id rcirc-batch-attributes
                                    nil nil #'string=))))
          (when (eq (car (alist-get type rcirc-supported-batch-types
                                    nil nil #'string=))
                    'deferred)
            (let ((messages (alist-get id rcirc-batched-messages
                                       nil nil #'string=))
                  (bhandler (intern-soft (concat "rcirc-batch-handler-" type))))
              (if (fboundp bhandler)
                  (funcall bhandler process id (nreverse messages))
                (dolist (message (nreverse messages))
                  (let ((cmd (nth 0 message))
                        (process (nth 1 message))
                        (sender (nth 2 message))
                        (args (nth 3 message))
                        (text (nth 4 message))
                        (rcirc-message-tags (nth 5 message)))
                    (if-let (handler (intern-soft (concat "rcirc-handler-" cmd)))
                        (funcall handler process sender args text)
                      (rcirc-handler-generic process cmd sender args text))))))))
        (setq rcirc-batch-attributes
              (delq (assoc id rcirc-batch-attributes)
                    rcirc-batch-attributes)
              rcirc-batched-messages
              (delq (assoc id rcirc-batched-messages)
                    rcirc-batched-messages)))))))