Function: erc--run-send-hooks

erc--run-send-hooks is a byte-compiled function defined in erc.el.gz.

Signature

(erc--run-send-hooks LINES-OBJ)

Documentation

Run send-related hooks that operate on the entire prompt input.

Sequester some of the back and forth involved in honoring old interfaces, such as the reconstituting and re-splitting of multiline input. Optionally readjust lines to protocol length limits and pad empty ones, knowing full well that additional processing may still corrupt messages before they reach the send queue. Expect LINES-OBJ to be an erc--input-split object.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
(defun erc--run-send-hooks (lines-obj)
  "Run send-related hooks that operate on the entire prompt input.
Sequester some of the back and forth involved in honoring old
interfaces, such as the reconstituting and re-splitting of
multiline input.  Optionally readjust lines to protocol length
limits and pad empty ones, knowing full well that additional
processing may still corrupt messages before they reach the send
queue.  Expect LINES-OBJ to be an `erc--input-split' object."
  (progn ; FIXME remove `progn' after code review.
    (with-suppressed-warnings ((lexical str) (obsolete erc-send-this))
      (defvar str) ; see note in string `erc-send-input'.
      (let* ((str (string-join (erc--input-split-lines lines-obj) "\n"))
             (erc-send-this (erc--input-split-sendp lines-obj))
             (erc-insert-this (erc--input-split-insertp lines-obj))
             (state (progn
                      ;; This may change `str' and `erc-*-this'.
                      (run-hook-with-args 'erc-send-pre-hook str)
                      (make-erc-input
                       :string str
                       :insertp erc-insert-this
                       :sendp erc-send-this
                       :substxt (erc--input-split-substxt lines-obj)
                       :refoldp (erc--input-split-refoldp lines-obj)))))
        (run-hook-with-args 'erc-pre-send-functions state)
        (setf (erc--input-split-sendp lines-obj) (erc-input-sendp state)
              (erc--input-split-insertp lines-obj) (erc-input-insertp state)
              (erc--input-split-substxt lines-obj) (erc-input-substxt state)
              (erc--input-split-refoldp lines-obj) (erc-input-refoldp state)
              ;; See note in test of same name re trailing newlines.
              (erc--input-split-lines lines-obj)
              (let ((lines (split-string (erc-input-string state)
                                         erc--input-line-delim-regexp)))
                (if erc--allow-empty-outgoing-lines-p
                    lines
                  (cl-nsubst " " "" lines :test #'equal))))
        (when (erc--input-split-refoldp lines-obj)
          (erc--split-lines lines-obj)))))
  (when (and (erc--input-split-cmdp lines-obj)
             (cdr (erc--input-split-lines lines-obj)))
    (user-error "Multiline command detected" ))
  lines-obj)