[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/scala-mode 081a92b 081/217: scala-indent:remove-indent-fro
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/scala-mode 081a92b 081/217: scala-indent:remove-indent-from-previous-empty-line |
Date: |
Sun, 29 Aug 2021 11:30:48 -0400 (EDT) |
branch: elpa/scala-mode
commit 081a92b0b6431f235658d99027f7cb510fe68f11
Author: Heikki Vesalainen <heikkivesalainen@yahoo.com>
Commit: Heikki Vesalainen <heikkivesalainen@yahoo.com>
scala-indent:remove-indent-from-previous-empty-line
New functionality that removes previously added indent when the
cursors moves away from the line and the line was left otherwise
empty.
---
scala-mode-indent.el | 24 +++++++++++++++++++++++-
scala-mode-map.el | 4 ++++
scala-mode.el | 1 +
3 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/scala-mode-indent.el b/scala-mode-indent.el
index 27a3b88..48d5628 100644
--- a/scala-mode-indent.el
+++ b/scala-mode-indent.el
@@ -761,6 +761,25 @@ column, if it was at the left margin."
(indent-line-to column)
(save-excursion (indent-line-to column)))))
+(make-variable-buffer-local 'scala-indent:previous-indent-pos)
+
+(defun scala-indent:remove-indent-from-previous-empty-line ()
+ "Handles removing of whitespace from a previosly indented code
+line that was left empty (i.e. whitespaces only). Also clears the
+scala-indent:previous-indent-pos variable that controls the process."
+ (when (and scala-indent:previous-indent-pos
+ (/= scala-indent:previous-indent-pos (point)))
+ (save-excursion
+ (beginning-of-line)
+ (if (= scala-indent:previous-indent-pos
+ (point))
+ (setq scala-indent:previous-indent-pos
+ (when (looking-at "^\\s +$") (point)))
+ (goto-char scala-indent:previous-indent-pos)
+ (when (looking-at "^\\s +$")
+ (delete-region (match-beginning 0) (match-end 0)))
+ (setq scala-indent:previous-indent-pos nil)))))
+
(defun scala-indent:indent-code-line (&optional strategy)
"Indent a line of code. Expect to be outside of any comments or
strings"
@@ -772,7 +791,10 @@ strings"
; (message "run-on-strategy is %s" (scala-indent:run-on-strategy))
(scala-indent:indent-line-to (scala-indent:calculate-indent-for-line))
(scala-lib:delete-trailing-whitespace)
- )
+ (setq scala-indent:previous-indent-pos
+ (save-excursion
+ (beginning-of-line)
+ (when (looking-at "^\\s +$") (point)))))
(defun scala-indent:indent-line (&optional strategy)
"Indents the current line."
diff --git a/scala-mode-map.el b/scala-mode-map.el
index d827e41..15e46a5 100644
--- a/scala-mode-map.el
+++ b/scala-mode-map.el
@@ -23,6 +23,10 @@
(add-hook 'post-self-insert-hook
'scala-indent:indent-on-scaladoc-asterisk))
+(defun scala-mode-map:add-remove-indent-hook ()
+ (add-hook 'post-command-hook
+ 'scala-indent:remove-indent-from-previous-empty-line))
+
(when (not scala-mode-map)
(let ((keymap (make-sparse-keymap)))
(scala-mode-map:define-keys
diff --git a/scala-mode.el b/scala-mode.el
index bfb3f6f..81ff902 100644
--- a/scala-mode.el
+++ b/scala-mode.el
@@ -99,6 +99,7 @@ When started, runs `scala-mode-hook'.
(turn-on-font-lock)
;; add indent functionality to some characters
(scala-mode-map:add-self-insert-hooks)
+ (scala-mode-map:add-remove-indent-hook)
)
;; Attach .scala files to the scala-mode
- [nongnu] elpa/scala-mode a2a1b1d 208/217: compile mode with sbt thin client, (continued)
- [nongnu] elpa/scala-mode a2a1b1d 208/217: compile mode with sbt thin client, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 54fa36f 200/217: Merge pull request #159 from kpbochenek/fix-files-association-alist, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 5058a85 204/217: doc: clarify Scala versions supported, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 0c5ed9e 022/217: deleted example files, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 61a511f 021/217: Update README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode fe5c2c4 031/217: Fixes #11: was still using the slow regexp, not faster, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 1a3d958 029/217: forward/backward-sexp, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode e30b35a 008/217: Indentation working, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 59cdd94 074/217: Add `scala-indent:use-javadoc-style` defcustom., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 347faeb 075/217: Add Evan Meagher to contributors list., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 081a92b 081/217: scala-indent:remove-indent-from-previous-empty-line,
ELPA Syncer <=
- [nongnu] elpa/scala-mode 0fac9ae 014/217: removed debug messages, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 9476d4c 018/217: Fixes #3: alignment of else inside parens, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 3f724ed 030/217: Add the scala-indent:pad-equals setting., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 6257e3b 033/217: Renamed bad-equals to indent-value-expression. Added info to README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 4e3a24f 043/217: Updated Examples.md to reflect issues already solved, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 338ff73 060/217: Changed the indent defaults, closes #19, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 6c257f6 057/217: Enhanced support for comments and multi-line strings, including, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 68ca175 056/217: Fixes #20, the cons bug (a :: b :: Nil) as well as improving some of, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 78fff40 039/217: scala-indent:align-forms customization variable, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode f61e32d 047/217: Update README.md, ELPA Syncer, 2021/08/29