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

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

[nongnu] elpa/kotlin-mode f8b7b3648e 2/2: Merge pull request #65 from te


From: ELPA Syncer
Subject: [nongnu] elpa/kotlin-mode f8b7b3648e 2/2: Merge pull request #65 from ted-tanner/master
Date: Tue, 17 May 2022 16:58:42 -0400 (EDT)

branch: elpa/kotlin-mode
commit f8b7b3648e230368fc019b63263dff874ac255cd
Merge: 3e0c34087b 52631abde4
Author: Gregg Hernandez <greggory.hz@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #65 from ted-tanner/master
    
    Fix indentation for if/else and getters/setters with visibility modifiers
---
 kotlin-mode.el | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/kotlin-mode.el b/kotlin-mode.el
index 1026783902..184538fc22 100644
--- a/kotlin-mode.el
+++ b/kotlin-mode.el
@@ -335,6 +335,18 @@
         (while (and (looking-at "^[ \t]*$") (not (bobp)))
           (forward-line -1)))))
 
+(defun kotlin-mode--prev-line-begins (pattern)
+  "Return whether the previous line begins with the given pattern"
+  (save-excursion
+    (kotlin-mode--prev-line)
+    (looking-at (format "^[ \t]*%s" pattern))))
+
+(defun kotlin-mode--prev-line-ends (pattern)
+  "Return whether the previous line ends with the given pattern"
+  (save-excursion
+    (kotlin-mode--prev-line)
+    (looking-at (format ".*%s[ \t]*$" pattern))))
+
 (defun kotlin-mode--line-begins (pattern)
   "Return whether the current line begins with the given pattern"
   (save-excursion
@@ -356,10 +368,13 @@
 (defun kotlin-mode--line-continuation()
   "Return whether this line continues a statement in the previous line"
   (or
-   (kotlin-mode--line-begins "\\([.=:]\\|->\\|[sg]et\\b\\)")
-   (save-excursion
-     (kotlin-mode--prev-line)
-     (kotlin-mode--line-ends "\\([=:]\\|->\\)"))))
+   (and (kotlin-mode--prev-line-begins "\\(if\\|else\\)[ \t]*")
+        (not (kotlin-mode--prev-line-ends "{.*")))
+   (or
+    (kotlin-mode--line-begins 
"\\([.=:]\\|->\\|\\(\\(private\\|public\\|protected\\|internal\\)[ 
\t]*\\)?[sg]et\\b\\)")
+    (save-excursion
+      (kotlin-mode--prev-line)
+      (kotlin-mode--line-ends "\\([=:]\\|->\\)")))))
 
 (defun kotlin-mode--base-indentation ()
   "Return the indentation level of the current line based on brackets only,



reply via email to

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