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

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

[nongnu] elpa/scala-mode 1a241eb 076/217: Add `scala-indent:insert-aster


From: ELPA Syncer
Subject: [nongnu] elpa/scala-mode 1a241eb 076/217: Add `scala-indent:insert-asterisk-on-multiline-comment`.
Date: Sun, 29 Aug 2021 11:30:47 -0400 (EDT)

branch: elpa/scala-mode
commit 1a241eb58769f33d46edae0c5c6145f8b1c7f108
Author: Evan Meagher <evm@twitter.com>
Commit: Evan Meagher <evm@twitter.com>

    Add `scala-indent:insert-asterisk-on-multiline-comment`.
    
    When enabled, inserts asterisk at end-of-line of multi-line comments.
---
 README.md            |  9 +++++++++
 scala-mode-indent.el | 11 ++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 39f9fe1..f45dc55 100644
--- a/README.md
+++ b/README.md
@@ -274,6 +274,15 @@ you may want to try. Just copy-paste it to your `.emacs` 
file.
   ;; 'reindent-then-newline-and-indent' command.
   (local-set-key (kbd "RET") 'newline-and-indent)
 
+  ;; Alternatively, bind the 'newline-and-indent' command and
+  ;; 'scala-indent:insert-asterisk-on-multiline-comment' to RET in
+  ;; order to get indentation and asterisk-insertion within multi-line
+  ;; comments.
+  (local-set-key (kbd "RET") '(lambda ()
+    (interactive)
+    (newline-and-indent)
+    (scala-indent:insert-asterisk-on-multiline-comment)))
+
   ;; Bind the 'join-line' command to C-M-j. This command is normally
   ;; bound to M-^ which is hard to access, especially on some European
   ;; keyboards. The 'join-line' command has the effect or joining the
diff --git a/scala-mode-indent.el b/scala-mode-indent.el
index 18f5079..7a89efc 100644
--- a/scala-mode-indent.el
+++ b/scala-mode-indent.el
@@ -856,6 +856,15 @@ the line."
         (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)))
+    (when (and (integerp (nth 4 state))
+               (integerp (string-match-p "^\\s-*$" (thing-at-point 'line))))
+      (end-of-line)
+      (insert "*")
+      (scala-indent:indent-on-scaladoc-asterisk))))
+
 (defun scala-mode:indent-scaladoc-asterisk (&optional insert-space-p)
   (message "scala-mode:indent-scaladoc-asterisk has been deprecated"))
-



reply via email to

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