[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode 592a33f 021/496: Copy syntax table from rust-mo
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode 592a33f 021/496: Copy syntax table from rust-mode. |
Date: |
Sun, 29 Aug 2021 11:33:00 -0400 (EDT) |
branch: elpa/swift-mode
commit 592a33f1a4a71b89f2e5a230ad410c719b39c83a
Author: Chris Barrett <chris.d.barrett@me.com>
Commit: Chris Barrett <chris.d.barrett@me.com>
Copy syntax table from rust-mode.
This fixes font-locking of C and C++ style comments.
Resolves #1
---
swift-mode.el | 53 +++++++++++++++++++++++++----------------------------
1 file changed, 25 insertions(+), 28 deletions(-)
diff --git a/swift-mode.el b/swift-mode.el
index 2177a79..2759dc8 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -30,6 +30,8 @@
(require 'dash)
(require 'rx)
+(require 'swift-indentation)
+
;; Font lock.
(defvar swift-mode--type-decl-keywords
@@ -131,35 +133,29 @@
;; Mode definition.
-;; FIXME: Syntax table cobbled together from entries in tuareg-mode and
-;; fsharp-mode. Not really tested.
+;; HACK: This syntax table is lifted directly from `rust-mode'. There may be
+;; corner cases in the Swift syntax that are not accounted for.
(defvar swift-mode-syntax-table
- (let ((st (make-syntax-table)))
- (modify-syntax-entry ?_ "_" st)
- (modify-syntax-entry ?. "'" st) ; Make qualified names a single symbol.
- (modify-syntax-entry ?? ". p" st)
- (modify-syntax-entry ?& ". p" st)
- (modify-syntax-entry ?! ". p" st)
-
- ;; C++-style comments (//)
- (modify-syntax-entry ?/ ". 12b" st)
- (modify-syntax-entry ?\n "> b" st)
- ;; C-style comments (/* */)
- (modify-syntax-entry ?/ "()1n" st)
- (modify-syntax-entry ?* ". 23n" st)
- (modify-syntax-entry ?/ ")(4n" st)
-
- (dolist (c '(?$ ?% ?+ ?- ?/ ?: ?< ?= ?> ?@ ?^ ?|))
- (modify-syntax-entry c "." st))
-
- (modify-syntax-entry ?' "_" st) ; ' is part of symbols (for primes).
- (modify-syntax-entry ?\" "\"" st) ; " is a string delimiter
- (modify-syntax-entry ?\\ "\\" st)
- (modify-syntax-entry ?* ". 23" st)
- (modify-syntax-entry ?\( "()1n" st)
- (modify-syntax-entry ?\) ")(4n" st)
- st)
- "Syntax table for `swift-mode'.")
+ (let ((table (make-syntax-table)))
+
+ ;; Operators
+ (dolist (i '(?+ ?- ?* ?/ ?& ?| ?^ ?! ?< ?> ?~ ?@))
+ (modify-syntax-entry i "." table))
+
+ ;; Strings
+ (modify-syntax-entry ?\" "\"" table)
+ (modify-syntax-entry ?\\ "\\" table)
+
+ ;; _ is a word-char
+ (modify-syntax-entry ?_ "w" table)
+
+ ;; Comments
+ (modify-syntax-entry ?/ ". 124b" table)
+ (modify-syntax-entry ?* ". 23" table)
+ (modify-syntax-entry ?\n "> b" table)
+ (modify-syntax-entry ?\^m "> b" table)
+
+ table))
;;;###autoload
(define-derived-mode swift-mode prog-mode "Swift"
@@ -167,6 +163,7 @@
\\<swift-mode-map>"
:group 'swift
+ :syntax-table swift-mode-syntax-table
(setq-local font-lock-defaults swift-mode--font-lock-defaults)
(setq-local comment-start "// ")
(setq-local comment-end "")
- [nongnu] branch elpa/swift-mode created (now 800efe2), ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 00001ea 009/496: Fix keywords list, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode e90cf5e 012/496: Set comment vars, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode f39c05b 013/496: Tweak comment syntax, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 592a33f 021/496: Copy syntax table from rust-mode.,
ELPA Syncer <=
- [nongnu] elpa/swift-mode 142c7db 023/496: Merge pull request #7 from syohex/fix-for-older-emacs, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 90802b5 041/496: Use lexical scoping, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 8641ebc 048/496: Mention old-school installation method, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 8e72839 004/496: Add basic syntax table, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 5274877 010/496: Add single-line comments to syntax table, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode d110515 011/496: Font lock tweaks, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 272473b 005/496: Remove currently unused mode map, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode cbb19f2 003/496: Add basic font-locking, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 7df8b6d 037/496: Remove dash.el dependency., ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 09b50fa 042/496: [Fix #12] Merge mode code in a single file, ELPA Syncer, 2021/08/29