Skip to content

Commit 636a326

Browse files
authored
Merge pull request #71689 from lorentey/update-emacs-mode
[utils] Update the in-tree Emacs swift mode to teach it about new keywords
2 parents 3c8073e + 0d2d346 commit 636a326

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

utils/swift-mode.el

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
;
33
; This source file is part of the Swift.org open source project
44
;
5-
; Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
; Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors
66
; Licensed under Apache License v2.0 with Runtime Library Exception
77
;
88
; See https://swift.org/LICENSE.txt for license information
@@ -48,35 +48,43 @@
4848
;; Integer literals
4949
'("\\b[-]?[0-9]+\\b" . font-lock-preprocessor-face)
5050
;; Decl and type keywords
51-
`(,(regexp-opt '("class" "init" "deinit" "extension" "fileprivate" "func"
52-
"import" "let" "protocol" "static" "struct" "subscript"
53-
"typealias" "enum" "var" "lazy" "where" "private" "public"
54-
"internal" "override" "open" "associatedtype" "inout"
55-
"indirect" "final")
51+
`(,(regexp-opt '("import"
52+
"class" "struct" "enum" "extension" "protocol" "typealias" "var" "let" "actor"
53+
"func" "init" "deinit" "subscript" "associatedtype"
54+
"public" "internal" "private" "fileprivate" "package"
55+
"static"
56+
"where")
5657
'words) . font-lock-keyword-face)
5758
;; Variable decl keywords
58-
`("\\b\\(?:[^a-zA-Z_0-9]*\\)\\(get\\|set\\)\\(?:[^a-zA-Z_0-9]*\\)\\b" 1 font-lock-keyword-face)
59+
`("\\b\\(?:[^a-zA-Z_0-9]*\\)\\(get\\|set\\|_read\\|_modify\\|unsafe\\(Mutable\\)?Address\\)\\(?:[^a-zA-Z_0-9]*\\)\\b" 1 font-lock-keyword-face)
5960
`(,(regexp-opt '("willSet" "didSet") 'words) . font-lock-keyword-face)
6061
;; Operators
6162
`("\\b\\(?:\\(?:pre\\|post\\|in\\)fix\\s-+\\)operator\\b" . font-lock-keyword-face)
6263
;; Keywords that begin with a number sign
6364
`("#\\(if\\|endif\\|elseif\\|else\\|available\\|error\\|warning\\)\\b" . font-lock-string-face)
6465
`("#\\(file\\|line\\|column\\|function\\|selector\\)\\b" . font-lock-keyword-face)
6566
;; Infix operator attributes
66-
`(,(regexp-opt '("precedence" "associativity" "left" "right" "none")
67+
`(,(regexp-opt '("precedence" "associativity" "left" "right" "none" "precedencegroup")
6768
'words) . font-lock-keyword-face)
6869
;; Statements
6970
`(,(regexp-opt '("if" "guard" "in" "else" "for" "do" "repeat" "while"
7071
"return" "break" "continue" "fallthrough" "switch" "case"
71-
"default" "defer" "catch")
72+
"default" "defer" "catch" "yield")
7273
'words) . font-lock-keyword-face)
7374
;; Decl modifier keywords
74-
`(,(regexp-opt '("convenience" "dynamic" "mutating" "nonmutating" "optional"
75-
"required" "weak" "unowned" "safe" "unsafe")
75+
`(,(regexp-opt '("mutating" "nonmutating" "__consuming" "consuming" "borrowing" "inout"
76+
"convenience" "dynamic" "optional"
77+
"indirect" "override" "open" "final"
78+
"required" "lazy" "weak"
79+
"_compilerInitialized" "_const" "_local" "_resultDependsOnSelf"
80+
"nonisolated" "distributed")
7681
'words) . font-lock-keyword-face)
82+
`("\\<unowned\\((\\(un\\)?safe)\\)?\\>" . font-lock-keyword-face)
7783
;; Expression keywords: "Any" and "Self" are included in "Types" above
7884
`(,(regexp-opt '("as" "false" "is" "nil" "rethrows" "super" "self" "throw"
79-
"true" "try" "throws")
85+
"true" "try" "throws" "async" "await"
86+
"consume" "copy" "_move" "_borrow" "discard"
87+
"any" "some" "repeat" "each")
8088
'words) . font-lock-keyword-face)
8189
;; Expressions
8290
`(,(regexp-opt '("new") 'words) . font-lock-keyword-face)

0 commit comments

Comments
 (0)