branch: elpa/swift-mode commit 07780b434c37096bed6590bf3ec99553b8c74eb0 Merge: ca6437a 41d38bd Author: Bozhidar Batsov <bozhi...@batsov.com> Commit: Bozhidar Batsov <bozhi...@batsov.com>
Merge pull request #30 from ap4y/syntactic_fontification Clarify syntax table for syntactic fontification. --- swift-mode.el | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/swift-mode.el b/swift-mode.el index 4447b58..4f9b4b5 100644 --- a/swift-mode.el +++ b/swift-mode.el @@ -546,27 +546,33 @@ You can send text to the REPL process from other buffers containing source. ;;; Mode definition -;; 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 ((table (make-syntax-table))) ;; Operators - (dolist (i '(?+ ?- ?* ?/ ?& ?| ?^ ?! ?< ?> ?~ ?@)) + (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) + ;; Additional symbols + (modify-syntax-entry ?_ "-" table) + (modify-syntax-entry ?: "_" table) ;; Comments (modify-syntax-entry ?/ ". 124b" table) (modify-syntax-entry ?* ". 23" table) (modify-syntax-entry ?\n "> b" table) - (modify-syntax-entry ?\^m "> b" table) + + ;; Parenthesis, braces and brackets + (modify-syntax-entry ?\( "()" table) + (modify-syntax-entry ?\) ")(" table) + (modify-syntax-entry ?\{ "(}" table) + (modify-syntax-entry ?\} "){" table) + (modify-syntax-entry ?\[ "(]" table) + (modify-syntax-entry ?\] ")[" table) table))