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

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

[nongnu] elpa/kotlin-mode 9e2e4c11fe 090/162: Merge pull request #13 fro


From: ELPA Syncer
Subject: [nongnu] elpa/kotlin-mode 9e2e4c11fe 090/162: Merge pull request #13 from gregghz/whitespace-indent
Date: Sat, 29 Jan 2022 08:25:25 -0500 (EST)

branch: elpa/kotlin-mode
commit 9e2e4c11fe3a9e8f63ce351762a2b1ac5dbe8a75
Merge: f54da34b3f f42a0745dd
Author: Gregg Hernandez <greggory.hz@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #13 from gregghz/whitespace-indent
    
    Ignores blank lines when finding indent level
---
 kotlin-mode.el | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/kotlin-mode.el b/kotlin-mode.el
index 4f67c027b3..006379cc31 100644
--- a/kotlin-mode.el
+++ b/kotlin-mode.el
@@ -225,6 +225,14 @@
                    t)
           (kotlin-mode--match-interpolation limit))))))
 
+(defun kotlin-mode--prev-line ()
+  "Moves up to the nearest non-empty line"
+  (if (not (bobp))
+      (progn
+        (forward-line -1)
+        (while (and (looking-at "^[ \t]*$") (not (bobp)))
+          (forward-line -1)))))
+
 (defun kotlin-mode--indent-line ()
   "Indent current line as kotlin code"
   (interactive)
@@ -235,7 +243,7 @@
     (let ((not-indented t) cur-indent)
       (cond ((looking-at "^[ \t]*\\.")
              (save-excursion
-               (forward-line -1)
+               (kotlin-mode--prev-line)
                (cond ((looking-at "^[ \t]*\\.")
                       (setq cur-indent (current-indentation)))
 
@@ -246,16 +254,16 @@
 
             ((looking-at "^[ \t]*}")
              (save-excursion
-               (forward-line -1)
+               (kotlin-mode--prev-line)
                (while (and (looking-at "^[ \t]*\\.") (not (bobp)))
-                 (forward-line -1))
+                 (kotlin-mode--prev-line))
                (setq cur-indent (- (current-indentation) kotlin-tab-width)))
              (if (< cur-indent 0)
                  (setq cur-indent 0)))
 
             ((looking-at "^[ \t]*)")
              (save-excursion
-               (forward-line -1)
+               (kotlin-mode--prev-line)
                (setq cur-indent (- (current-indentation) (* 2 
kotlin-tab-width))))
              (if (< cur-indent 0)
                  (setq cur-indent 0)))
@@ -263,7 +271,7 @@
             (t
              (save-excursion
                (while not-indented
-                 (forward-line -1)
+                 (kotlin-mode--prev-line)
                  (cond ((looking-at ".*{[ \t]*$") ; 4.)
                         (setq cur-indent (+ (current-indentation) 
kotlin-tab-width))
                         (setq not-indented nil))



reply via email to

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