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

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

[nongnu] elpa/swift-mode e3cb72b 360/496: Fix `swift-mode:forward-sexp`


From: ELPA Syncer
Subject: [nongnu] elpa/swift-mode e3cb72b 360/496: Fix `swift-mode:forward-sexp` for `up-list` and `down-list`
Date: Sun, 29 Aug 2021 11:34:07 -0400 (EDT)

branch: elpa/swift-mode
commit e3cb72b0ebdd4cf7e08b8188b692fbec17c8e90b
Author: taku0 <mxxouy6x3m_github@tatapa.org>
Commit: taku0 <mxxouy6x3m_github@tatapa.org>

    Fix `swift-mode:forward-sexp` for `up-list` and `down-list`
---
 swift-mode.el | 39 +++++++++++++++++++++++++++++++++------
 1 file changed, 33 insertions(+), 6 deletions(-)

diff --git a/swift-mode.el b/swift-mode.el
index 224e3d4..3ba9ff3 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -84,16 +84,43 @@ See `forward-sexp for ARG."
   (setq arg (or arg 1))
   (if (< 0 arg)
       (while (< 0 arg)
-        (while (eq
-                (swift-mode:token:type (swift-mode:forward-token-or-list))
-                'implicit-\;))
+        (while (eq (swift-mode:token:type (swift-mode:forward-sexp-1))
+                   'implicit-\;))
         (setq arg (1- arg))))
   (while (< arg 0)
-    (while (eq
-            (swift-mode:token:type (swift-mode:backward-token-or-list))
-            'implicit-\;))
+    (while (eq (swift-mode:token:type (swift-mode:backward-sexp-1))
+               'implicit-\;))
     (setq arg (1+ arg))))
 
+(defun swift-mode:forward-sexp-1 ()
+  "Move forward a token or list.
+
+Signal `scan-error' if it hits closing parentheses."
+  (let ((token (swift-mode:forward-token-or-list))
+        (pos (point)))
+    (when (memq (swift-mode:token:type token) '(\] \) }))
+      (goto-char pos)
+      (signal 'scan-error
+              (list "Unbalanced parentheses"
+                    (swift-mode:token:start token)
+                    (swift-mode:token:end token))))
+    token))
+
+(defun swift-mode:backward-sexp-1 ()
+  "Move backward a token or list.
+
+Signal `scan-error' if it hits opening parentheses."
+  (let ((token (swift-mode:backward-token-or-list))
+        (pos (point)))
+    (when (memq (swift-mode:token:type token) '(\[ \( {))
+      (goto-char pos)
+      (signal 'scan-error
+              (list "Unbalanced parentheses"
+                    (swift-mode:token:start token)
+                    (swift-mode:token:end token))))
+    token))
+
+
 ;; Imenu
 
 (defun swift-mode:mk-regex-for-def (keyword)



reply via email to

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