Function: count-words-region

count-words-region is an interactive and byte-compiled function defined in simple.el.gz.

Signature

(count-words-region START END &optional ARG)

Documentation

Count the number of words in the region.

If called interactively, print a message reporting the number of lines, words, and characters in the region (whether or not the region is active); with prefix ARG, report for the entire buffer rather than the region.

If called from Lisp, return the number of words between positions START and END.

View in manual

Probably introduced at or before Emacs version 24.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun count-words-region (start end &optional arg)
  "Count the number of words in the region.
If called interactively, print a message reporting the number of
lines, words, and characters in the region (whether or not the
region is active); with prefix ARG, report for the entire buffer
rather than the region.

If called from Lisp, return the number of words between positions
START and END."
  (interactive (if current-prefix-arg
		   (list nil nil current-prefix-arg)
		 (list (region-beginning) (region-end) nil)))
  (cond ((not (called-interactively-p 'any))
	 (count-words start end))
	(arg
	 (message "%s" (count-words--buffer-format)))
	(t
	 (message "%s" (count-words--format "Region" start end)))))