[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/kotlin-mode 52631abde4 1/2: Fix indentation for if/else an
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/kotlin-mode 52631abde4 1/2: Fix indentation for if/else and getters/setters with visibility modifiers |
Date: |
Tue, 17 May 2022 16:58:42 -0400 (EDT) |
branch: elpa/kotlin-mode
commit 52631abde449ec654e3d0ab0602f6c29aa83f9fe
Author: Tanner Davies <tanner.e.davies@gmail.com>
Commit: Tanner Davies <tanner.e.davies@gmail.com>
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,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/kotlin-mode 52631abde4 1/2: Fix indentation for if/else and getters/setters with visibility modifiers,
ELPA Syncer <=