[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode 58f31cc 340/496: Speed-up indentation for colon
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode 58f31cc 340/496: Speed-up indentation for colon |
Date: |
Sun, 29 Aug 2021 11:34:03 -0400 (EDT) |
branch: elpa/swift-mode
commit 58f31cc50ee8fac236f5aa3936152e6e70ee3ce5
Author: taku0 <mxxouy6x3m_github@tatapa.org>
Commit: taku0 <mxxouy6x3m_github@tatapa.org>
Speed-up indentation for colon
---
swift-mode-lexer.el | 51 +++++++++++++++++++++++++++++++--------------------
1 file changed, 31 insertions(+), 20 deletions(-)
diff --git a/swift-mode-lexer.el b/swift-mode-lexer.el
index 4bdec5e..b00bbcc 100644
--- a/swift-mode-lexer.el
+++ b/swift-mode-lexer.el
@@ -437,27 +437,38 @@ That is supertype declaration or type declaration of let
or var."
'("class" "extension" "enum" "struct" "protocol" "typealias"
"associatedtype"))))))
-(defun swift-mode:case-colon-p ()
- "Return t if a colon at the cursor is the colon for case or default label."
- (save-excursion
- (member
- ;; This function can be confused by conditional operator.
- ;;
- ;;
- ;; switch foo {
- ;; case let x where x is Foo ?
- ;; a : // This function should return nil but it
- ;; // actually retuns t.
- ;; b: // This function should return t but it
- ;; // actually return nil.
- ;; let y = a ? b : c // This function returns nil correctly for this.
- ;; }
+(defvar swift-mode:in-recursive-call-of-case-colon-p nil
+ "Non-nil if `case-colon-p' is being evaluated.")
- ;; FIXME: mutual dependency
- (swift-mode:token:text
- (swift-mode:backward-sexps-until
- '(implicit-\; \; { \( \[ "case" "default" ":")))
- '("case" "default"))))
+(defun swift-mode:case-colon-p ()
+ "Return non-nil if the colon at the cursor follows case or default label.
+
+Return nil otherwise."
+ (if swift-mode:in-recursive-call-of-case-colon-p
+ nil
+ (save-excursion
+ (setq swift-mode:in-recursive-call-of-case-colon-p t)
+
+ (unwind-protect
+ (member
+ ;; FIXME:
+ ;; This function can be confused by conditional operator.
+ ;;
+ ;; switch foo {
+ ;; case let x where x is Foo ?
+ ;; a : // This function should return nil but it
+ ;; // actually retuns t.
+ ;; b: // This function should return t but it
+ ;; // actually return nil.
+ ;; let y = a ? b : c // This function returns nil correctly for
this.
+ ;; }
+
+ ;; FIXME: mutual dependency
+ (swift-mode:token:text
+ (swift-mode:backward-sexps-until
+ '(implicit-\; \; { \( \[ "case" "default" ":")))
+ '("case" "default"))
+ (setq swift-mode:in-recursive-call-of-case-colon-p nil)))))
(defun swift-mode:anonyous-parameter-in-p ()
"Return t if a 'in' token at the cursor is for anonymous function
parameters."
- [nongnu] elpa/swift-mode e9648b1 296/496: Use .el for file extension in distributed package., (continued)
- [nongnu] elpa/swift-mode e9648b1 296/496: Use .el for file extension in distributed package., ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 1563e8b 300/496: Bump the development version to 0.5.0-snapshot, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode a5e1acf 297/496: Merge pull request #122 from N4tr0n/make-install-fix-issue120, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode cfaeaff 294/496: Update MELPA URL, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 9471669 304/496: Merge taku0/swift3-mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 848d088 310/496: Fix indentation after attributes with arguments, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode cad72a1 306/496: Fix a link in README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 0a75736 317/496: Fix indentation, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c1f7ec2 321/496: Fix indentation of switch-case body, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 7423f68 324/496: Simplify code, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 58f31cc 340/496: Speed-up indentation for colon,
ELPA Syncer <=
- [nongnu] elpa/swift-mode 0b1f29d 334/496: Fix indentation of setter, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 812d202 341/496: Fix REPL prompt corruption, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode f755479 333/496: Fix anchor highlighting, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 56ee9b2 359/496: Add comment style option, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode dba539e 394/496: Tweak and clean-up font-lock, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode dca378a 400/496: Rename constants, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c532c1e 402/496: Update documents, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode d35275b 417/496: Remove unused variables, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 8a7be9c 424/496: Use remap for keymap, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 56e21f8 427/496: Simplify autoloads, ELPA Syncer, 2021/08/29