[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
- [nongnu] elpa/kotlin-mode 0e542ae2f7 114/162: Merge pull request #37 from cjfuller/fix-star-projected-types, (continued)
- [nongnu] elpa/kotlin-mode 0e542ae2f7 114/162: Merge pull request #37 from cjfuller/fix-star-projected-types, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 2467eceee3 118/162: Properly indent multi-line comment blocks, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 3c48b34e0d 127/162: Delete unused function, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 1f57bb5a92 135/162: Fix test runner in .travis.yml, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 96b37d211c 139/162: Merge pull request #45 from taku0/add_backup_to_gitignore, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode d9d77ed459 069/162: indentation logic handling lambdas, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 82db4dce0c 077/162: basic indentation test, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 49ef724e96 076/162: additional keywords and smarter highlighting, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 257647d5d6 083/162: handle chained method calls on multiple lines, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode e1540a5ddf 087/162: Merge pull request #10 from gregghz/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode ad16798e02 091/162: Set proper indentation for closing brackets preceded by a blank line,
ELPA Syncer <=
- [nongnu] elpa/kotlin-mode ebcf6f3730 102/162: switch to tab-width, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 1b6d311168 108/162: Merge pull request #31 from jojojames/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 734b08408c 103/162: Add send-{block, buffer, line, region}-and-focus functions, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 472ae23d6a 113/162: Fix syntax highlighting of star-projected types, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 002dd1497c 112/162: Merge pull request #36 from mikegolod/issue-35, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode ea5f378e40 129/162: Merge pull request #43 from taku0/add-prefix-to-methods, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode b4b575ce3a 130/162: Merge pull request #41 from ppareit/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 5dbf5dbf5f 132/162: Add *~ to .gitignore, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode e8100a9070 137/162: Adds more emacs versions to test matrix, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 29730e7908 153/162: Add Makefile, ELPA Syncer, 2022/01/29