Skip to content

Commit bbb3792

Browse files
tarsiusbrotzeit
authored andcommitted
Remove "-face" suffix from names of faces
As mentioned in (info "(emacs)Defining Faces") the name of a face > should not end in "-face" (that would be redundant). For historic reasons a few built-in faces actually do end with "-face" and it so happens that our faces are closely related to just those `font-lock' faces and that probably inspired our use of the suffix. Even so, we should stop now.
1 parent e9e9e32 commit bbb3792

File tree

2 files changed

+69
-60
lines changed

2 files changed

+69
-60
lines changed

rust-mode-tests.el

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,13 +1638,13 @@ this_is_not_a_string();)"
16381638
"Ensure question mark operator is highlighted."
16391639
(rust-test-font-lock
16401640
"?"
1641-
'("?" rust-question-mark-face))
1641+
'("?" rust-question-mark))
16421642
(rust-test-font-lock
16431643
"foo\(\)?;"
1644-
'("?" rust-question-mark-face))
1644+
'("?" rust-question-mark))
16451645
(rust-test-font-lock
16461646
"foo\(bar\(\)?\);"
1647-
'("?" rust-question-mark-face))
1647+
'("?" rust-question-mark))
16481648
(rust-test-font-lock
16491649
"\"?\""
16501650
'("\"?\"" font-lock-string-face))
@@ -1664,7 +1664,7 @@ this_is_not_a_string();)"
16641664
(rust-test-font-lock
16651665
"foo\(\"?\"\)?;"
16661666
'("\"?\"" font-lock-string-face
1667-
"?" rust-question-mark-face)))
1667+
"?" rust-question-mark)))
16681668

16691669
(ert-deftest rust-test-default-context-sensitive ()
16701670
(rust-test-font-lock
@@ -2250,195 +2250,195 @@ fn main() {
22502250
;; is ignored
22512251
(rust-test-font-lock
22522252
"print!(\"\"); { /* print!(\"\"); */ }"
2253-
'("print!" rust-builtin-formatting-macro-face
2253+
'("print!" rust-builtin-formatting-macro
22542254
"\"\"" font-lock-string-face
22552255
"/* " font-lock-comment-delimiter-face
22562256
"print!(\"\"); */" font-lock-comment-face))
22572257
;; with newline directly following delimiter
22582258
(rust-test-font-lock
22592259
"print!(\n\"\"\n); { /* print!(\"\"); */ }"
2260-
'("print!" rust-builtin-formatting-macro-face
2260+
'("print!" rust-builtin-formatting-macro
22612261
"\"\"" font-lock-string-face
22622262
"/* " font-lock-comment-delimiter-face
22632263
"print!(\"\"); */" font-lock-comment-face))
22642264
;; with empty println!()
22652265
(rust-test-font-lock
22662266
"println!(); { /* println!(); */ }"
2267-
'("println!" rust-builtin-formatting-macro-face
2267+
'("println!" rust-builtin-formatting-macro
22682268
"/* " font-lock-comment-delimiter-face
22692269
"println!(); */" font-lock-comment-face))
22702270
;; other delimiters
22712271
(rust-test-font-lock
22722272
"print!{\"\"}; { /* no-op */ }"
2273-
'("print!" rust-builtin-formatting-macro-face
2273+
'("print!" rust-builtin-formatting-macro
22742274
"\"\"" font-lock-string-face
22752275
"/* " font-lock-comment-delimiter-face
22762276
"no-op */" font-lock-comment-face))
22772277
;; other delimiters
22782278
(rust-test-font-lock
22792279
"print![\"\"]; { /* no-op */ }"
2280-
'("print!" rust-builtin-formatting-macro-face
2280+
'("print!" rust-builtin-formatting-macro
22812281
"\"\"" font-lock-string-face
22822282
"/* " font-lock-comment-delimiter-face
22832283
"no-op */" font-lock-comment-face))
22842284
;; no interpolation
22852285
(rust-test-font-lock
22862286
"print!(\"abcd\"); { /* no-op */ }"
2287-
'("print!" rust-builtin-formatting-macro-face
2287+
'("print!" rust-builtin-formatting-macro
22882288
"\"abcd\"" font-lock-string-face
22892289
"/* " font-lock-comment-delimiter-face
22902290
"no-op */" font-lock-comment-face))
22912291
;; only interpolation
22922292
(rust-test-font-lock
22932293
"print!(\"{}\"); { /* no-op */ }"
2294-
'("print!" rust-builtin-formatting-macro-face
2294+
'("print!" rust-builtin-formatting-macro
22952295
"\"" font-lock-string-face
2296-
"{}" rust-string-interpolation-face
2296+
"{}" rust-string-interpolation
22972297
"\"" font-lock-string-face
22982298
"/* " font-lock-comment-delimiter-face
22992299
"no-op */" font-lock-comment-face))
23002300
;; text + interpolation
23012301
(rust-test-font-lock
23022302
"print!(\"abcd {}\", foo); { /* no-op */ }"
2303-
'("print!" rust-builtin-formatting-macro-face
2303+
'("print!" rust-builtin-formatting-macro
23042304
"\"abcd " font-lock-string-face
2305-
"{}" rust-string-interpolation-face
2305+
"{}" rust-string-interpolation
23062306
"\"" font-lock-string-face
23072307
"/* " font-lock-comment-delimiter-face
23082308
"no-op */" font-lock-comment-face))
23092309
;; text + interpolation with specification
23102310
(rust-test-font-lock
23112311
"print!(\"abcd {0}\", foo); { /* no-op */ }"
2312-
'("print!" rust-builtin-formatting-macro-face
2312+
'("print!" rust-builtin-formatting-macro
23132313
"\"abcd " font-lock-string-face
2314-
"{0}" rust-string-interpolation-face
2314+
"{0}" rust-string-interpolation
23152315
"\"" font-lock-string-face
23162316
"/* " font-lock-comment-delimiter-face
23172317
"no-op */" font-lock-comment-face))
23182318
;; text + interpolation with specification and escape
23192319
(rust-test-font-lock
23202320
"print!(\"abcd {0}}}\", foo); { /* no-op */ }"
2321-
'("print!" rust-builtin-formatting-macro-face
2321+
'("print!" rust-builtin-formatting-macro
23222322
"\"abcd " font-lock-string-face
2323-
"{0}" rust-string-interpolation-face
2323+
"{0}" rust-string-interpolation
23242324
"}}\"" font-lock-string-face
23252325
"/* " font-lock-comment-delimiter-face
23262326
"no-op */" font-lock-comment-face))
23272327
;; multiple pairs
23282328
(rust-test-font-lock
23292329
"print!(\"abcd {0} efgh {1}\", foo, bar); { /* no-op */ }"
2330-
'("print!" rust-builtin-formatting-macro-face
2330+
'("print!" rust-builtin-formatting-macro
23312331
"\"abcd " font-lock-string-face
2332-
"{0}" rust-string-interpolation-face
2332+
"{0}" rust-string-interpolation
23332333
" efgh " font-lock-string-face
2334-
"{1}" rust-string-interpolation-face
2334+
"{1}" rust-string-interpolation
23352335
"\"" font-lock-string-face
23362336
"/* " font-lock-comment-delimiter-face
23372337
"no-op */" font-lock-comment-face))
23382338
;; println
23392339
(rust-test-font-lock
23402340
"println!(\"abcd {0} efgh {1}\", foo, bar); { /* no-op */ }"
2341-
'("println!" rust-builtin-formatting-macro-face
2341+
'("println!" rust-builtin-formatting-macro
23422342
"\"abcd " font-lock-string-face
2343-
"{0}" rust-string-interpolation-face
2343+
"{0}" rust-string-interpolation
23442344
" efgh " font-lock-string-face
2345-
"{1}" rust-string-interpolation-face
2345+
"{1}" rust-string-interpolation
23462346
"\"" font-lock-string-face
23472347
"/* " font-lock-comment-delimiter-face
23482348
"no-op */" font-lock-comment-face))
23492349
;; eprint
23502350
(rust-test-font-lock
23512351
"eprint!(\"abcd {0} efgh {1}\", foo, bar); { /* no-op */ }"
2352-
'("eprint!" rust-builtin-formatting-macro-face
2352+
'("eprint!" rust-builtin-formatting-macro
23532353
"\"abcd " font-lock-string-face
2354-
"{0}" rust-string-interpolation-face
2354+
"{0}" rust-string-interpolation
23552355
" efgh " font-lock-string-face
2356-
"{1}" rust-string-interpolation-face
2356+
"{1}" rust-string-interpolation
23572357
"\"" font-lock-string-face
23582358
"/* " font-lock-comment-delimiter-face
23592359
"no-op */" font-lock-comment-face))
23602360
;; eprintln
23612361
(rust-test-font-lock
23622362
"eprintln!(\"abcd {0} efgh {1}\", foo, bar); { /* no-op */ }"
2363-
'("eprintln!" rust-builtin-formatting-macro-face
2363+
'("eprintln!" rust-builtin-formatting-macro
23642364
"\"abcd " font-lock-string-face
2365-
"{0}" rust-string-interpolation-face
2365+
"{0}" rust-string-interpolation
23662366
" efgh " font-lock-string-face
2367-
"{1}" rust-string-interpolation-face
2367+
"{1}" rust-string-interpolation
23682368
"\"" font-lock-string-face
23692369
"/* " font-lock-comment-delimiter-face
23702370
"no-op */" font-lock-comment-face))
23712371
;; format
23722372
(rust-test-font-lock
23732373
"format!(\"abcd {0} efgh {1}\", foo, bar); { /* no-op */ }"
2374-
'("format!" rust-builtin-formatting-macro-face
2374+
'("format!" rust-builtin-formatting-macro
23752375
"\"abcd " font-lock-string-face
2376-
"{0}" rust-string-interpolation-face
2376+
"{0}" rust-string-interpolation
23772377
" efgh " font-lock-string-face
2378-
"{1}" rust-string-interpolation-face
2378+
"{1}" rust-string-interpolation
23792379
"\"" font-lock-string-face
23802380
"/* " font-lock-comment-delimiter-face
23812381
"no-op */" font-lock-comment-face))
23822382
;; print + raw string
23832383
(rust-test-font-lock
23842384
"format!(r\"abcd {0} efgh {1}\", foo, bar); { /* no-op */ }"
2385-
'("format!" rust-builtin-formatting-macro-face
2385+
'("format!" rust-builtin-formatting-macro
23862386
"r\"abcd " font-lock-string-face
2387-
"{0}" rust-string-interpolation-face
2387+
"{0}" rust-string-interpolation
23882388
" efgh " font-lock-string-face
2389-
"{1}" rust-string-interpolation-face
2389+
"{1}" rust-string-interpolation
23902390
"\"" font-lock-string-face
23912391
"/* " font-lock-comment-delimiter-face
23922392
"no-op */" font-lock-comment-face))
23932393
;; print + raw string with hash
23942394
(rust-test-font-lock
23952395
"format!(r#\"abcd {0} efgh {1}\"#, foo, bar); { /* no-op */ }"
2396-
'("format!" rust-builtin-formatting-macro-face
2396+
'("format!" rust-builtin-formatting-macro
23972397
"r#\"abcd " font-lock-string-face
2398-
"{0}" rust-string-interpolation-face
2398+
"{0}" rust-string-interpolation
23992399
" efgh " font-lock-string-face
2400-
"{1}" rust-string-interpolation-face
2400+
"{1}" rust-string-interpolation
24012401
"\"#" font-lock-string-face
24022402
"/* " font-lock-comment-delimiter-face
24032403
"no-op */" font-lock-comment-face))
24042404
;; print + raw string with two hashes
24052405
(rust-test-font-lock
24062406
"format!(r##\"abcd {0} efgh {1}\"##, foo, bar); { /* no-op */ }"
2407-
'("format!" rust-builtin-formatting-macro-face
2407+
'("format!" rust-builtin-formatting-macro
24082408
"r##\"abcd " font-lock-string-face
2409-
"{0}" rust-string-interpolation-face
2409+
"{0}" rust-string-interpolation
24102410
" efgh " font-lock-string-face
2411-
"{1}" rust-string-interpolation-face
2411+
"{1}" rust-string-interpolation
24122412
"\"##" font-lock-string-face
24132413
"/* " font-lock-comment-delimiter-face
24142414
"no-op */" font-lock-comment-face)))
24152415

24162416
(ert-deftest rust-write-macro-font-lock ()
24172417
(rust-test-font-lock
24182418
"write!(f, \"abcd {0}}} efgh {1}\", foo, bar); { /* no-op */ }"
2419-
'("write!" rust-builtin-formatting-macro-face
2419+
'("write!" rust-builtin-formatting-macro
24202420
"\"abcd " font-lock-string-face
2421-
"{0}" rust-string-interpolation-face
2421+
"{0}" rust-string-interpolation
24222422
"}} efgh " font-lock-string-face
2423-
"{1}" rust-string-interpolation-face
2423+
"{1}" rust-string-interpolation
24242424
"\"" font-lock-string-face
24252425
"/* " font-lock-comment-delimiter-face
24262426
"no-op */" font-lock-comment-face))
24272427
(rust-test-font-lock
24282428
"writeln!(f, \"abcd {0}}} efgh {1}\", foo, bar); { /* no-op */ }"
2429-
'("writeln!" rust-builtin-formatting-macro-face
2429+
'("writeln!" rust-builtin-formatting-macro
24302430
"\"abcd " font-lock-string-face
2431-
"{0}" rust-string-interpolation-face
2431+
"{0}" rust-string-interpolation
24322432
"}} efgh " font-lock-string-face
2433-
"{1}" rust-string-interpolation-face
2433+
"{1}" rust-string-interpolation
24342434
"\"" font-lock-string-face
24352435
"/* " font-lock-comment-delimiter-face
24362436
"no-op */" font-lock-comment-face))
24372437
(rust-test-font-lock
24382438
"println!(\"123\"); eprintln!(\"123\"); cprintln!(\"123\");"
2439-
'("println!" rust-builtin-formatting-macro-face
2439+
'("println!" rust-builtin-formatting-macro
24402440
"\"123\"" font-lock-string-face
2441-
"eprintln!" rust-builtin-formatting-macro-face
2441+
"eprintln!" rust-builtin-formatting-macro
24422442
"\"123\"" font-lock-string-face
24432443
"cprintln!" font-lock-preprocessor-face
24442444
"\"123\"" font-lock-string-face)))

rust-mode.el

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,22 +117,31 @@ to the function arguments. When nil, `->' will be indented one level."
117117

