Function: erc-split-line

erc-split-line is a byte-compiled function defined in erc-backend.el.gz.

Signature

(erc-split-line LONGLINE)

Documentation

Return a list of lines which are not too long for IRC.

The length is specified in erc-split-line-length.

Currently this is called by erc-send-input.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-backend.el.gz
;; From Circe
(defun erc-split-line (longline)
  "Return a list of lines which are not too long for IRC.
The length is specified in `erc-split-line-length'.

Currently this is called by `erc-send-input'."
  (let* ((coding (erc-coding-system-for-target nil))
         (charset (if (consp coding) (car coding) coding)))
    (with-temp-buffer
      (insert longline)
      ;; The line lengths are in octets, not characters (because these
      ;; are server protocol limits), so we have to first make the
      ;; text into bytes, then fold the bytes on "word" boundaries,
      ;; and then make the bytes into text again.
      (encode-coding-region (point-min) (point-max) charset)
      (let ((fill-column erc-split-line-length))
        (fill-region (point-min) (point-max)
                     nil t))
      (decode-coding-region (point-min) (point-max) charset)
      (split-string (buffer-string) "\n"))))