emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/swift-mode 62276c3 061/496: Indent cases in enums


From: ELPA Syncer
Subject: [nongnu] elpa/swift-mode 62276c3 061/496: Indent cases in enums
Date: Sun, 29 Aug 2021 11:33:08 -0400 (EDT)

branch: elpa/swift-mode
commit 62276c39e5cf50286ded6736c8cc19e5fbaa7fff
Author: Chris Barrett <chris.d.barrett@me.com>
Commit: Chris Barrett <chris.d.barrett@me.com>

    Indent cases in enums
    
    Fixes #15
---
 swift-mode.el | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/swift-mode.el b/swift-mode.el
index c879eb7..6b39a9d 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -91,6 +91,15 @@
         (backward-word 1))
       (current-column))))
 
+(defun swift-indent--at-enum-case? ()
+  "Non-nil if point is at the case keyword at the top-level of an enum 
declaration."
+  (save-excursion
+    (back-to-indentation)
+    (when (looking-at (rx bow "case" eow))
+      (backward-up-list)
+      (swift-indent--back-to-start-of-level)
+      (looking-at (rx bow "enum" eow)))))
+
 (defun swift-indent--calculate-indentation ()
   "Calculate the indentation column to use for `swift-indent-line'.
 Returns the column number as an integer."
@@ -142,6 +151,8 @@ Returns the column number as an integer."
            (back-to-indentation)
            ;; Point is now at the beginning of the current line
            (cond
+            ((swift-indent--at-enum-case?)
+             baseline)
             ;; Cases are indented to the same level as the enclosing switch 
statement.
             ((looking-at (rx bow (or "case" "default") eow))
              (- baseline swift-indent-offset))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]