Subject: Re: bug#62027: Subject: 29.0.60; Breaking change in forward-sentence/backward-sentence

From: Manuel Giraud <[email-masked]>
Date: Tue, 07 Mar 2023 17:07:14 +0100

Eli Zaretskii <[email-masked]> writes:

[...]

>> I'm all for reverting to the traditional return values of the sentence
>> commands, specially if they don't complicate the new command much.  The
>> return value was not documented, but Hyrum's Law
>> (https://www.hyrumslaw.com/) tells us that there is an unknown amount of
>> code out there that depends on the traditional return value, anyway.
>
> Agreed.

Ok.  I've tried to fix this.  I've done some testing, it works for me™.
If it is ok, I think it should go in emacs-29 (if this is still
possible).
>From 965a803d571ab78f2ca37b4ac01b51a6a0bc7df7 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <[email-masked]>
Date: Tue, 7 Mar 2023 16:46:02 +0100
Subject: [PATCH] Revert 'forward-sentence-default-function' to return the
 point

* lisp/textmodes/paragraphs.el
(forward-sentence-default-function): Revert to return the point
position.
(count-sentences): Adapt to this change.
---
 lisp/textmodes/paragraphs.el | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lisp/textmodes/paragraphs.el b/lisp/textmodes/paragraphs.el
index bf249fdcdfb..70ae0f7daeb 100644
--- a/lisp/textmodes/paragraphs.el
+++ b/lisp/textmodes/paragraphs.el
@@ -476,8 +476,7 @@ forward-sentence-default-function
 	    (skip-chars-backward " \t\n")
 	  (goto-char par-end)))
       (setq arg (1- arg)))
-    (let ((npoint (constrain-to-field nil opoint t)))
-      (not (= npoint opoint)))))
+    (constrain-to-field nil opoint t)))
 
 (defvar forward-sentence-function #'forward-sentence-default-function
   "Function to be used to calculate sentence movements.
@@ -499,8 +498,13 @@ count-sentences
       (save-restriction
         (narrow-to-region start end)
         (goto-char (point-min))
-	(while (ignore-errors (forward-sentence))
-	  (setq sentences (1+ sentences)))
+        (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)))
-- 
2.39.1

-- 
Manuel Giraud