[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode b4b56f6 246/496: Merge pull request #99 from uk
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode b4b56f6 246/496: Merge pull request #99 from uk-ar/fix-indents-around-comma |
Date: |
Sun, 29 Aug 2021 11:33:44 -0400 (EDT) |
branch: elpa/swift-mode
commit b4b56f6d78117314c544d0629fbc557d06efad94
Merge: 17bf117 cb7ba6f
Author: Arthur Evstifeev <mail@ap4y.me>
Commit: Arthur Evstifeev <mail@ap4y.me>
Merge pull request #99 from uk-ar/fix-indents-around-comma
Modify indents around comma to meet Xcode spec
---
swift-mode.el | 31 ++++++++++++++++++++++++-------
test/indentation-tests.el | 8 +++++---
2 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/swift-mode.el b/swift-mode.el
index 9597644..19dd18a 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -61,6 +61,12 @@
:type 'integer
:package-version '(swift-mode "0.3.0"))
+(defcustom swift-indent-hanging-comma-offset 4
+ "Defines the indentation offset for hanging comma."
+ :group 'swift
+ :type 'integer
+ :package-version '(swift-mode "0.4.0"))
+
(defcustom swift-repl-executable
"xcrun swift"
"Path to the Swift CLI."
@@ -153,9 +159,11 @@
(enum-cases (enum-case) (enum-case ";" enum-case))
(enum-body (enum-cases) (insts))
- (case-exps (exp) (guard-exp))
- (case (case-exps ":" insts))
- (switch-body (case) (case "case" case))
+ (case-exps (exp)
+ (guard-exp)
+ (case-exps "," case-exps))
+ (case ("case" case-exps "case-:" insts))
+ (switch-body (case))
(for-head (in-exp) (op-exp) (for-head ";" for-head))
@@ -247,7 +255,10 @@
((looking-at "}") (forward-char 1) "}")
((looking-at ",") (forward-char 1) ",")
- ((looking-at ":") (forward-char 1) ":")
+ ((looking-at ":") (forward-char 1)
+ (if (looking-back "case [^:]+:")
+ "case-:"
+ ":"))
((looking-at "->") (forward-char 2) "->")
@@ -292,7 +303,10 @@
((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 [^:]+")
+ "case-:"
+ ":"))
((looking-back "->" (- (point) 2) t)
(goto-char (match-beginning 0)) "->")
@@ -369,9 +383,12 @@
;; Indent second line of the multi-line class
;; definitions with swift-indent-offset
+ (`(:before . "case")
+ (smie-rule-parent))
+
(`(:before . ",")
- (if (smie-rule-parent-p "class")
- (smie-rule-parent swift-indent-offset)))
+ (if (smie-rule-parent-p "class" "case")
+ (smie-rule-parent swift-indent-hanging-comma-offset)))
;; Disable unnecessary default indentation for
;; "func" and "class" keywords
diff --git a/test/indentation-tests.el b/test/indentation-tests.el
index 256f3d7..3153cf1 100644
--- a/test/indentation-tests.el
+++ b/test/indentation-tests.el
@@ -59,6 +59,8 @@ values of customisable variables."
(swift-indent-offset 4)
(swift-indent-switch-case-offset 0)
(swift-indent-multiline-statement-offset 2)
+ ;; Change from default value to detect offset bug.
+ (swift-indent-hanging-comma-offset 3)
,@var-bindings)
(with-temp-buffer
(insert ,before)
@@ -486,7 +488,7 @@ case foo where bar,
" "
switch true {
case foo where bar,
- |bar where baz:
+ |bar where baz:
}
")
@@ -685,7 +687,7 @@ class Foo: Foo, Bar,
}
" "
class Foo: Foo, Bar,
- |Baz {
+ |Baz {
}
")
@@ -725,7 +727,7 @@ public class Foo: Foo, Bar,
}
" "
public class Foo: Foo, Bar,
- |Baz {
+ |Baz {
}
")
- [nongnu] elpa/swift-mode 9b6f599 146/496: Apply swift-indent-offset to multi-line class definitions, (continued)
- [nongnu] elpa/swift-mode 9b6f599 146/496: Apply swift-indent-offset to multi-line class definitions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 4286ff9 148/496: Merge pull request #52 from ap4y/fix_47, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 0f57a7d 179/496: Add lexer rule for ":" token., ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 2d0194e 184/496: Correct several indentation cases for class defitinion, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode f8190d6 186/496: Extract function into separate grammar and add return typo to the, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode fb2f48e 187/496: Add rule for assignment expression, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 01bcc35 192/496: Improve grammar for functions and contraint protocols grammar to, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c09229a 198/496: Use semantic hanging-p function instead of custom regex when checking, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 462ea17e 221/496: Improve closures grammar and add several related indentation rules, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode f42752b 223/496: Respect comments when calculating position of the implicit semicolon, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode b4b56f6 246/496: Merge pull request #99 from uk-ar/fix-indents-around-comma,
ELPA Syncer <=
- [nongnu] elpa/swift-mode d047843 258/496: Fix token for :, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode ba39552 261/496: Fix test failure on travis, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 1f39b11 288/496: Fix indent for ternary operator, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 4d90ca5 280/496: Merge pull request #110 from lunaryorn/patch-1, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 0cb5e13 303/496: Improve some wording, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode b6f3664 302/496: Update a few URLs, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 9c180cf 315/496: Fix testing error when running the test twice interactively, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 2955e8f 314/496: Simplify indentation for commas, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 8e69064 034/496: Mention package.el as an installation option, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode cfb3a6f 045/496: Setup some basic code style conventions, ELPA Syncer, 2021/08/29