Function: erc-send-input

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

Signature

(erc-send-input INPUT &optional SKIP-WS-CHK)

Documentation

Treat INPUT as typed in by the user.

It is assumed that the input and the prompt is already deleted. Return non-nil only if we actually send anything.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
(defun erc-send-input (input &optional skip-ws-chk)
  "Treat INPUT as typed in by the user.
It is assumed that the input and the prompt is already deleted.
Return non-nil only if we actually send anything."
  ;; Handle different kinds of inputs
  (if (and (not skip-ws-chk)
           (erc--check-prompt-input-for-multiline-blanks
            input (split-string input erc--input-line-delim-regexp)))
      (when erc-warn-about-blank-lines
        (message "Blank line - ignoring...") ; compat
        (beep))
    ;; This dynamic variable is used by `erc-send-pre-hook'.  It's
    ;; obsolete, and when it's finally removed, this binding should
    ;; also be removed.
    (with-suppressed-warnings ((lexical str))
      (defvar str))
    (let ((str input)
          (erc-insert-this t)
	  (erc-send-this t)
	  state)
      ;; The calling convention of `erc-send-pre-hook' is that it
      ;; should change the dynamic variable `str' or set
      ;; `erc-send-this' to nil.  This has now been deprecated:
      ;; Instead `erc-pre-send-functions' is used as a filter to do
      ;; allow both changing and suppressing the string.
      (run-hook-with-args 'erc-send-pre-hook input)
      (setq state (make-erc-input :string str ;May be != from `input' now!
				  :insertp erc-insert-this
				  :sendp erc-send-this))
      (run-hook-with-args 'erc-pre-send-functions state)
      (setq state (make-erc--input-split
                   :string (erc-input-string state)
                   :insertp (erc-input-insertp state)
                   :sendp (erc-input-sendp state)
                   :lines (split-string (erc-input-string state)
                                        erc--input-line-delim-regexp)
                   :cmdp (string-match erc-command-regexp
                                       (erc-input-string state))))
      (run-hook-with-args 'erc--pre-send-split-functions state)
      (when (and (erc-input-sendp state)
                 erc-send-this)
        (let ((lines (erc--input-split-lines state)))
          (if (and (erc--input-split-cmdp state) (not (cdr lines)))
              (erc-process-input-line (concat (car lines) "\n") t nil)
            (dolist (line lines)
              (dolist (line (or (and erc-flood-protect (erc-split-line line))
                                (list line)))
                (when (erc-input-insertp state)
                  (erc-display-msg line))
                (erc-process-input-line (concat line "\n")
                                        (null erc-flood-protect) t))))
          t)))))