branch: elpa/scala-mode commit 6c4e8dcae49a8ec9264eb49690d48881d8af3bc9 Author: Tillmann Rendel <ren...@informatik.uni-marburg.de> Commit: Tillmann Rendel <ren...@informatik.uni-marburg.de>
Delete automatic space between * and /. This allows to type */ to end a multi-line comment even if automatic insertion of spaces after * is turned on. See issue #69. Potential problem: What if the user actually wants to start a line with / in a multi-line comment? --- scala-mode2-indent.el | 12 ++++++++++++ scala-mode2-map.el | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/scala-mode2-indent.el b/scala-mode2-indent.el index 4c8441e..3475f51 100644 --- a/scala-mode2-indent.el +++ b/scala-mode2-indent.el @@ -880,6 +880,18 @@ the line." (insert " ")) (scala-indent:indent-line-to (scala-indent:scaladoc-indent (nth 8 state)))))) +(defun scala-indent:fix-scaladoc-close () + "This function is meant to be used with post-self-insert-hook. + +Changes 'asterisk space slash' to 'asterisk slash' in a +multi-line comment if position is right after that slash and +scala-indent:add-space-for-scaladoc-asterisk is t." + (let ((state (syntax-ppss))) + (when (and scala-indent:add-space-for-scaladoc-asterisk + (integerp (nth 4 state)) + (looking-back "^\\s *\\*\\s /" (line-beginning-position))) + (delete-region (- (point) 2) (- (point) 1))))) + (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 " diff --git a/scala-mode2-map.el b/scala-mode2-map.el index 1f65080..78a847b 100644 --- a/scala-mode2-map.el +++ b/scala-mode2-map.el @@ -17,7 +17,9 @@ (add-hook 'post-self-insert-hook 'scala-indent:indent-on-special-words) (add-hook 'post-self-insert-hook - 'scala-indent:indent-on-scaladoc-asterisk)) + 'scala-indent:indent-on-scaladoc-asterisk) + (add-hook 'post-self-insert-hook + 'scala-indent:fix-scaladoc-close)) (defun scala-mode-map:add-remove-indent-hook () (add-hook 'post-command-hook