[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode 359efc0 379/496: Fix indentation of function pa
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode 359efc0 379/496: Fix indentation of function parameter clauses |
Date: |
Sun, 29 Aug 2021 11:34:11 -0400 (EDT) |
branch: elpa/swift-mode
commit 359efc05cceecac363f4b0d34d0c06de803cf3ee
Author: taku0 <mxxouy6x3m_github@tatapa.org>
Commit: taku0 <mxxouy6x3m_github@tatapa.org>
Fix indentation of function parameter clauses
---
swift-mode-lexer.el | 32 ++++++++++++++++++++++++++++--
test/swift-files/indent/declarations.swift | 4 +++-
2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/swift-mode-lexer.el b/swift-mode-lexer.el
index ed9e5fd..f17bdd5 100644
--- a/swift-mode-lexer.el
+++ b/swift-mode-lexer.el
@@ -68,6 +68,11 @@
stop-at-eol-token-types
stop-at-bol-token-types))
+(declare-function swift-mode:try-backward-generic-parameters
+ "swift-mode-indent.el"
+ ())
+
+
(defun swift-mode:token (type text start end)
"Construct and return a token.
@@ -571,7 +576,9 @@ Return nil otherwise."
;; ]
((eq (swift-mode:token:type next-token) '\[) t)
- ;; Inserts implicit semicolon before open parenthesis.
+ ;; Inserts implicit semicolon before open parenthesis, unless it is a
+ ;; function parameter clause. Suppress implicit semicolon before function
+ ;; parameter clause.
;;
;; Open parenthesis for function arguments cannot appear at the start of a
;; line.
@@ -584,7 +591,8 @@ Return nil otherwise."
;; (
;; 1
;; )
- ((eq (swift-mode:token:type next-token) '\() t)
+ ((eq (swift-mode:token:type next-token) '\()
+ (not (swift-mode:function-parameter-clause-p)))
;; Suppress implicit semicolon after the beginning of an interpolated
;; expression.
@@ -595,6 +603,26 @@ Return nil otherwise."
;; Otherwise, inserts implicit semicolon.
(t t))))
+(defun swift-mode:function-parameter-clause-p ()
+ "Return t if the cursor is before a function parameter clause.
+
+Return nil otherwise."
+ (save-excursion
+ (let* ((previous-token (swift-mode:backward-token-simple))
+ (previous-type (swift-mode:token:type previous-token)))
+ (cond
+ ((eq previous-type '>)
+ (and
+ (/= (point)
+ ;; FIXME: mutual dependency
+ (progn (swift-mode:try-backward-generic-parameters) (point)))
+ (swift-mode:function-parameter-clause-p)))
+ ((or (eq previous-type 'operator)
+ (eq previous-type 'identifier))
+ (equal (swift-mode:token:text (swift-mode:backward-token-simple))
+ "func"))
+ (t nil)))))
+
(defun swift-mode:supertype-colon-p ()
"Return t if a colon at the cursor is the colon for supertype.
diff --git a/test/swift-files/indent/declarations.swift
b/test/swift-files/indent/declarations.swift
index c0a776c..dab5296 100644
--- a/test/swift-files/indent/declarations.swift
+++ b/test/swift-files/indent/declarations.swift
@@ -223,7 +223,9 @@ class Foo {
private
final
func
- foo<A, B>(
+ foo<A,
+ B>
+ (
x:
Int,
y:
- [nongnu] elpa/swift-mode f03db1a 331/496: Fix indentation of switch., (continued)
- [nongnu] elpa/swift-mode f03db1a 331/496: Fix indentation of switch., ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode a489024 344/496: indent-new-comment-line: Inherit slashes from the previous line, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 75cbae2 345/496: Bump version to 2.2.3, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 42669da 343/496: Fix indentation for keywords used as parameter names, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 0cab4b2 346/496: Fix indentation for catch blocks without patterns, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 92f8eba 349/496: Update README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 2cd111f 351/496: Fix indentation of multiline strings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 3bcdf32 353/496: Add more keywords with number sign, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 030b1b8 356/496: Update documentations and wordings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode d68af3c 365/496: Update copyright, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 359efc0 379/496: Fix indentation of function parameter clauses,
ELPA Syncer <=
- [nongnu] elpa/swift-mode 25944c2 378/496: Add test for beginning/end-of-defun, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode ea029a0 370/496: Suppress implicit semicolons inside interpolated expressions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode b5602c1 375/496: Add beginning/end-of-sentence to README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 18c3dc4 376/496: Bump version to 4.0.0, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 27e959e 385/496: Handle unmatched parens correctly, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode abf3426 392/496: Add support for highlighting function calls / properties / enum cases, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 560242d 393/496: Add support for choosing scheme when building/running iOS projects, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c56f43c 395/496: Make faces customizable, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 6d4fab5 396/496: Move customizations for REPL to their own group, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 604610d 399/496: Fix LLDB breakpoint option, ELPA Syncer, 2021/08/29