[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode f9f4bc5 311/496: Fix `beginning/end-of-defun`
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode f9f4bc5 311/496: Fix `beginning/end-of-defun` |
Date: |
Sun, 29 Aug 2021 11:33:57 -0400 (EDT) |
branch: elpa/swift-mode
commit f9f4bc58c01889e43e16a7d2306fed3e71660322
Author: taku0 <mxxouy6x3m_github@tatapa.org>
Commit: taku0 <mxxouy6x3m_github@tatapa.org>
Fix `beginning/end-of-defun`
---
swift-mode-beginning-of-defun.el | 63 +++++++++++++++++++++++++++++++---------
1 file changed, 50 insertions(+), 13 deletions(-)
diff --git a/swift-mode-beginning-of-defun.el b/swift-mode-beginning-of-defun.el
index c884361..438ede9 100644
--- a/swift-mode-beginning-of-defun.el
+++ b/swift-mode-beginning-of-defun.el
@@ -39,20 +39,46 @@
(let (result
pos)
(if (<= 0 arg)
- (while (< 0 arg)
- (setq result (swift-mode:beginning-of-defun-1
- #'swift-mode:backward-token-or-list))
- (setq arg (1- arg)))
+ (progn
+ (setq pos (point))
+ ;; Special handling for the case that the cursor is between the
+ ;; beginning of the defun and the open curly brace of the defun.
+ (when (< (save-excursion
+ (swift-mode:beginning-of-statement)
+ (point))
+ (point))
+ ;; Searches forward { or end of a statement.
+ (while (not
+ (memq
+ (swift-mode:token:type (swift-mode:forward-token-or-list))
+ '({} implicit-\; \; } outside-of-buffer))))
+ (when (eq (char-before) ?})
+ (backward-list))
+ ;; Skips implicit ;
+ (forward-comment (point-max))
+ (if (swift-mode:is-point-before-body-of-defun)
+ (progn
+ (swift-mode:beginning-of-statement)
+ (setq result t)
+ (setq arg (1- arg)))
+ (goto-char pos)))
+ (while (< 0 arg)
+ (setq result (swift-mode:beginning-of-defun-1
+ #'swift-mode:backward-token-or-list))
+ (setq arg (1- arg))))
(while (< arg 0)
+ ;; If the cursor is on a defun, ensure the cursor is after the open
+ ;; curly brace of defun.
(setq pos (point))
-
(swift-mode:beginning-of-statement)
-
+ ;; swift-mode:beginning-of-statement may forward the cursor if the
+ ;; cursor is on a comment or whitespace. In that case, does not skip
+ ;; the defun.
(when (<= (point) pos)
(while (not
(memq
(swift-mode:token:type (swift-mode:forward-token-or-list))
- '({} outside-of-buffer)))))
+ '({} } outside-of-buffer)))))
(setq result (swift-mode:beginning-of-defun-1
(lambda ()
@@ -109,12 +135,23 @@
Intended for internal use."
(let ((parent (swift-mode:backward-sexps-until
swift-mode:statement-parent-tokens)))
- (forward-comment (point-max))
- (swift-mode:goto-non-comment-bol)
- (when (< (point) (swift-mode:token:end parent))
- (goto-char (swift-mode:token:end parent)))
- (swift-mode:skip-whitespaces)))
-
+ (if (and
+ (eq (swift-mode:token:type parent) 'implicit-\;)
+ (save-excursion
+ (goto-char (swift-mode:token:end parent))
+ (eq
+ (swift-mode:token:type (swift-mode:forward-token))
+ '{)))
+ (progn
+ (forward-comment (- (point)))
+ (swift-mode:beginning-of-statement))
+ (goto-char (swift-mode:token:end parent))
+ (setq parent (save-excursion (swift-mode:backward-token)))
+ (forward-comment (point-max))
+ (swift-mode:goto-non-comment-bol)
+ (when (< (point) (swift-mode:token:end parent))
+ (goto-char (swift-mode:token:end parent)))
+ (swift-mode:skip-whitespaces))))
(defun swift-mode:end-of-defun (&optional arg)
"Move forward to the end of a defun."
- [nongnu] elpa/swift-mode 3aa3dcd 254/496: Add test code for checking tokens, (continued)
- [nongnu] elpa/swift-mode 3aa3dcd 254/496: Add test code for checking tokens, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode b97b570 260/496: Fix indent rule for '(' and pass all test, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 00393f7 262/496: Merge pull request #103 from uk-ar/fix-lexer, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode ed1ed46 264/496: Add test for forward-sexp, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode a3377bf 266/496: Fix forward-sexp test by adding brackets, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 228b50c 267/496: Fix case-: for multiline case-exps, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 3931734 283/496: fix multi-line expressions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode e5b569e 284/496: Add keyword for attribute, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode d614017 298/496: Update copyright years, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 174bccc 309/496: Tweak .travis.yml, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode f9f4bc5 311/496: Fix `beginning/end-of-defun`,
ELPA Syncer <=
- [nongnu] elpa/swift-mode c659c45 329/496: Highlight anchor point for debugging., ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode b6512fa 325/496: Fix indentation of attributes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 1d43501 330/496: Fix indentation of attributes at begging of the buffer., ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 193de68 327/496: Fix end-of-defun at eob, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode a07be7a 335/496: Fix `swift-mode:beginning-of-defun`, ELPA Syncer, 2021/08/29
- [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