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

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

[nongnu] elpa/kotlin-mode 1f60b01659 148/162: Fix indentation of multili


From: ELPA Syncer
Subject: [nongnu] elpa/kotlin-mode 1f60b01659 148/162: Fix indentation of multiline comment at the beginning of buffer
Date: Sat, 29 Jan 2022 08:25:31 -0500 (EST)

branch: elpa/kotlin-mode
commit 1f60b0165972df8cef46ed8409bf06d0c0ff425e
Author: taku0 <mxxouy6x3m_github@tatapa.org>
Commit: taku0 <mxxouy6x3m_github@tatapa.org>

    Fix indentation of multiline comment at the beginning of buffer
    
    Example:
    
    /*
     * aaa
     * bbb
     * ccc
     */
---
 kotlin-mode.el           | 18 +++++++++++-------
 test/kotlin-mode-test.el | 29 +++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/kotlin-mode.el b/kotlin-mode.el
index 0c31e91dbd..adf5cc5497 100644
--- a/kotlin-mode.el
+++ b/kotlin-mode.el
@@ -148,8 +148,9 @@
 
     ;; b-style comment
     (modify-syntax-entry ?/ ". 124b" st)
-    (modify-syntax-entry ?* ". 23" st)
+    (modify-syntax-entry ?* ". 23n" st)
     (modify-syntax-entry ?\n "> b" st)
+    (modify-syntax-entry ?\r "> b" st)
     st))
 
 
@@ -537,20 +538,23 @@ fun foo() {
    of the following format:
    /**
     * Description here
-    */ "
+    */"
   (save-excursion
     (let ((in-comment-block nil)
-          (keep-going (not (kotlin-mode--line-ends "\\*\\*/"))))
+          (keep-going (and
+                       (not (kotlin-mode--line-begins "\\*\\*+/"))
+                       (not (kotlin-mode--line-begins "/\\*"))
+                       (nth 4 (syntax-ppss)))))
       (while keep-going
         (kotlin-mode--prev-line)
         (cond
+         ((kotlin-mode--line-begins "/\\*")
+          (setq keep-going nil)
+          (setq in-comment-block t))
          ((bobp)
           (setq keep-going nil))
          ((kotlin-mode--line-contains "\\*/")
-          (setq keep-going nil))
-         ((kotlin-mode--line-begins "/\\*")
-          (setq keep-going nil)
-          (setq in-comment-block t))))
+          (setq keep-going nil))))
       in-comment-block)))
 
 (defun kotlin-mode--indent-line ()
diff --git a/test/kotlin-mode-test.el b/test/kotlin-mode-test.el
index bbb39e504d..fe96b6218a 100644
--- a/test/kotlin-mode-test.el
+++ b/test/kotlin-mode-test.el
@@ -117,6 +117,35 @@ return a + b
       (kotlin-mode--indent-line)
       (should (equal text (buffer-string))))))
 
+(ert-deftest kotlin-mode--indent-comment-at-bob--test ()
+  (with-temp-buffer
+    (let ((text "/*
+ *
+ *
+ */"))
+      (pop-to-buffer (current-buffer))
+      (insert text)
+      (goto-char (point-min))
+      (kotlin-mode)
+      (setq-local indent-tabs-mode nil)
+      (setq-local tab-width 4)
+      (setq-local kotlin-tab-width 4)
+
+      (kotlin-mode--indent-line)
+      (should (equal text (buffer-string)))
+
+      (forward-line)
+      (kotlin-mode--indent-line)
+      (should (equal text (buffer-string)))
+
+      (forward-line)
+      (kotlin-mode--indent-line)
+      (should (equal text (buffer-string)))
+
+      (forward-line)
+      (kotlin-mode--indent-line)
+      (should (equal text (buffer-string))))))
+
 (defun next-non-empty-line ()
   "Moves to the next non-empty line"
   (forward-line)



reply via email to

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