* bug#60360: 30.0.50; prog-fill-reindent-defun doesn't use region
@ 2022-12-27 18:13 Juri Linkov
2022-12-27 21:01 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 3+ messages in thread
From: Juri Linkov @ 2022-12-27 18:13 UTC (permalink / raw)
To: 60360; +Cc: theodor thornhill
X-Debbugs-CC: Theodor Thornhill <theo@thornhill.no>
After selecting the region in a docstring, M-q used to fill the region,
but new prog-fill-reindent-defun doesn't do this. The original
function had the argument REGION for that, described thusly:
The REGION argument is non-nil if called interactively; in that
case, if Transient Mark mode is enabled and the mark is active,
call ‘fill-region’ to fill each of the paragraphs in the active
region, instead of just filling the current paragraph.
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#60360: 30.0.50; prog-fill-reindent-defun doesn't use region
2022-12-27 18:13 bug#60360: 30.0.50; prog-fill-reindent-defun doesn't use region Juri Linkov
@ 2022-12-27 21:01 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-28 17:22 ` Juri Linkov
0 siblings, 1 reply; 3+ messages in thread
From: Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-12-27 21:01 UTC (permalink / raw)
To: Juri Linkov, 60360
[-- Attachment #1: Type: text/plain, Size: 664 bytes --]
Hi, Juri!
> X-Debbugs-CC: Theodor Thornhill <theo@thornhill.no>
>
> After selecting the region in a docstring, M-q used to fill the region,
> but new prog-fill-reindent-defun doesn't do this. The original
> function had the argument REGION for that, described thusly:
>
> The REGION argument is non-nil if called interactively; in that
> case, if Transient Mark mode is enabled and the mark is active,
> call ‘fill-region’ to fill each of the paragraphs in the active
> region, instead of just filling the current paragraph.
Thanks, does the below patch solve your problem? If so, feel free to
install it, as I can't :-)
Theo
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fixes-in-prog-fill-reindent-defun.patch --]
[-- Type: text/x-diff, Size: 1530 bytes --]
From bafb70b02577aaabec3d92a4a25557504dec25f3 Mon Sep 17 00:00:00 2001
From: Theodor Thornhill <theo@thornhill.no>
Date: Sun, 25 Dec 2022 22:47:36 +0100
Subject: [PATCH] Fixes in prog-fill-reindent-defun
Ensure that we don't consider lines such as
switch (foo) {
case 2: // If point on 'c' in 'case'
return 2;
not to be considered for filling.
Also make sure we check for the active region, to replicate the normal
fill-paragraph behavior.
* lisp/progmodes/prog-mode.el (prog-fill-reindent-defun): Adjust
regex, and make sure fill-paragraph checks for active region.
(bug#60360, bug#60322)
---
lisp/progmodes/prog-mode.el | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
index aa37a4ac86..5e692980b2 100644
--- a/lisp/progmodes/prog-mode.el
+++ b/lisp/progmodes/prog-mode.el
@@ -164,10 +164,8 @@ prog-fill-reindent-defun
(treesit-node-type (treesit-node-at (point)))))))
(if (or treesit-text-node
(nth 8 (syntax-ppss))
- (re-search-forward comment-start-skip (line-end-position) t))
- (if (memq fill-paragraph-function '(t nil))
- (lisp-fill-paragraph argument)
- (funcall fill-paragraph-function argument))
+ (re-search-forward "^\\s<" (line-end-position) t))
+ (fill-paragraph argument (region-active-p))
(beginning-of-defun)
(let ((start (point)))
(end-of-defun)
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#60360: 30.0.50; prog-fill-reindent-defun doesn't use region
2022-12-27 21:01 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-12-28 17:22 ` Juri Linkov
0 siblings, 0 replies; 3+ messages in thread
From: Juri Linkov @ 2022-12-28 17:22 UTC (permalink / raw)
To: Theodor Thornhill; +Cc: 60360
close 60360 30.0.50
thanks
>> After selecting the region in a docstring, M-q used to fill the region,
>> but new prog-fill-reindent-defun doesn't do this. The original
>> function had the argument REGION for that, described thusly:
>
> Thanks, does the below patch solve your problem? If so, feel free to
> install it, as I can't :-)
Thanks for the patch. I confirmed that it works,
and then pushed to master.
> @@ -164,10 +164,8 @@ prog-fill-reindent-defun
> ...
> + (re-search-forward "^\\s<" (line-end-position) t))
> + (fill-paragraph argument (region-active-p))
Usually use-region-p would be a better choice, but in this case
region-active-p is fine since it follows the logic used by
the REGION arg of fill-paragraph.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-12-28 17:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-27 18:13 bug#60360: 30.0.50; prog-fill-reindent-defun doesn't use region Juri Linkov
2022-12-27 21:01 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-28 17:22 ` Juri Linkov
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.