all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#60322: 30.0.50; [PATCH]: Search for comment at bol in prog-fill-reindent-defun
@ 2022-12-25 21:54 Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-12-29  9:02 ` Eli Zaretskii
  2022-12-29 16:04 ` Dmitry Gutov
  0 siblings, 2 replies; 7+ messages in thread
From: Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-12-25 21:54 UTC (permalink / raw)
  To: 60322

[-- Attachment #1: Type: text/plain, Size: 198 bytes --]


Hi!

Attached is a small adjustment to the regex used in
prog-fill-reindent-defun.  The point is that we shouldn't consider lines
where comments come after actual code as inside a comment.


Theo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Search-for-comment-at-bol-in-prog-fill-reindent-defu.patch --]
[-- Type: text/x-diff, Size: 1224 bytes --]

From 8cbd514496d45e3b22523c5dc303abf97b3761f7 Mon Sep 17 00:00:00 2001
From: Theodor Thornhill <theo@thornhill.no>
Date: Sun, 25 Dec 2022 22:47:36 +0100
Subject: [PATCH] Search for comment at bol 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.

* lisp/progmodes/prog-mode.el (prog-fill-reindent-defun): Adjust
regex.
---
 lisp/progmodes/prog-mode.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
index aa37a4ac86..cebd759a4e 100644
--- a/lisp/progmodes/prog-mode.el
+++ b/lisp/progmodes/prog-mode.el
@@ -164,7 +164,7 @@ 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))
+              (re-search-forward "^\\s<" (line-end-position) t))
           (if (memq fill-paragraph-function '(t nil))
               (lisp-fill-paragraph argument)
             (funcall fill-paragraph-function argument))
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#60322: 30.0.50; [PATCH]: Search for comment at bol in prog-fill-reindent-defun
  2022-12-25 21:54 bug#60322: 30.0.50; [PATCH]: Search for comment at bol in prog-fill-reindent-defun Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-12-29  9:02 ` Eli Zaretskii
  2022-12-29 10:48   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-12-29 16:04 ` Dmitry Gutov
  1 sibling, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2022-12-29  9:02 UTC (permalink / raw)
  To: Theodor Thornhill, Dmitry Gutov, Yuan Fu; +Cc: 60322

> Date: Sun, 25 Dec 2022 22:54:44 +0100
> From:  Theodor Thornhill via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> Attached is a small adjustment to the regex used in
> prog-fill-reindent-defun.  The point is that we shouldn't consider lines
> where comments come after actual code as inside a comment.

Dmitry, Yuan, any comments?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#60322: 30.0.50; [PATCH]: Search for comment at bol in prog-fill-reindent-defun
  2022-12-29  9:02 ` Eli Zaretskii
@ 2022-12-29 10:48   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-12-29 11:12     ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-12-29 10:48 UTC (permalink / raw)
  To: Eli Zaretskii, Dmitry Gutov, Yuan Fu; +Cc: 60322

Eli Zaretskii <eliz@gnu.org> writes:

>> Date: Sun, 25 Dec 2022 22:54:44 +0100
>> From:  Theodor Thornhill via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>> 
>> Attached is a small adjustment to the regex used in
>> prog-fill-reindent-defun.  The point is that we shouldn't consider lines
>> where comments come after actual code as inside a comment.
>
> Dmitry, Yuan, any comments?

This is adressed in f9a22cf78d1a7f6472b09c3046c6a7f6984bc2d2, so This
can be closed :-)

Theo





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#60322: 30.0.50; [PATCH]: Search for comment at bol in prog-fill-reindent-defun
  2022-12-29 10:48   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-12-29 11:12     ` Eli Zaretskii
  0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2022-12-29 11:12 UTC (permalink / raw)
  To: Theodor Thornhill; +Cc: casouri, 60322-done, dgutov

> From: Theodor Thornhill <theo@thornhill.no>
> Cc: 60322@debbugs.gnu.org
> Date: Thu, 29 Dec 2022 11:48:10 +0100
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> Date: Sun, 25 Dec 2022 22:54:44 +0100
> >> From:  Theodor Thornhill via "Bug reports for GNU Emacs,
> >>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> >> 
> >> Attached is a small adjustment to the regex used in
> >> prog-fill-reindent-defun.  The point is that we shouldn't consider lines
> >> where comments come after actual code as inside a comment.
> >
> > Dmitry, Yuan, any comments?
> 
> This is adressed in f9a22cf78d1a7f6472b09c3046c6a7f6984bc2d2, so This
> can be closed :-)

Thanks, done.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#60322: 30.0.50; [PATCH]: Search for comment at bol in prog-fill-reindent-defun
  2022-12-25 21:54 bug#60322: 30.0.50; [PATCH]: Search for comment at bol in prog-fill-reindent-defun Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-12-29  9:02 ` Eli Zaretskii
