bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#62717: 29.0.60; c-ts-mode does not indent the first line in a functi


From: Daniel Martín
Subject: bug#62717: 29.0.60; c-ts-mode does not indent the first line in a function after RET
Date: Sun, 09 Apr 2023 13:05:18 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (darwin)

Dmitry Gutov <dmitry@gutov.dev> writes:

>
> I'm not sure, though, what is the big deal with adding the top-level
> function's closing curly first thing before writing the body (after
> that the parser starts working much better), so as far as I'm
> concerned this patch is very optional. It does add some complexity,
> after all.

I think this problem also affects languages without curly braces like
Ruby or Python.

For example, if I insert this Ruby code in a buffer with ruby-ts-mode
enabled

def sample RET

The newline is not indented, but it is indented in ruby-mode.

>
> Adding Alan and Joao, who were interested in this scenario as well.
>
> diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
> index 981c7766375..9aaa8b32c73 100644
> --- a/lisp/progmodes/c-ts-mode.el
> +++ b/lisp/progmodes/c-ts-mode.el

Thanks for the patch.  It works correctly and the existing c-ts-mode
tests pass.  I suggest adding a test to prevent regressions:

diff --git a/test/lisp/progmodes/c-ts-mode-resources/indent.erts 
b/test/lisp/progmodes/c-ts-mode-resources/indent.erts
index 5cdefe2122c..221b3d809af 100644
--- a/test/lisp/progmodes/c-ts-mode-resources/indent.erts
+++ b/test/lisp/progmodes/c-ts-mode-resources/indent.erts
@@ -464,3 +464,17 @@ main (void)
   |
 }
 =-=-=
+
+Name: Empty Line (Block Start)
+
+=-=
+int
+main (void)
+{
+|
+=-=
+int
+main (void)
+{
+  |
+=-=-=




reply via email to

[Prev in Thread] Current Thread [Next in Thread]