[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/scala-mode 2f7b335 065/217: Fixes indenting of else body
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/scala-mode 2f7b335 065/217: Fixes indenting of else body |
Date: |
Sun, 29 Aug 2021 11:30:44 -0400 (EDT) |
branch: elpa/scala-mode
commit 2f7b335c2d74d31cddfb21797a8ab7eb49b8c5d9
Author: Heikki Vesalainen <heikkivesalainen@yahoo.com>
Commit: Heikki Vesalainen <heikkivesalainen@yahoo.com>
Fixes indenting of else body
```
if (foo)
(1, 2)
else
(2, 3)
foo // fixed, used to indent as if else had a condition
```
---
scala-mode-indent.el | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/scala-mode-indent.el b/scala-mode-indent.el
index 4d4920e..0c95410 100644
--- a/scala-mode-indent.el
+++ b/scala-mode-indent.el
@@ -505,23 +505,36 @@ point or nil if the point is not in a enumerator element
> 1."
;;; Body
;;;
-(defconst scala-indent:value-keyword-re
- (regexp-opt '("if" "else" "while" "yield" "for" "try" "finally" "catch")
'words))
+(defconst scala-indent:control-keywords-cond-re
+ (regexp-opt '("if" "while" "for") 'words)
+ "All the flow control keywords that are followed by a
+condition (or generators in the case of 'for') in parentheses.")
+
+(defconst scala-indent:control-keywords-other-re
+ (regexp-opt '("else" "do" "yield" "try" "finally" "catch") 'words)
+ "Other flow control keywords (not followed by parentheses)")
+
+(defconst scala-indent:control-keywords-re
+ (concat scala-indent:control-keywords-cond-re
+ scala-indent:control-keywords-other-re))
(defun scala-indent:body-p (&optional point)
- "Returns the position of '=', 'if or 'else if' (TODO: or '=>')
-symbol if current point (or point 'point) is on a line that
-follows said symbol, or nil if not."
+ "Returns the position of '=' symbol, or one of the
+scala-indent:control-keywords-re or
+scala-indent:control-keywords-cond-re keywords if current
+point (or point 'point) is on a line that follows said symbol or
+keyword, or nil if not."
(save-excursion
(when point (goto-char point))
(scala-syntax:beginning-of-code-line)
(or (scala-syntax:looking-back-token scala-syntax:body-start-re 3)
+ (scala-syntax:looking-back-token
scala-indent:control-keywords-other-re)
(progn
;; if, else if
(when (scala-syntax:looking-back-token ")" 1)
(goto-char (match-end 0))
(backward-list))
- (when (scala-syntax:looking-back-token scala-indent:value-keyword-re)
+ (when (scala-syntax:looking-back-token
scala-indent:control-keywords-cond-re)
(goto-char (match-beginning 0))
(when (and (looking-at "\\<if\\>")
(scala-syntax:looking-back-token "\\<else\\>"))
@@ -534,7 +547,7 @@ follows said symbol, or nil if not."
(let ((declaration-end (scala-indent:body-p point)))
(when declaration-end
(goto-char declaration-end)
- (if (looking-at scala-indent:value-keyword-re)
+ (if (looking-at scala-indent:control-keywords-re)
(point)
(when (scala-indent:backward-sexp-to-beginning-of-line)
(scala-indent:goto-run-on-anchor
- [nongnu] elpa/scala-mode f88091a 191/217: `**` at end of multiline comment cause issue #140 (#141), (continued)
- [nongnu] elpa/scala-mode f88091a 191/217: `**` at end of multiline comment cause issue #140 (#141), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 44772cb 196/217: fixed some compilation warnings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 9e5b8af 190/217: Operator characters ids cannot be adjoint to word constituent ids (#139), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode a82f186 192/217: Removed duplicated defconst, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode cc960f3 197/217: fixed some markdown syntax mistakes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 9d3b56e 206/217: Merge pull request #161 from Kazark/scala3-keywords, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode a4ed6b4 073/217: Merge pull request #28 from non/bug/fix-colon-operators, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 27459c3 080/217: Merge pull request #32 from evnm/insert-asterisk-in-multiline-comment, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode e0341e9 199/217: Recognize worksheets as scala files, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 1ab5f64 212/217: fix comment indenting, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 2f7b335 065/217: Fixes indenting of else body,
ELPA Syncer <=
- [nongnu] elpa/scala-mode 5299b4a 205/217: feat: add Scala 3 soft keywords (as regular keywords), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 4014cf6 215/217: Don't make post-self-insert-hook local variable., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 598cb68 217/217: Merge pull request #169 from kurnevsky/post-self-insert-hook, ELPA Syncer, 2021/08/29