@ 2022-12-29 16:04 ` Dmitry Gutov
  2022-12-29 19:23   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 7+ messages in thread
From: Dmitry Gutov @ 2022-12-29 16:04 UTC (permalink / raw)
  To: Theodor Thornhill, 60322

On 25/12/2022 23:54, Theodor Thornhill via Bug reports for GNU Emacs, 
the Swiss army knife of text editors wrote:
> Attached is a small adjustment to the regex used in
> prog-fill-reindent-defun.  The point is that we shouldn't consider lines
> where comments come after actual code as inside a comment.

How about we allow indentation?

And allow to be called not from BOL too?

(re-search-forward "\\s-*\\s<" (line-end-position) t)





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#60322: 30.0.50; [PATCH]: Search for comment at bol in prog-fill-reindent-defun
  2022-12-29 16:04 ` Dmitry Gutov
@ 2022-12-29 19:23   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-12-29 19:25     ` Dmitry Gutov
  0 siblings, 1 reply; 7+ messages in thread
From: Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-12-29 19:23 UTC (permalink / raw)
  To: Dmitry Gutov, 60322

[-- Attachment #1: Type: text/plain, Size: 535 bytes --]

Dmitry Gutov <dgutov@yandex.ru> writes:

> On 25/12/2022 23:54, Theodor Thornhill via Bug reports for GNU Emacs, 
> the Swiss army knife of text editors wrote:
>> Attached is a small adjustment to the regex used in
>> prog-fill-reindent-defun.  The point is that we shouldn't consider lines
>> where comments come after actual code as inside a comment.
>
> How about we allow indentation?
>
> And allow to be called not from BOL too?
>
> (re-search-forward "\\s-*\\s<" (line-end-position) t)

Sure!

Will you install it for me?

Theo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Allow-for-indentation-in-prog-fill-reindent-defun.patch --]
[-- Type: text/x-diff, Size: 1018 bytes --]

From b92043c5f1c3f835d19aa9d632920804283eccfd Mon Sep 17 00:00:00 2001
From: Theodor Thornhill <theo@thornhill.no>
Date: Thu, 29 Dec 2022 20:19:46 +0100
Subject: [PATCH] Allow for indentation in prog-fill-reindent-defun

(bug#60322)

* lisp/progmodes/prog-mode.el (prog-fill-reindent-defun): Adjust
regexp.
---
 lisp/progmodes/prog-mode.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
index 5e692980b2..2e0cb6cd25 100644
--- a/lisp/progmodes/prog-mode.el
+++ b/lisp/progmodes/prog-mode.el
@@ -164,7 +164,7 @@ prog-fill-reindent-defun
                  (treesit-node-type (treesit-node-at (point)))))))
       (if (or treesit-text-node
               (nth 8 (syntax-ppss))
-              (re-search-forward "^\\s<" (line-end-position) t))
+              (re-search-forward "\\s-*\\s<" (line-end-position) t))
           (fill-paragraph argument (region-active-p))
         (beginning-of-defun)
         (let ((start (point)))
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#60322: 30.0.50; [PATCH]: Search for comment at bol in prog-fill-reindent-defun
  2022-12-29 19:23   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-12-29 19:25     ` Dmitry Gutov
  0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Gutov @ 2022-12-29 19:25 UTC (permalink / raw)
  To: Theodor Thornhill, 60322

On 29/12/2022 21:23, Theodor Thornhill wrote:
> Dmitry Gutov <dgutov@yandex.ru> writes:
> 
>> On 25/12/2022 23:54, Theodor Thornhill via Bug reports for GNU Emacs,
>> the Swiss army knife of text editors wrote:
>>> Attached is a small adjustment to the regex used in
>>> prog-fill-reindent-defun.  The point is that we shouldn't consider lines
>>> where comments come after actual code as inside a comment.
>>
>> How about we allow indentation?
>>
>> And allow to be called not from BOL too?
>>
>> (re-search-forward "\\s-*\\s<" (line-end-position) t)
> 
> Sure!
> 
> Will you install it for me?

Sure, done.

I've also refilled the commit message a little.






^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-12-29 19:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-25 21:54 bug#60322: 30.0.50; [PATCH]: Search for comment at bol in prog-fill-reindent-defun Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-29  9:02 ` Eli Zaretskii
2022-12-29 10:48   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-29 11:12     ` Eli Zaretskii
2022-12-29 16:04 ` Dmitry Gutov
2022-12-29 19:23   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-29 19:25     ` Dmitry Gutov

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.