Subject: bug#60572: 29.0.60; c-ts-mode: String spanning multiple lines are not indented

From: Theodor Thornhill <[email-masked]>
Date: Sat, 07 Jan 2023 13:07:05 +0100

Yuan Fu <[email-masked]> writes:

> Mohammed Sadiq <[email-masked]> writes:
>
>> The following code doesn't indent with TAB on c-ts-mode:
>>
>> #include <stdio.h>
>>
>> int
>> main (void)
>> {
>>   char *test = "some "
>>   "test";
>>
>>   puts ("more "
>>   "test");
>> }
>>
>>
>> expected indentation:
>>
>> #include <stdio.h>
>>
>> int
>> main (void)
>> {
>>   char *test = "some "
>>     "test";
>>
>>   puts ("more "
>> 	"test");
>> }
>>
>
> Thanks for the report. I’m on the road right now, but I’ll soon get back
> and work on this and your other reports, just FYI :-)
>
> Yuan

Here is a patch fixing this, Yuan.  Feel free to install at your
convenience.

Do you agree with this patch, Mohammed?

Theo

>From 0891cff08c2e6438902ed09291d5e52e742bab11 Mon Sep 17 00:00:00 2001
From: Theodor Thornhill <[email-masked]>
Date: Sat, 7 Jan 2023 13:04:07 +0100
Subject: [PATCH] Add indentation rule for concatenated_string (bug#60572)

* lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Indent to
parent-bol.
---
 lisp/progmodes/c-ts-mode.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index e76966e7660..a22f1f3c44f 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -138,6 +138,7 @@ c-ts-mode--indent-styles
            ((parent-is "function_definition") parent-bol 0)
            ((parent-is "conditional_expression") first-sibling 0)
            ((parent-is "assignment_expression") parent-bol c-ts-mode-indent-offset)
+           ((parent-is "concatenated_string") parent-bol c-ts-mode-indent-offset)
            ((parent-is "comma_expression") first-sibling 0)
            ((parent-is "init_declarator") parent-bol c-ts-mode-indent-offset)
            ((parent-is "parenthesized_expression") first-sibling 1)
-- 
2.34.1