Subject: Re: bug#72704: 29.4; repunctuate-sentences ignores NO-QUERY

From: Joseph Turner <[email-masked]>
Date: Fri, 23 Aug 2024 23:30:52 -0700

Richard Stallman <[email-masked]> writes:

> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
> The usual default behavior of Emacs commands that take START and END
> arguments is to operate by default on the reguon.
> `repunctuate-sentences' operates by default from point to EOB.  Is
> that wise?  Is there a reason why it should not follow
> the usual convention instead?

AFAICT, `repunctuate-sentences' does operate on the region when active:

(interactive (list nil (use-region-beginning) (use-region-end)))

Please see the attached patch, which makes repunctuate-sentences respect
the current prefix argument.

Juri, do I need to update the interactive-args declaration?  I'm not
totally clear on how that works.

Thank you!

Joseph

>From b5689dd1907fc8e2bd2752d8c8248f3747d52ff3 Mon Sep 17 00:00:00 2001
From: Joseph Turner <[email-masked]>
Date: Fri, 23 Aug 2024 23:19:33 -0700
Subject: [PATCH] Interpret prefix argument as NO-QUERY in
 repunctuate-sentences

* lisp/textmodes/paragraphs.el (repunctuate-sentences): Respect
current-prefix-arg.
* etc/NEWS: Announce changes.
---
 etc/NEWS                     | 4 ++++
 lisp/textmodes/paragraphs.el | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/etc/NEWS b/etc/NEWS
index 2ddbab29528..5f9f86bce53 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -95,6 +95,10 @@ When using 'visual-wrap-prefix-mode' in buffers with variable-pitch
 fonts, the wrapped text will now be lined up correctly so that it's
 exactly below the text after the prefix on the first line.
 
+---
+** When invoked with a prefix argument, 'repunctuate-sentences' now
+replaces text without querying for confirmation.
+
 
 * Changes in Specialized Modes and Packages in Emacs 31.1
 
diff --git a/lisp/textmodes/paragraphs.el b/lisp/textmodes/paragraphs.el
index be741e6517b..79bfc7fab3c 100644
--- a/lisp/textmodes/paragraphs.el
+++ b/lisp/textmodes/paragraphs.el
@@ -550,7 +550,8 @@ repunctuate-sentences
 filters to skip occurrences of spaces that don't need to be replaced."
   (declare (interactive-args (start (use-region-beginning))
                              (end (use-region-end))))
-  (interactive (list nil (use-region-beginning) (use-region-end)))
+  (interactive
+   (list current-prefix-arg (use-region-beginning) (use-region-end)))
   (let ((regexp "\\([]\"')]?\\)\\([.?!]\\)\\([]\"')]?\\) +")
         (to-string "\\1\\2\\3  "))
     (if no-query
-- 
2.41.0