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

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

[nongnu] elpa/scala-mode 56280a2 062/217: Made scala-indent:indent-on-sc


From: ELPA Syncer
Subject: [nongnu] elpa/scala-mode 56280a2 062/217: Made scala-indent:indent-on-scaladoc-asterisk be an integral part of the mode.
Date: Sun, 29 Aug 2021 11:30:44 -0400 (EDT)

branch: elpa/scala-mode
commit 56280a2488a0e23ba615709b850fd770f1767cff
Author: Heikki Vesalainen <heikkivesalainen@yahoo.com>
Commit: Heikki Vesalainen <heikkivesalainen@yahoo.com>

    Made scala-indent:indent-on-scaladoc-asterisk be an integral part of the 
mode.
    
    Added scala-indent:add-space-for-scaladoc-asterisk configuration parameter 
(on by defualt).
---
 README.md            | 16 +++++++---------
 scala-mode-indent.el | 27 +++++++++++++++++++--------
 scala-mode-map.el    | 11 ++++-------
 3 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/README.md b/README.md
index 55e9ada..6b7f57c 100644
--- a/README.md
+++ b/README.md
@@ -202,7 +202,7 @@ scaladoc style guide.
   */
 ```
 
-Other multi-line comments are indented under the first asterix.
+Other multi-line comments are indented under the first asterisk.
 
 ```
 /****
@@ -215,6 +215,12 @@ Other multi-line comments are indented under the first 
asterix.
  */
 ```
 
+Typing an asterisk in multi-line comment region, at the start of a
+line, will trigger indent. Furthermore, if the configurable variable
+*scala-indent:add-space-for-scaladoc-asterisk* is t (default) and the
+asterisk was the last character on the line, a space will be inserted
+after it.
+
 ## Filling (i.e. word wrap)
 
 Paragraph *filling* (emacs jargon for word wrap) is supported for
@@ -269,14 +275,6 @@ you may want to try. Just copy-paste it to your `.emacs` 
file.
   ;; code line as a new statement.
   (local-set-key (kbd "<backtab>") 
'scala-indent:indent-with-reluctant-strategy)
 
-  ;; Add the scalaindent:indent-scaladoc-asterisk
-  ;; post-self-insert-hook which indents the multi-line comment
-  ;; asterisk to its correct place when you type it. It also adds a
-  ;; space after the asterisk if the parameter to the function is
-  ;; t. If you don't want the space, replace t with nil.
-  (add-hook 'post-self-insert-hook
-            '(lambda () (scala-mode:indent-scaladoc-asterisk t)))
-
   ;; and other bindings here
 ))
 ```
diff --git a/scala-mode-indent.el b/scala-mode-indent.el
index 8ceb7d1..cb5d6e4 100644
--- a/scala-mode-indent.el
+++ b/scala-mode-indent.el
@@ -114,6 +114,12 @@ are not ruled out by the language specification.
 
 (make-variable-buffer-local 'scala-indent:effective-run-on-strategy)
 
+(defcustom scala-indent:add-space-for-scaladoc-asterisk t
+  "When non-nil, a space will be added after a scaladoc asterisk,
+when it is added to an empty line."
+  :type 'boolean
+  :group 'scala)
+
 (defun scala-indent:run-on-strategy ()
   "Returns the currently effecti run-on strategy"
   (or scala-indent:effective-run-on-strategy
@@ -789,11 +795,16 @@ comment is outside the comment region. "
          (+ (match-beginning 0) 1)))
         (current-column))))
 
+(defun scala-indent:indent-on-parentheses ()
+  (when (and (= (char-syntax (char-before)) ?\))
+             (= (save-excursion (back-to-indentation) (point)) (1- (point))))
+    (scala-indent:indent-line)))
+
 (defconst scala-indent:indent-on-words-re
   (concat "^\\s *"
           (regexp-opt '("catch" "case" "else" "finally" "yield") 'words)))
 
-(defun scala-mode:indent-on-special-words ()
+(defun scala-indent:indent-on-special-words ()
   "This function is meant to be used with post-self-insert-hook.
 
 Indents the line if position is right after a space that is after
@@ -807,23 +818,23 @@ a word that needs to be indented specially."
              (not (nth 8 (syntax-ppss))))
     (scala-indent:indent-line-to (scala-indent:calculate-indent-for-line))))
 
-(defun scala-mode:indent-on-scaladoc-asterisk (&optional insert-space-p)
+(defun scala-indent:indent-on-scaladoc-asterisk ()
   "This function is meant to be used with post-self-insert-hook.
 
 Indents the line if position is right after an asterisk in a
 multi-line comment block and there is only whitespace before the asterisk.
 
-If insert-space is true, also adds a space after the asterisk if
-the asterisk is the last character on the line."
+If scala-indent:add-space-for-scaladoc-asterisk is t, also adds a
+space after the asterisk if the asterisk is the last character on
+the line."
   (let ((state (syntax-ppss)))
     (when (and (integerp (nth 4 state))
                (looking-back "^\\s *\\*" (line-beginning-position)))
-      (when (and insert-space-p
+      (when (and scala-indent:add-space-for-scaladoc-asterisk
                  (looking-at "\\s *$"))
         (insert " "))
       (scala-indent:indent-line-to (scala-indent:scaladoc-indent (nth 8 
state))))))
 
 (defun scala-mode:indent-scaladoc-asterisk (&optional insert-space-p)
-  (message "scala-mode:indent-scaladoc-asterisk has been deprecated, use
-scala-mode:indent-on-scaladoc-asterisk")
-  (scala-mode:indent-on-scaladoc-asterisk insert-space-p))
+  (message "scala-mode:indent-scaladoc-asterisk has been deprecated"))
+
diff --git a/scala-mode-map.el b/scala-mode-map.el
index f6d99ca..edf6088 100644
--- a/scala-mode-map.el
+++ b/scala-mode-map.el
@@ -15,16 +15,13 @@
 (defvar scala-mode-map nil
   "Local key map used for scala mode")
 
-(defun scala-mode-map:indent-parentheses ()
-  (when (and (= (char-syntax (char-before)) ?\))
-             (= (save-excursion (back-to-indentation) (point)) (1- (point))))
-    (scala-indent:indent-line)))
-
 (defun scala-mode-map:add-self-insert-hooks ()
   (add-hook 'post-self-insert-hook
-            'scala-mode-map:indent-parentheses)
+            'scala-indent:indent-on-parentheses)
+  (add-hook 'post-self-insert-hook
+            'scala-indent:indent-on-special-words)
   (add-hook 'post-self-insert-hook
-            'scala-mode:indent-on-special-words))
+            'scala-indent:indent-on-scaladoc-asterisk))
 
 (when (not scala-mode-map)
   (let ((keymap (make-sparse-keymap)))



reply via email to

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