[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode 85e05ea 271/496: Merge pull request #105 from u
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode 85e05ea 271/496: Merge pull request #105 from uk-ar/fix-move-by-sexp |
Date: |
Sun, 29 Aug 2021 11:33:49 -0400 (EDT) |
branch: elpa/swift-mode
commit 85e05ea5e901fa7010db62d39c6efd728ccf3448
Merge: 37cab39 ce816a8
Author: Arthur Evstifeev <mail@ap4y.me>
Commit: Arthur Evstifeev <mail@ap4y.me>
Merge pull request #105 from uk-ar/fix-move-by-sexp
Fix move by sexp
---
swift-mode.el | 25 ++++++++++++-------------
test/indentation-tests.el | 21 ++++++++++++++-------
2 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/swift-mode.el b/swift-mode.el
index edea55f..d14cd9f 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -107,8 +107,8 @@
(top-level-st
("import" type)
(decl)
- ("ACCESSMOD" "class" class-decl-exp "class-{" class-level-sts "}")
- ("ACCESSMOD" "protocol" class-decl-exp "protocol-{" protocol-level-sts
"}")
+ ("ACCESSMOD" "class" class-decl-exp "{" class-level-sts "}")
+ ("ACCESSMOD" "protocol" class-decl-exp "{" protocol-level-sts "}")
)
(class-level-sts (class-level-st) (class-level-st ";" class-level-st))
@@ -278,16 +278,16 @@ We try to constraint those lookups by reasonable number
of lines.")
((and (looking-at "\n\\|\/\/") (swift-smie--implicit-semi-p))
(if (eolp) (forward-char 1) (forward-comment 1))
";")
-
- ((looking-at "{") (forward-char 1)
- (if (looking-back "\\(class\\|protocol\\) [^{]+{" (line-beginning-position
swift-smie--lookback-max-lines) t)
- (concat (match-string 1) "-{")
- "{"))
+ (t
+ (forward-comment (point))
+ (cond
+ ((looking-at "{") (forward-char 1) "{")
((looking-at "}") (forward-char 1) "}")
((looking-at ",") (forward-char 1) ",")
((looking-at ":") (forward-char 1)
- (if (looking-back "\\(case [^:]+\\|default\\):" (line-beginning-position
0) t)
+ ;; look-back until "case", "default", ":", "{", ";"
+ (if (looking-back "\\(case[\n\t ][^:{;]+\\|default[\n\t ]*\\):")
"case-:"
":"))
@@ -327,6 +327,7 @@ We try to constraint those lookups by reasonable number of
lines.")
"else"))
(t tok))))
))
+ ))
(defun swift-smie--backward-token ()
(let ((pos (point)))
@@ -336,15 +337,13 @@ We try to constraint those lookups by reasonable number
of lines.")
(swift-smie--implicit-semi-p))
";")
- ((eq (char-before) ?\{) (backward-char 1)
- (if (looking-back "\\(class\\|protocol\\) [^{]+"
(line-beginning-position swift-smie--lookback-max-lines) t)
- (concat (match-string 1) "-{")
- "{"))
+ ((eq (char-before) ?\{) (backward-char 1) "{")
((eq (char-before) ?\}) (backward-char 1) "}")
((eq (char-before) ?,) (backward-char 1) ",")
((eq (char-before) ?:) (backward-char 1)
- (if (looking-back "case [^:]+\\|default" (line-beginning-position 0))
+ ;; look-back until "case", "default", ":", "{", ";"
+ (if (looking-back "\\(case[\n\t ][^:{;]+\\|default[\n\t ]*\\)")
"case-:"
":"))
diff --git a/test/indentation-tests.el b/test/indentation-tests.el
index 8defb9a..30ec607 100644
--- a/test/indentation-tests.el
+++ b/test/indentation-tests.el
@@ -72,7 +72,14 @@ values of customisable variables."
(indent-according-to-mode)
(should (equal expected-state (buffer-string)))
- (should (equal expected-cursor-pos (point))))))))
+ (should (equal expected-cursor-pos (point)))
+
+ (goto-char (point-min))
+ (forward-sexp 10)
+ (should (equal (point-max) (point)))
+ (forward-sexp -10)
+ (should (equal (point-min) (point)))
+ )))))
;; Provide font locking for easier test editing.
@@ -1181,10 +1188,10 @@ let foo = [
(check-indentation indents-declaration/12
"
let foo = [
-|[
+|[]]
" "
let foo = [
- |[
+ |[]]
")
(check-indentation indents-declaration/13
@@ -1381,10 +1388,10 @@ func a () {
(check-indentation indents-multiline-expressions/13
"
if (a
-|.b)
+|.b){}
" "
if (a
- |.b)
+ |.b){}
")
(check-indentation indents-multiline-expressions/14
@@ -2048,12 +2055,12 @@ foo.bar(10,
foo.bar(10,
completionHandler: { (bar, baz) -> Void in
|foo
- }
+ })
" "
foo.bar(10,
completionHandler: { (bar, baz) -> Void in
|foo
- }
+ })
")
(check-indentation anonymous-function-as-a-argument/9
- [nongnu] elpa/swift-mode 5a858c7 218/496: Improve indentation of the array and dictionary expressions, (continued)
- [nongnu] elpa/swift-mode 5a858c7 218/496: Improve indentation of the array and dictionary expressions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 195d040 227/496: Merge pull request #76 from ap4y/batch_smie_fixes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode dbf48a1 232/496: Merge pull request #90 from nathankot/flycheck-framework-search-paths, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode e6f1a3c 237/496: More configurability for flycheck, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 3e8befa 238/496: Merge pull request #92 from apiology/more_flycheck_option_vars, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 31fb250 248/496: added elseguard to lexer, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 071cd18 249/496: Merge pull request #100 from uk-ar/enable-pairing-for-curly-bracket, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 7cefd8c 255/496: Fix token for generics, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c51eaf8 257/496: Fix token for ! & ?, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode ce816a8 270/496: Fix backward-sexp test by adding brackets, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 85e05ea 271/496: Merge pull request #105 from uk-ar/fix-move-by-sexp,
ELPA Syncer <=
- [nongnu] elpa/swift-mode befeb2a 017/496: Highlight bools and nil as constants, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 654d5e2 006/496: More work on font locking, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c4943a8 025/496: Add to auto-mode-alist, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 0ad90f8 035/496: Fix a typo, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 19a61d9 022/496: fixup! Copy syntax table from rust-mode., ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 406f2ba 028/496: Mention Emacs version in readme, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 2ca1425 026/496: Remove ackrc and travis yaml for now, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode ec9243c 032/496: Tweaks to indentation, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 1b3ebe8 046/496: Remove obsolete require, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 90cdeb5 057/496: Configure travis, ELPA Syncer, 2021/08/29