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

From: Joseph Turner <[email-masked]>
Date: Sat, 24 Aug 2024 00:51:36 -0700

Visuwesh <[email-masked]> writes:

> [வெள்ளி ஆகஸ்ட் 23, 2024] Joseph Turner via "Bug reports for GNU Emacs, the Swiss army knife of text editors" wrote:
>
>> [...]
>> 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."
>
> Should you not update the docstring to say that interactively prefix
> argument implies a non-nil NO-QUERY argument?
> [ P.S. you forgot to include the bug number in the commit log.  ]

You're right on both accounts.  Thanks.  See patch.

>>    (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
>From dccbecaf1b421c60a8846d782fb437d1cad3aa1f 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.  bug#72704
* etc/NEWS: Announce changes.
---
 etc/NEWS                     |  4 ++++
 lisp/textmodes/paragraphs.el | 10 ++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

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..f9351ef5afe 100644
--- a/lisp/textmodes/paragraphs.el
+++ b/lisp/textmodes/paragraphs.el
@@ -545,12 +545,14 @@ repunctuate-sentences
 It works using `query-replace-regexp'.  In Transient Mark mode,
 if the mark is active, operate on the contents of the region.
 Second and third arg START and END specify the region to operate on.
-If optional argument NO-QUERY is non-nil, make changes without asking
-for confirmation.  You can use `repunctuate-sentences-filter' to add
-filters to skip occurrences of spaces that don't need to be replaced."
+If optional argument NO-QUERY is non-nil (interactively with prefix
+argument), make changes without asking for confirmation.  You can use
+`repunctuate-sentences-filter' to add 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