Function: erc--count-blank-lines

erc--count-blank-lines is a byte-compiled function defined in erc.el.gz.

Signature

(erc--count-blank-lines LINES)

Documentation

Report on the number of whitespace-only and empty LINES.

Return a list of (BLANKS TO-PAD TO-STRIP). Expect caller to know that BLANKS includes non-empty whitespace-only lines and that no padding or stripping has yet occurred.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
(defun erc--count-blank-lines (lines)
  "Report on the number of whitespace-only and empty LINES.
Return a list of (BLANKS TO-PAD TO-STRIP).  Expect caller to know
that BLANKS includes non-empty whitespace-only lines and that no
padding or stripping has yet occurred."
  (let ((real 0) (total 0) (pad 0) (strip 0))
    (dolist (line lines)
      (if (string-match (rx bot (* (in " \t\f")) eot) line)
          (progn
            (cl-incf total)
            (if (zerop (match-end 0))
                (cl-incf strip)
              (cl-incf pad strip)
              (setq strip 0)))
        (cl-incf real)
        (unless (zerop strip)
          (cl-incf pad strip)
          (setq strip 0))))
    (when (and (zerop real) (not (zerop total)) (= total (+ pad strip)))
      (cl-incf strip (1- pad))
      (setq pad 1))
    (list total pad strip)))