emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/kotlin-mode ad16798e02 091/162: Set proper indentation for


From: ELPA Syncer
Subject: [nongnu] elpa/kotlin-mode ad16798e02 091/162: Set proper indentation for closing brackets preceded by a blank line
Date: Sat, 29 Jan 2022 08:25:25 -0500 (EST)

branch: elpa/kotlin-mode
commit ad16798e02cd0c3e572f7f337ce1f954bd0713d7
Author: Gregg Hernandez <gregg@lucidchart.com>
Commit: Gregg Hernandez <gregg@lucidchart.com>

    Set proper indentation for closing brackets preceded by a blank line
---
 kotlin-mode.el | 23 +++++++++++++----------
 test/sample.kt | 14 ++++++++++----
 2 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/kotlin-mode.el b/kotlin-mode.el
index 006379cc31..4cc3dc9ad5 100644
--- a/kotlin-mode.el
+++ b/kotlin-mode.el
@@ -241,7 +241,7 @@
       (progn
         (kotlin-mode--beginning-of-buffer-indent))
     (let ((not-indented t) cur-indent)
-      (cond ((looking-at "^[ \t]*\\.")
+      (cond ((looking-at "^[ \t]*\\.") ; line starts with .
              (save-excursion
                (kotlin-mode--prev-line)
                (cond ((looking-at "^[ \t]*\\.")
@@ -252,16 +252,19 @@
                (if (< cur-indent 0)
                    (setq cur-indent 0))))
 
-            ((looking-at "^[ \t]*}")
+            ((looking-at "^[ \t]*}") ; line starts with }
              (save-excursion
                (kotlin-mode--prev-line)
-               (while (and (looking-at "^[ \t]*\\.") (not (bobp)))
+               (while (and (or (looking-at "^[ \t]*$") (looking-at "^[ 
\t]*\\.")) (not (bobp)))
                  (kotlin-mode--prev-line))
-               (setq cur-indent (- (current-indentation) kotlin-tab-width)))
+               (cond ((or (looking-at ".*{[ \t]*$") (looking-at ".*{.*->[ 
\t]*$"))
+                      (setq cur-indent (current-indentation)))
+                     (t
+                      (setq cur-indent (- (current-indentation) 
kotlin-tab-width)))))
              (if (< cur-indent 0)
                  (setq cur-indent 0)))
 
-            ((looking-at "^[ \t]*)")
+            ((looking-at "^[ \t]*)") ; line starts with )
              (save-excursion
                (kotlin-mode--prev-line)
                (setq cur-indent (- (current-indentation) (* 2 
kotlin-tab-width))))
@@ -272,23 +275,23 @@
              (save-excursion
                (while not-indented
                  (kotlin-mode--prev-line)
-                 (cond ((looking-at ".*{[ \t]*$") ; 4.)
+                 (cond ((looking-at ".*{[ \t]*$") ; line ends with {
                         (setq cur-indent (+ (current-indentation) 
kotlin-tab-width))
                         (setq not-indented nil))
 
-                       ((looking-at "^[ \t]*}") ; 3.)
+                       ((looking-at "^[ \t]*}") ; line starts with }
                         (setq cur-indent (current-indentation))
                         (setq not-indented nil))
 
-                       ((looking-at ".*{.*->[ \t]*$")
+                       ((looking-at ".*{.*->[ \t]*$") ; line ends with ->
                         (setq cur-indent (+ (current-indentation) 
kotlin-tab-width))
                         (setq not-indented nil))
 
-                       ((looking-at ".*([ \t]*$")
+                       ((looking-at ".*([ \t]*$") ; line ends with (
                         (setq cur-indent (+ (current-indentation) (* 2 
kotlin-tab-width)))
                         (setq not-indented nil))
 
-                       ((looking-at "^[ \t]*).*$")
+                       ((looking-at "^[ \t]*).*$") ; line starts with )
                         (setq cur-indent (current-indentation))
                         (setq not-indented nil))
 
diff --git a/test/sample.kt b/test/sample.kt
index 1768f0142e..c64907fd47 100644
--- a/test/sample.kt
+++ b/test/sample.kt
@@ -7,7 +7,7 @@ import bar.Bar as bBar
 // a single line comment
 
 /*
- * a multiline comment
+* a multiline comment
 */
 
 fun sum(a: Int, b: Int): Int {
@@ -273,10 +273,10 @@ class Derived(p: Int) : Base(p)
 
 class MyView : View {
     constructor(ctx: Context) : super(ctx) {
-}
+    }
 
-constructor(ctx: Context, attrs: AttributeSet) : super(ctx, attrs) {
-}
+    constructor(ctx: Context, attrs: AttributeSet) : super(ctx, attrs) {
+    }
 }
 
 open class Base {
@@ -705,3 +705,9 @@ inline fun <reified T> TreeNode.findParentOfType(): T? {
     }
     return p as T
 }
+
+class Test {
+    fun f() {
+
+    }
+}
\ No newline at end of file



reply via email to

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