Function: count-words
count-words is an interactive and byte-compiled function defined in
simple.el.gz.
Signature
(count-words START END)
Documentation
Count words between START and END.
If called interactively, START and END are normally the start and end of the buffer; but if the region is active, START and END are the start and end of the region. Print a message reporting the number of lines, words, and chars.
If called from Lisp, return the number of words between START and END, without printing any message.
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 (start end)
"Count words between START and END.
If called interactively, START and END are normally the start and
end of the buffer; but if the region is active, START and END are
the start and end of the region. Print a message reporting the
number of lines, words, and chars.
If called from Lisp, return the number of words between START and
END, without printing any message."
(interactive (list nil nil))
(cond ((not (called-interactively-p 'any))
(let ((words 0)
;; Count across field boundaries. (Bug#41761)
(inhibit-field-text-motion t))
(save-excursion
(save-restriction
(narrow-to-region start end)
(goto-char (point-min))
(while (forward-word-strictly 1)
(setq words (1+ words)))))
words))
((use-region-p)
(call-interactively 'count-words-region))
(t
(count-words--buffer-message))))