[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/scala-mode 1a3d958 029/217: forward/backward-sexp
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/scala-mode 1a3d958 029/217: forward/backward-sexp |
Date: |
Sun, 29 Aug 2021 11:30:38 -0400 (EDT) |
branch: elpa/scala-mode
commit 1a3d958f28d46c999ccde122e8cfece0a5997a09
Author: Heikki Vesalainen <heikkivesalainen@yahoo.com>
Commit: Heikki Vesalainen <heikkivesalainen@yahoo.com>
forward/backward-sexp
---
README.md | 6 ++++--
scala-mode-map.el | 2 --
scala-mode-syntax.el | 23 ++++++++---------------
scala-mode.el | 10 +++++++++-
4 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/README.md b/README.md
index bc0d1c5..38692bc 100644
--- a/README.md
+++ b/README.md
@@ -76,7 +76,9 @@ will toggle between the modes.
## Motion
-Basic emacs motion will work, including movement over expressions (M-C-f,
M-C-b).
+Basic emacs motion will work as expected. The forward-sexp and
+backward-sexp (M-C-f, M-C-b) motion commands will move over reserved
+words, literals, ids and lists.
## Code highlighting
@@ -87,11 +89,11 @@ should work is welcomed as issues to this github project.
- supports multi-line strings
- highlights only properly formatted string and character constants
- fills scaladoc comments properly (TODO row comments)
+- indenting a code line removes trailing whitespace
## Future work
- indent scaladoc left margin correctly
-- indenting a row should remove trailing whitespace and converts tabs to spaces
- indent and fill multi-line strings with margin correctly
- movement commands to move to previous or next definition (val,
var, def, class, trait, object)
diff --git a/scala-mode-map.el b/scala-mode-map.el
index bb4dabc..2108e11 100644
--- a/scala-mode-map.el
+++ b/scala-mode-map.el
@@ -28,8 +28,6 @@
keymap
(
([backtab] 'scala-indent:indent-with-reluctant-strategy)
- ;; TODO: remove, use forward-sexp-function insetead
- ((kbd "C-M-b") 'scala-syntax:backward-sexp)
([(control c)(control r)] 'scala-indent:rotate-run-on-strategy)
([(control c)(control c)] 'comment-region)
;; ("}" 'scala-electric-brace)
diff --git a/scala-mode-syntax.el b/scala-mode-syntax.el
index 1e83cd6..d42f21a 100644
--- a/scala-mode-syntax.el
+++ b/scala-mode-syntax.el
@@ -663,7 +663,7 @@ one."
(while (scala-syntax:looking-at scala-syntax:modifiers-re)
(scala-syntax:forward-sexp)
(when (scala-syntax:looking-at "[")
- (forward-sexp)))))
+ (forward-list)))))
(defun scala-syntax:looking-back-else-if-p ()
;; TODO: rewrite using (scala-syntax:if-skipped
(scala:syntax:skip-backward-else-if))
@@ -733,16 +733,10 @@ beginning of the skipped expression."
(forward-comment (buffer-size))
(while (< 0 (+ (skip-syntax-forward " ")
(skip-chars-forward scala-syntax:delimiter-group))))
-
- (if (not (= (char-syntax (char-after)) ?\.))
- ;; emacs can handle everything but opchars
- (forward-sexp)
- ;; just because some char has punctuation syntax, doesn't mean the
- ;; position has it (since the propertize function can change
- ;; things. So... let's first try to handle it as punctuation and
- ;; if we got no success, then we let emacs try
- (when (= (skip-syntax-forward ".") 0)
- (forward-sexp))))
+
+ ;; emacs can handle everything but opchars
+ (when (= (skip-syntax-forward ".") 0)
+ (goto-char (or (scan-sexps (point) 1) (buffer-end 1)))))
(defun scala-syntax:backward-sexp ()
"Move backward one scala expression. It can be: parameter
@@ -756,10 +750,9 @@ beginning of the skipped expression."
(while (> 0 (+ (skip-syntax-backward " ")
(skip-chars-backward scala-syntax:delimiter-group))))
- (if (not (or (bobp) (= (char-syntax (char-before)) ?\.)))
- (backward-sexp)
- (when (= (skip-syntax-backward ".") 0)
- (backward-sexp))))
+ (when (= (skip-syntax-backward ".") 0)
+ (goto-char (or (scan-sexps (point) -1) (buffer-end -1)))
+ (backward-prefix-chars)))
(defun scala-syntax:has-char-before (char end)
(save-excursion
diff --git a/scala-mode.el b/scala-mode.el
index 28012e6..6c1a663 100644
--- a/scala-mode.el
+++ b/scala-mode.el
@@ -49,6 +49,13 @@
(defconst scala-mode:paragraph-separate
(concat scala-mode:comment-line-start "$"))
+(defun scala-mode:forward-sexp-function (&optional count)
+ (unless count (setq count 1))
+ (if (< count 0)
+ (dotimes (n (abs count))
+ (scala-syntax:backward-sexp))
+ (dotimes (n count)
+ (scala-syntax:forward-sexp))))
;; (defun scala-mode ()
;; "Major mode for editing scala code.
@@ -90,6 +97,7 @@ When started, runs `scala-mode-hook'.
'comment-start-skip
'comment-column
'comment-multi-line
+ 'forward-sexp-function
'indent-line-function
'indent-tabs-mode)
@@ -118,7 +126,7 @@ When started, runs `scala-mode-hook'.
;; TODO: comment-indent-function
;; TODO: forward-sexp-function
-
+ forward-sexp-function 'scala-mode:forward-sexp-function
indent-line-function 'scala-indent:indent-line
indent-tabs-mode nil
)
- [nongnu] elpa/scala-mode 618f0fb 163/217: remove 'scala-indent:indent-on-parentheses in preference of smartparens, (continued)
- [nongnu] elpa/scala-mode 618f0fb 163/217: remove 'scala-indent:indent-on-parentheses in preference of smartparens, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 56cba29 194/217: Fix bad syntax when `*/` is prefixed by an opcode. (#143), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode a1ff6f3 202/217: feat: add Scala 3 keywords, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 46bb948 198/217: Fix #155, remove ob-scala.el, ELPA Syncer, 2021/08/29
- [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 <=
- [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, 2021/08/29
- [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