118118
;;; Faces
119119

120-
(defface rust-unsafe-face
120+
(define-obsolete-face-alias 'rust-unsafe-face
121+
'rust-unsafe "0.6.0")
122+
(define-obsolete-face-alias 'rust-question-mark-face
123+
'rust-question-mark "0.6.0")
124+
(define-obsolete-face-alias 'rust-builtin-formatting-macro-face
125+
'rust-builtin-formatting-macro "0.6.0")
126+
(define-obsolete-face-alias 'rust-string-interpolation-face
127+
'rust-string-interpolation "0.6.0")
128+
129+
(defface rust-unsafe
121130
'((t :inherit font-lock-warning-face))
122131
"Face for the `unsafe' keyword."
123132
:group 'rust-mode)
124133

125-
(defface rust-question-mark-face
134+
(defface rust-question-mark
126135
'((t :weight bold :inherit font-lock-builtin-face))
127136
"Face for the question mark operator."
128137
:group 'rust-mode)
129138

130-
(defface rust-builtin-formatting-macro-face
139+
(defface rust-builtin-formatting-macro
131140
'((t :inherit font-lock-builtin-face))
132141
"Face for builtin formatting macros (print! &c.)."
133142
:group 'rust-mode)
134143

135-
(defface rust-string-interpolation-face
144+
(defface rust-string-interpolation
136145
'((t :slant italic :inherit font-lock-string-face))
137146
"Face for interpolating braces in builtin formatting macro strings."
138147
:group 'rust-mode)
@@ -401,7 +410,7 @@ Does not match type annotations of the form \"foo::<\"."
401410
(,(regexp-opt rust-special-types 'symbols) . font-lock-type-face)
402411

403412
;; The unsafe keyword
404-
("\\_<unsafe\\_>" . 'rust-unsafe-face)
413+
("\\_<unsafe\\_>" . 'rust-unsafe)
405414

406415
;; Attributes like `#[bar(baz)]` or `#![bar(baz)]` or `#[bar = "baz"]`
407416
(,(rust-re-grab (concat "#\\!?\\[" rust-re-ident "[^]]*\\]"))
@@ -413,22 +422,22 @@ Does not match type annotations of the form \"foo::<\"."
413422
"!"))
414423
rust-formatting-macro-opening-re
415424
"\\(?:" rust-start-of-string-re "\\)?")
416-
(1 'rust-builtin-formatting-macro-face)
425+
(1 'rust-builtin-formatting-macro)
417426
(rust-string-interpolation-matcher
418427
(rust-end-of-string)
419428
nil
420-
(0 'rust-string-interpolation-face t nil)))
429+
(0 'rust-string-interpolation t nil)))
421430

422431
;; write! macro
423432
(,(concat (rust-re-grab (concat (rust-re-word "write\\(ln\\)?") "!"))
424433
rust-formatting-macro-opening-re
425434
"[[:space:]]*[^\"]+,[[:space:]]*"
426435
rust-start-of-string-re)
427-
(1 'rust-builtin-formatting-macro-face)
436+
(1 'rust-builtin-formatting-macro)
428437
(rust-string-interpolation-matcher
429438
(rust-end-of-string)
430439
nil
431-
(0 'rust-string-interpolation-face t nil)))
440+
(0 'rust-string-interpolation t nil)))
432441

433442
;; Syntax extension invocations like `foo!`, highlight including the !
434443
(,(concat (rust-re-grab (concat rust-re-ident "!")) "[({[:space:][]")
@@ -457,7 +466,7 @@ Does not match type annotations of the form \"foo::<\"."
457466
(,(concat "'" (rust-re-grab rust-re-ident) "[^']") 1 font-lock-variable-name-face)
458467

459468
;; Question mark operator
460-
("\\?" . 'rust-question-mark-face)
469+
("\\?" . 'rust-question-mark)
461470
)
462471

463472
;; Ensure we highlight `Foo` in `struct Foo` as a type.

0 commit comments

Comments
 (0)