Subject: bug#41761: [PATCH] bug#41761: 28.0.50; M-x count-words counts words only up to a field boundary

From: Daniel Koning <[email-masked]>
Date: Wed, 10 Jun 2020 15:15:32 -0500

Pip Cet <[email-masked]> writes:

> Expected result:
>
> message "Region has 1 line, 10 words, and 50 characters"
>
> Actual result:
>
> message "Region has 1 line, 1 word, and 50 characters"

`count-words' should be disabling field-boundary behavior in
`forward-word-strictly' by setting `inhibit-field-text-motion'. Patch
included.

I grepped for other calls to `count-words' that might be making the same
omission, but everything I saw looked like a use case that should
respect field boundaries.

Daniel

>From af0d9c48aaf99d8df5fa55a8ba2c0ee42bf695e9 Mon Sep 17 00:00:00 2001
From: Daniel Koning <[email-masked]>
Date: Wed, 10 Jun 2020 14:42:39 -0500
Subject: [PATCH] Don't stop at field boundaries when counting words
 (Bug#41761)

* lisp/simple.el (count-words): Ensure that `forward-word-strictly'
moves point from one field to the next during the word-counting loop.

Copyright-paperwork-exempt: yes
---
 lisp/simple.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index 6d7600e414..9d898eeeec 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1319,7 +1319,9 @@ count-words
 END, without printing any message."
   (interactive (list nil nil))
   (cond ((not (called-interactively-p 'any))
-	 (let ((words 0))
+	 (let ((words 0)
+               ;; Count across field boundaries. (Bug#41761)
+               (inhibit-field-text-motion t))
 	   (save-excursion
 	     (save-restriction
 	       (narrow-to-region start end)
-- 
2.20.1