[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/scala-mode 763c93c 107/217: scala-indent:join-line
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/scala-mode 763c93c 107/217: scala-indent:join-line |
Date: |
Sun, 29 Aug 2021 11:30:53 -0400 (EDT) |
branch: elpa/scala-mode
commit 763c93cddc9388905452c36688fcc3efd642aed0
Author: Heikki Vesalainen <heikkivesalainen@yahoo.com>
Commit: Heikki Vesalainen <heikkivesalainen@yahoo.com>
scala-indent:join-line
---
README.md | 13 ++++++++++---
scala-mode2-indent.el | 28 +++++++++++++++++++++++++---
scala-mode2.el | 4 +++-
3 files changed, 38 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index 4f02bc9..2189b32 100644
--- a/README.md
+++ b/README.md
@@ -274,6 +274,13 @@ To re-fill a paragraph, use the *fill-paragraph* command (
**M-q**
command. To set the default, you use the *customize-variable* command
or a mode-hook.
+## Joinin lines
+
+Scala-mode defines its own join-line function. Besides doing what the
+normal join-line function does, it also removes comment marks
+(asterisks and slashes) when comment lines are joined and space when
+code lines are joined and the uppper line ended with a dot.
+
## Motion
Basic emacs motion will work as expected.
@@ -313,12 +320,12 @@ you may want to try. Just copy-paste it to your `.emacs`
file.
;; (newline-and-indent)
;; (scala-indent:insert-asterisk-on-multiline-comment)))
- ;; Bind the 'join-line' command to C-M-j. This command is normally
+ ;; Bind the 'join-line' command to M-RET. This command is normally
;; bound to M-^ which is hard to access, especially on some European
;; keyboards. The 'join-line' command has the effect or joining the
;; current line with the previous while fixing whitespace at the
- ;; joint.
- (local-set-key (kbd "C-M-j") 'join-line)
+ ;; joint.
+ (local-set-key (kbd "M-RET") 'join-line)
;; Bind the backtab (shift tab) to
;; 'scala-indent:indent-with-reluctant-strategy command. This is usefull
diff --git a/scala-mode2-indent.el b/scala-mode2-indent.el
index cbaf176..af24925 100644
--- a/scala-mode2-indent.el
+++ b/scala-mode2-indent.el
@@ -642,7 +642,7 @@ with an opening parentheses, or nil if not."
anchor for calculating opening parenthesis indent for the current
point (or point 'point'). Returns point or nil, if line does not
start with opening parenthesis."
- ;; There are four cases we need to consider:
+ ;; There are five cases we need to consider:
;; 1. curry parentheses, i.e. 2..n parentheses groups.
;; 2. value body parentheses (follows '=').
;; 3. parameters, etc on separate line (who would be so mad?)
@@ -883,8 +883,8 @@ the line."
(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 "
- (let ((state (syntax-ppss))
- (comment-start-pos (nth 8 (syntax-ppss))))
+ (let* ((state (syntax-ppss))
+ (comment-start-pos (nth 8 state)))
(when (and (integerp (nth 4 state))
; Ensure that we're inside a scaladoc comment
(string-match-p "^/\\*\\*[^\\*]"
@@ -905,4 +905,26 @@ of a line inside a multi-line comment "
(defun scala-mode:indent-scaladoc-asterisk (&optional insert-space-p)
(message "scala-mode:indent-scaladoc-asterisk has been deprecated"))
+(defun scala-indent:join-line ()
+ (interactive)
+ (join-line)
+ (let ((state (syntax-ppss)))
+ (cond
+ ((and (integerp (nth 4 state)) ; nestable comment (i.e. with *)
+ (looking-at " \\*")
+ (save-excursion (goto-char (max (nth 8 state)
(line-beginning-position)))
+ (looking-at "\\s */?\\*")))
+ (delete-forward-char 2)
+ (delete-horizontal-space)
+ (insert " "))
+ ((and (nth 4 state) ; row comment (i.e. with //)
+ (looking-at " //"))
+ (delete-forward-char 3)
+ (delete-horizontal-space)
+ (insert " "))
+ ((and (not (nth 8 (syntax-ppss))) ; not in comment or string
+ (= (char-before) ?.))
+ (delete-horizontal-space)
+ ))))
+
(provide 'scala-mode2-indent)
diff --git a/scala-mode2.el b/scala-mode2.el
index c53765f..42f3b40 100644
--- a/scala-mode2.el
+++ b/scala-mode2.el
@@ -62,7 +62,8 @@ When started, runs `scala-mode-hook'.
'comment-multi-line
'forward-sexp-function
'indent-line-function
- 'indent-tabs-mode)
+ 'indent-tabs-mode
+ 'join-line)
(add-hook 'syntax-propertize-extend-region-functions
'scala-syntax:propertize-extend-region)
@@ -93,6 +94,7 @@ When started, runs `scala-mode-hook'.
forward-sexp-function 'scala-mode:forward-sexp-function
indent-line-function 'scala-indent:indent-line
indent-tabs-mode nil
+ join-line 'scala-indent:join-line
)
(use-local-map scala-mode-map)
;; add indent functionality to some characters
- [nongnu] elpa/scala-mode 1dd5825 085/217: Added comment syntax for bash preambles (#!...!#) in scala script files, (continued)
- [nongnu] elpa/scala-mode 1dd5825 085/217: Added comment syntax for bash preambles (#!...!#) in scala script files, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 16d6f36 067/217: Added a not to README about font-lock-doc-face, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode b55ca83 066/217: Merge pull request #23 from hvesalai/issue22, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode aa38dae 083/217: Fixes #38: 100% CPU usage for multi-line strings in some cases., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 0af3b07 069/217: Added Makefile and fixed compilation warnings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode be89855 084/217: Multi-line comment indentation and asterisk-insertion on mid-line return., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 711091a 087/217: moved provides to end of files, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 6312b36 082/217: Make the code agreeable to Emacs-Lisp mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 18a52f0 094/217: Update installation instructions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode a1ea0b7 097/217: Proper instructions and autoload settings for package-based install, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 763c93c 107/217: scala-indent:join-line,
ELPA Syncer <=
- [nongnu] elpa/scala-mode c62ecf9 109/217: Update README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode aea047a 104/217: Create .gitignore with *.elc, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode d4cccb0 112/217: scala-mode:set-scala-syntax-mode to support sbt-mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode c9dd697 103/217: alphaid-re for SIP11 support, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 89c7138 102/217: Merge pull request #52 from non/topic/octal-escapes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 600d27b 115/217: join-line cannot be re-defined like this, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 890b7eb 129/217: Document */ behavior in multi-line comments., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 3d330ad 126/217: Makefile clean-up 2, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 6c4e8dc 128/217: Delete automatic space between * and /., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 84ff656 138/217: Update README.md, ELPA Syncer, 2021/08/29