[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/scala-mode 7113976 059/217: Indenting for multi-line strin
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/scala-mode 7113976 059/217: Indenting for multi-line strings with margin, fixed row comment indent |
Date: |
Sun, 29 Aug 2021 11:30:43 -0400 (EDT) |
branch: elpa/scala-mode
commit 7113976a0e3c0d7961439359663339aa01f79561
Author: Heikki Vesalainen <heikkivesalainen@yahoo.com>
Commit: Heikki Vesalainen <heikkivesalainen@yahoo.com>
Indenting for multi-line strings with margin, fixed row comment indent
---
README.md | 1 -
scala-mode-indent.el | 36 ++++++++++++++++++++++++++----------
scala-mode-syntax.el | 1 +
3 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/README.md b/README.md
index 6593f82..080456f 100644
--- a/README.md
+++ b/README.md
@@ -325,7 +325,6 @@ customization variable *frame-background-mode* to *dark*
(use **M-x**
multiple lines
- beginning-of-defun, end-of-defun
- indent case, etc after they are typed (use first space as self-insert-hook)
-- indent multi-line strings with margin correctly
- movement commands to move to previous or next definition (val,
var, def, class, trait, object)
- highlight headings and annotations inside scaladoc specially (use
diff --git a/scala-mode-indent.el b/scala-mode-indent.el
index 47772d7..1e656e1 100644
--- a/scala-mode-indent.el
+++ b/scala-mode-indent.el
@@ -662,20 +662,25 @@ anchored at 'anchor'."
(goto-char anchor)
;; find =
(scala-syntax:has-char-before ?= start))
- (message "=")
+; (message "=")
scala-indent:step)
(t
; (message "normal at %d" (current-column))
0)))
-(defun scala-indent:goto-line-comment-anchor (&optional pos)
+(defun scala-indent:goto-line-comment-anchor (&optional point)
"Goto and return the position relative to which a line comment
will be indented. This will be the start of the line-comment on
previous line, if any."
- (if (and (looking-at "\\s *//")
- (forward-comment -1))
- (point)))
-
+ (let ((pos (point)))
+ (when (save-excursion
+ (when point (goto-char point))
+ (when (and (looking-at "\\s *//")
+ (not (scala-syntax:looking-back-empty-line-p))
+ (forward-comment -1))
+ (setq pos (point))))
+ (goto-char pos))))
+
;;;
;;; Indentation engine
;;;
@@ -686,6 +691,7 @@ the sum of the value and the respective indent step, or nil
if
nothing was applied."
(when rule-indents
(save-excursion
+ (when point (goto-char point))
(let* ((pos (scala-syntax:beginning-of-code-line))
(rule-indent (car rule-indents))
(rule-statement (car rule-indent))
@@ -694,7 +700,7 @@ nothing was applied."
(if anchor
(progn
(if scala-mode:debug-messages
- (message "indenting acording to %s at %d" rule-statement
anchor))
+ (message "indenting acording to %s at %d for pos %d for
point %s" rule-statement anchor pos point))
(when (/= anchor (point))
(error (format "Assertion error: anchor=%d, point=%d" anchor
(point))))
(+ (current-column)
@@ -748,9 +754,19 @@ strings"
(let ((state (save-excursion (syntax-ppss (line-beginning-position)))))
(if (not (nth 8 state)) ;; 8 = start pos of comment or string, nil if none
(scala-indent:indent-code-line strategy)
- (if (integerp (nth 4 state)) ;; 4 = nesting level of comment for scaladoc
- (scala-indent:indent-line-to (scala-indent:scaladoc-indent (nth 8
state)))
- (scala-indent:indent-line-to (current-indentation))))))
+ (scala-indent:indent-line-to
+ (cond ((integerp (nth 4 state)) ;; 4 = nesting level of multi-line
comment
+ (scala-indent:scaladoc-indent (nth 8 state)))
+ ((eq t (nth 3 state)) ;; 3 = t for multi-line string
+ (or (save-excursion
+ (beginning-of-line)
+ (when (and (looking-at "\\s *|")
+ (progn (goto-char (nth 8 state))
+ (looking-at "\\(\"\"\"\\)|")))
+ (goto-char (match-end 1))
+ (current-column)))
+ (current-indentation)))
+ (t (current-indentation)))))))
(defun scala-indent:indent-with-reluctant-strategy ()
(interactive)
diff --git a/scala-mode-syntax.el b/scala-mode-syntax.el
index 6ef3099..27b5f30 100644
--- a/scala-mode-syntax.el
+++ b/scala-mode-syntax.el
@@ -613,6 +613,7 @@ stableId"
(defun scala-syntax:skip-forward-ignorable ()
"Moves forward over ignorable whitespace and comments. A
completely empty line is not ignorable and will not be mobed over."
+ (interactive)
(save-match-data
(while (and (not (scala-syntax:looking-at-empty-line-p))
(forward-comment 1)))
- [nongnu] elpa/scala-mode 2a7b0fd 195/217: Moved ensime/emacs-scala-mode back to hvesalai/emacs-scala-mode, (continued)
- [nongnu] elpa/scala-mode 2a7b0fd 195/217: Moved ensime/emacs-scala-mode back to hvesalai/emacs-scala-mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 5d28cb3 210/217: feat: support trailing commas (>= Scala 2.12.2), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode b21befd 211/217: Fix README.md indenting, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode d837c96 203/217: doc: supports both Scala 2 and 3 (to some extent), not just 2.9, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 2bf5621 207/217: Update README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 402d6df 209/217: Merge pull request #165 from fommil/sbtn, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode ac8106f 025/217: Update README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode d81bc28 028/217: indenting code lines also removes trailing whitespace, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 26cd0b7 040/217: merged from align-parameters, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 884795f 052/217: more fixes to strings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 7113976 059/217: Indenting for multi-line strings with margin, fixed row comment indent,
ELPA Syncer <=
- [nongnu] elpa/scala-mode 8d4f34f 058/217: Use font-lock-doc-face for scaladoc comments, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 689bd7d 089/217: (require 'package), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode cb3f278 086/217: Update for marmalade / melpa package., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 1a241eb 076/217: Add `scala-indent:insert-asterisk-on-multiline-comment`., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 5cd1b20 068/217: Properly align constructor val and var params., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode ad73d10 096/217: Merge pull request #49 from zbskii/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode defa2af 098/217: pkg.el cleanup, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 13b30a6 093/217: Added Hugh Giddens to contributors, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 9ab0a59 091/217: Update README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode c48b479 113/217: Update README.md, ELPA Syncer, 2021/08/29