unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Vincenzo Pupillo <v.pupillo@gmail.com>
Cc: 70520-done@debbugs.gnu.org
Subject: bug#70520: 30.0.50; [PATCH] c-ts-common-comment-indent-new-line does nothing when the comment line in a block starts with whitespace.
Date: Mon, 22 Apr 2024 21:57:10 -0700	[thread overview]
Message-ID: <0D0F8221-6E3E-4D9E-9AFE-708FD46C460C@gmail.com> (raw)
In-Reply-To: <13523084.uLZWGnKmhe@fedora>

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



> On Apr 22, 2024, at 1:16 PM, Vincenzo Pupillo <v.pupillo@gmail.com> wrote:
> 
> Hello, 
> the new function c-ts-common-comment-indent-new-line has a different behavior 
> from comment-indent-new-line in c-mode.
> In a comment block like this:
> /*
>   Lorem ipsum dolor sit amet, consectetur adipiscing elit, 
>   sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
> */
> M-j does not break the line or indent. The cursor simply stands still.
> The attached patch handles this case.
> 
> Thank you.
> V.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Cover-more-c-ts-common-comment-indent-new-line.patch --]
[-- Type: text/x-patch; x-unix-mode=0644; name="0001-Cover-more-c-ts-common-comment-indent-new-line.patch", Size: 1295 bytes --]

From aa0b1f1d25a068b0386eeb81bab564465b31399e Mon Sep 17 00:00:00 2001
From: Vincenzo Pupillo <v.pupillo@gmail.com>
Date: Mon, 22 Apr 2024 21:05:49 +0200
Subject: [PATCH] Cover more c-ts-common-comment-indent-new-line.

* lisp/progmodes/c-ts-common.el:
(c-ts-common-comment-indent-new-line): Handles the case of comments in a
comment block that begin with whitespaces.
---
 lisp/progmodes/c-ts-common.el | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/c-ts-common.el b/lisp/progmodes/c-ts-common.el
index 735126e1eac..025703d7fce 100644
--- a/lisp/progmodes/c-ts-common.el
+++ b/lisp/progmodes/c-ts-common.el
@@ -317,7 +317,16 @@ c-ts-common-comment-indent-new-line
     (let ((prefix (match-string 1)))
       (if soft (insert-and-inherit ?\n) (newline 1))
       (delete-region (line-beginning-position) (point))
-      (insert prefix)))))
+      (insert prefix)))
+
+   ;; Line starts with whitespaces
+   ((save-excursion
+      (beginning-of-line)
+      (looking-at (rx (* " "))))
+    (let ((whitespaces (match-string 0)))
+      (if soft (insert-and-inherit ?\n) (newline 1))
+      (delete-region (line-beginning-position) (point))
+      (insert whitespaces)))))
 
 ;;; Statement indent
 
-- 
2.44.0


[-- Attachment #3: Type: text/plain, Size: 25 bytes --]


Merged, thank you!

Yuan

      reply	other threads:[~2024-04-23  4:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-22 20:16 bug#70520: 30.0.50; [PATCH] c-ts-common-comment-indent-new-line does nothing when the comment line in a block starts with whitespace Vincenzo Pupillo
2024-04-23  4:57 ` Yuan Fu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0D0F8221-6E3E-4D9E-9AFE-708FD46C460C@gmail.com \
    --to=casouri@gmail.com \
    --cc=70520-done@debbugs.gnu.org \
    --cc=v.pupillo@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).