Function: count-sentences

count-sentences is a byte-compiled function defined in paragraphs.el.gz.

Signature

(count-sentences START END)

Documentation

Count sentences in current buffer from START to END.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/paragraphs.el.gz
(defun count-sentences (start end)
  "Count sentences in current buffer from START to END."
  (let ((sentences 0)
        (inhibit-field-text-motion t))
    (save-excursion
      (save-restriction
        (narrow-to-region start end)
        (goto-char (point-min))
        (let* ((prev (point))
               (next (forward-sentence)))
          (while (and (not (null next))
                      (not (= prev next)))
            (setq prev next
                  next (ignore-errors (forward-sentence))
                  sentences (1+ sentences))))
        ;; Remove last possibly empty sentence
        (when (/= (skip-chars-backward " \t\n") 0)
          (setq sentences (1- sentences)))
	sentences))))