summaryrefslogtreecommitdiff
path: root/lisp/simple.el
diff options
context:
space:
mode:
authorManuel Giraud <manuel@ledu-giraud.fr>2022-05-20 13:52:28 +0200
committerEli Zaretskii <eliz@gnu.org>2022-05-29 10:58:13 +0300
commit460d5fd971489ba7b573d71a94cdaac2f9f1a767 (patch)
treed27b4919126e8cd83111823091fbe3a21f15a321 /lisp/simple.el
parent6f8e856ada08abf4cd29f03fe379a66693a78ba3 (diff)
downloademacs-460d5fd971489ba7b573d71a94cdaac2f9f1a767.tar.gz
emacs-460d5fd971489ba7b573d71a94cdaac2f9f1a767.tar.bz2
emacs-460d5fd971489ba7b573d71a94cdaac2f9f1a767.zip
Make `count-words' count sentences.
* lisp/textmodes/paragraphs.el (count-sentences): New function. * lisp/simple.el (count-words--format): Update format for showing sentences. (count-words): Also count sentences. * lisp/simple.el (count-words): * etc/NEWS: * doc/emacs/basic.texi (Position Info): Update documentation for sentence counting.
Diffstat (limited to 'lisp/simple.el')
-rw-r--r--lisp/simple.el9
1 files changed, 6 insertions, 3 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index db52d83cea4..a254ee22514 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1667,8 +1667,9 @@ 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. With prefix argument, also
-include the data for the entire (un-narrowed) buffer.
+number of lines, sentences, words, and chars. With prefix
+argument, also include the data for the entire (un-narrowed)
+buffer.
If called from Lisp, return the number of words between START and
END, without printing any message. TOTALS is ignored when called
@@ -1708,11 +1709,13 @@ from Lisp."
(defun count-words--format (str start end)
(let ((lines (count-lines start end))
+ (sentences (count-sentences start end))
(words (count-words start end))
(chars (- end start)))
- (format "%s has %d line%s, %d word%s, and %d character%s"
+ (format "%s has %d line%s, %d sentence%s, %d word%s, and %d character%s"
str
lines (if (= lines 1) "" "s")
+ sentences (if (= sentences 1) "" "s")
words (if (= words 1) "" "s")
chars (if (= chars 1) "" "s"))))