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

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

[nongnu] elpa/scala-mode be89855 084/217: Multi-line comment indentation


From: ELPA Syncer
Subject: [nongnu] elpa/scala-mode be89855 084/217: Multi-line comment indentation and asterisk-insertion on mid-line return.
Date: Sun, 29 Aug 2021 11:30:48 -0400 (EDT)

branch: elpa/scala-mode
commit be8985583dbd8a6b2a7ab690de681246e08e2c0d
Author: Evan Meagher <evm@twitter.com>
Commit: Heikki Vesalainen <heikkivesalainen@yahoo.com>

    Multi-line comment indentation and asterisk-insertion on mid-line return.
    
    Also:
    - Rm unnecessary `looking-at` predicate from 
`scala-indent:indent-on-scaladoc-asterisk`.
    - Only insert asterisk when:
    1. Inside scaladoc comment and
    2. Previous line had leading asterisk margin or was the starting line of
       the comment.
    
    Closes #41
---
 scala-mode-indent.el | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/scala-mode-indent.el b/scala-mode-indent.el
index bb8457e..8f05e3a 100644
--- a/scala-mode-indent.el
+++ b/scala-mode-indent.el
@@ -873,18 +873,29 @@ the line."
   (let ((state (syntax-ppss)))
     (when (and (integerp (nth 4 state))
                (looking-back "^\\s *\\*" (line-beginning-position)))
-      (when (and scala-indent:add-space-for-scaladoc-asterisk
-                 (looking-at "\\s *$"))
+      (when scala-indent:add-space-for-scaladoc-asterisk
         (insert " "))
       (scala-indent:indent-line-to (scala-indent:scaladoc-indent (nth 8 
state))))))
 
 (defun scala-indent:insert-asterisk-on-multiline-comment ()
   "Insert an asterisk at the end of the current line when at the beginning
 of a line inside a multi-line comment "
-  (let ((state (syntax-ppss)))
+  (let ((state (syntax-ppss))
+        (comment-start-pos (nth 8 (syntax-ppss))))
     (when (and (integerp (nth 4 state))
-               (string-match-p "^\\s-*$" (thing-at-point 'line)))
-      (end-of-line)
+               ; Ensure that we're inside a scaladoc comment
+               (string-match-p "^/\\*\\*[^\\*]"
+                               (buffer-substring-no-properties
+                                comment-start-pos
+                                (+ comment-start-pos 4)))
+               ; Ensure that the previous line had a leading asterisk or was 
the comment start.
+               (let ((prev-line (buffer-substring-no-properties
+                                 (line-beginning-position 0)
+                                 (line-end-position 0))))
+                 (or
+                  (string-match-p "^\\s-*\\*" prev-line)
+                  (string-match-p "\\s-*/\\*\\*" prev-line))))
+      (skip-syntax-forward " ")
       (insert "*")
       (scala-indent:indent-on-scaladoc-asterisk))))
 



reply via email to

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