[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)))
- [nongnu] elpa/scala-mode 35f3eef 036/217: Fixes #10, if body in parameter lists, (continued)
- [nongnu] elpa/scala-mode 35f3eef 036/217: Fixes #10, if body in parameter lists, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode da67179 050/217: Merge pull request #15 from non/bug/fix-annotations, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 95e3742 063/217: fix typo in readme, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode ecb0d57 055/217: correct emacs version in check, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode d65f062 064/217: indent `while` like `if`, `for` et al (fixes #22), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 280bff9 037/217: fix hex literal highlighting, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 3149a3d 049/217: Merge pull request #16 from gpampara/readme-update, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode aad6559 041/217: scala-indent:align-forms: obey scala-indent:indent-value-expression, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 94f34b2 077/217: Rm trailing whitespace from all project files., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 5d2416f 088/217: Reverted unintended removal of whitespace deletion hook, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 56280a2 062/217: Made scala-indent:indent-on-scaladoc-asterisk be an integral part of the mode.,
ELPA Syncer <=
- [nongnu] elpa/scala-mode caaebbd 078/217: Rm unneccessary `integerp` invocation., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode b251627 079/217: Comment out example binding of `scala-indent:insert-asterisk-on-multiline-comment`, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode f4b5a6b 095/217: Add .sbt to config, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 037d202 090/217: Merge pull request #44 from vn971/patch-1, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode cc2db35 100/217: indent case body only if first case statement is on its own line, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode e3f91eb 101/217: octal escapes for chars and strings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 74e5194 108/217: sbt support for scala-mode2, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 4581995 111/217: defined find-tag-default-function, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 2e514f8 118/217: proper instructions for sbt-mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode cddd00c 119/217: provide a package target to make a marmalade compatible package, ELPA Syncer, 2021/08/29