all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#60572: 29.0.60; c-ts-mode: String spanning multiple lines are not indented
@ 2023-01-05 11:12 Mohammed Sadiq
  2023-01-06  5:51 ` Yuan Fu
  2023-01-08  2:21 ` Yuan Fu
  0 siblings, 2 replies; 8+ messages in thread
From: Mohammed Sadiq @ 2023-01-05 11:12 UTC (permalink / raw)
  To: 60572

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");
}



In GNU Emacs 29.0.60 (build 5, x86_64-pc-linux-gnu, GTK+ Version
  3.24.35, cairo version 1.16.0) of 2023-01-02 built on purism
Repository revision: 2569ede9c496bb060e0b88428cb541088aaba1f9
Repository branch: emacs-29
Windowing system distributor 'The X.Org Foundation', version 
11.0.12101005
System Description: Debian GNU/Linux bookworm/sid





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

* bug#60572: 29.0.60; c-ts-mode: String spanning multiple lines  are not indented
  2023-01-05 11:12 bug#60572: 29.0.60; c-ts-mode: String spanning multiple lines are not indented Mohammed Sadiq
@ 2023-01-06  5:51 ` Yuan Fu
  2023-01-07 12:07   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-01-08  2:21 ` Yuan Fu
  1 sibling, 1 reply; 8+ messages in thread
From: Yuan Fu @ 2023-01-06  5:51 UTC (permalink / raw)
  To: Mohammed Sadiq; +Cc: 60572


Mohammed Sadiq <sadiq@sadiqpk.org> 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





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

* bug#60572: 29.0.60; c-ts-mode: String spanning multiple lines are not indented
  2023-01-06  5:51 ` Yuan Fu
@ 2023-01-07 12:07   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-01-21  8:10     ` Mohammed Sadiq
  0 siblings, 1 reply; 8+ messages in thread
From: Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-01-07 12:07 UTC (permalink / raw)
  To: Yuan Fu; +Cc: Mohammed Sadiq, 60572

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

Yuan Fu <casouri@gmail.com> writes:

> Mohammed Sadiq <sadiq@sadiqpk.org> 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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-indentation-rule-for-concatenated_string-bug-605.patch --]
[-- Type: text/x-patch, Size: 1118 bytes --]

From 0891cff08c2e6438902ed09291d5e52e742bab11 Mon Sep 17 00:00:00 2001
From: Theodor Thornhill <theo@thornhill.no>
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


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

* bug#60572: 29.0.60; c-ts-mode: String spanning multiple lines  are not indented
  2023-01-05 11:12 bug#60572: 29.0.60; c-ts-mode: String spanning multiple lines are not indented Mohammed Sadiq
  2023-01-06  5:51 ` Yuan Fu
@ 2023-01-08  2:21 ` Yuan Fu
  2023-01-08  8:12   ` Mohammed Sadiq
  1 sibling, 1 reply; 8+ messages in thread
From: Yuan Fu @ 2023-01-08  2:21 UTC (permalink / raw)
  To: Theodor Thornhill; +Cc: Mohammed Sadiq, 60572


Theodor Thornhill <theo@thornhill.no> writes:

> Yuan Fu <casouri@gmail.com> writes:
>
>> Mohammed Sadiq <sadiq@sadiqpk.org> 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

Thanks! Patch applied.

Yuan





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

* bug#60572: 29.0.60; c-ts-mode: String spanning multiple lines are not indented
  2023-01-08  2:21 ` Yuan Fu
@ 2023-01-08  8:12   ` Mohammed Sadiq
  2023-01-08  9:18     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 8+ messages in thread
From: Mohammed Sadiq @ 2023-01-08  8:12 UTC (permalink / raw)
  To: Yuan Fu; +Cc: Theodor Thornhill, 60572

> Theodor Thornhill <theo@thornhill.no> writes:
>> 
>> Here is a patch fixing this, Yuan.  Feel free to install at your
>> convenience.
>> 
>> Do you agree with this patch, Mohammed?

The line

   puts ("more"
     "test");

is still not indented right (right in the sense, the behavior is
different from c-mode):

I expect the code to be (with indent-tabs-mode set to nil):

   puts ("more"
         "test");

but I get:

   puts ("more"
     "test");





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

* bug#60572: 29.0.60; c-ts-mode: String spanning multiple lines are not indented
  2023-01-08  8:12   ` Mohammed Sadiq
@ 2023-01-08  9:18     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-01-08  9:45       ` Mohammed Sadiq
  0 siblings, 1 reply; 8+ messages in thread
From: Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-01-08  9:18 UTC (permalink / raw)
  To: Mohammed Sadiq, Yuan Fu; +Cc: 60572



On 8 January 2023 09:12:40 CET, Mohammed Sadiq <sadiq@sadiqpk.org> wrote:
>> Theodor Thornhill <theo@thornhill.no> writes:
>>> 
>>> Here is a patch fixing this, Yuan.  Feel free to install at your
>>> convenience.
>>> 
>>> Do you agree with this patch, Mohammed?
>
>The line
>
>  puts ("more"
>    "test");
>
>is still not indented right (right in the sense, the behavior is
>different from c-mode):
>
>I expect the code to be (with indent-tabs-mode set to nil):
>
>  puts ("more"
>        "test");
>
>but I get:
>
>  puts ("more"
>    "test");

Right, thanks. Is this indent style related? Would Linux style do this differently than gnu?

Thanks,
Theo





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

* bug#60572: 29.0.60; c-ts-mode: String spanning multiple lines are not indented
  2023-01-08  9:18     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-01-08  9:45       ` Mohammed Sadiq
  0 siblings, 0 replies; 8+ messages in thread
From: Mohammed Sadiq @ 2023-01-08  9:45 UTC (permalink / raw)
  To: Theodor Thornhill; +Cc: Yuan Fu, 60572

On 2023-01-08 14:48, Theodor Thornhill wrote:
> 
> Right, thanks. Is this indent style related? Would Linux style do this
> differently than gnu?
> 

As per 
https://www.kernel.org/doc/html/v6.0/process/coding-style.html#inline-assembly
and c-mode linux style, both GNU and Linux seem to behave similarly.


cheers,
Mohammed Sadiq





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

* bug#60572: 29.0.60; c-ts-mode: String spanning multiple lines are not indented
  2023-01-07 12:07   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-01-21  8:10     ` Mohammed Sadiq
  0 siblings, 0 replies; 8+ messages in thread
From: Mohammed Sadiq @ 2023-01-21  8:10 UTC (permalink / raw)
  To: Theodor Thornhill; +Cc: Yuan Fu, 60572

On 2023-01-07 17:37, Theodor Thornhill wrote:
> Here is a patch fixing this, Yuan.  Feel free to install at your
> convenience.
> 
> Do you agree with this patch, Mohammed?

I believe that the patch is already applied to emacs-29 branch,
I couldn't apply the patch (and reading the code, it looks it's
already in).

Anyway, This still doesn't fixes the following cases:

   some_func (arg1,
              "some really long"
                "string");
   some_func ("some really long"
     "string");


> 
> Theo





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

end of thread, other threads:[~2023-01-21  8:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-05 11:12 bug#60572: 29.0.60; c-ts-mode: String spanning multiple lines are not indented Mohammed Sadiq
2023-01-06  5:51 ` Yuan Fu
2023-01-07 12:07   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-21  8:10     ` Mohammed Sadiq
2023-01-08  2:21 ` Yuan Fu
2023-01-08  8:12   ` Mohammed Sadiq
2023-01-08  9:18     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-08  9:45       ` Mohammed Sadiq

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.