@@ -45,6 +45,7 @@ repository:
4545 {include : " #loop" }
4646 {include : " #escapes" }
4747 {include : " #definition" }
48+ {include : " #formatting" }
4849 {include : " #face-innards" }
4950 {include : " #expression" }
5051 {include : " #operators" }
@@ -269,6 +270,56 @@ repository:
269270 }]
270271
271272
273+ # Formatting functions
274+ formatting :
275+ name : " meta.string-formatting.expression.emacs.lisp"
276+ begin : ' (\\ ()(format|format-message|message|error)(?=\\ s|$|")'
277+ end : ' \\ )'
278+ beginCaptures :
279+ 1 : name : " punctuation.section.expression.begin.emacs.lisp"
280+ 2 : name : " support.function.$2.emacs.lisp"
281+ endCaptures :
282+ 0 : name : " punctuation.section.expression.end.emacs.lisp"
283+ patterns : [{
284+
285+ # Pin-hack: Part 1
286+ begin : ' \\ G\\ s*(")'
287+ end : ' "'
288+ beginCaptures : 1 : name : " punctuation.definition.string.begin.emacs.lisp"
289+ endCaptures : 0 : name : " punctuation.definition.string.end.emacs.lisp"
290+ patterns : [include : " #format" ]
291+ },{
292+ # Pin-hack: Part 2
293+ begin : ' \\ G\\ s*$\\ n?'
294+ end : ' "|(?<!^)$|[\\ s"](?=[^\\ s"])'
295+ patterns : [
296+ match : " ^\\ s*$\\ n?"
297+
298+ {match : ' (?:^|\\ G)\\ s*(")' ,
299+ captures :
300+ 1 : name : " punctuation.definition.string.begin.emacs.lisp" }
301+
302+ begin : ' (?<=")'
303+ end : ' "'
304+ patterns : [include : " #format" ]
305+ endCaptures :
306+ 0 : name : " punctuation.definition.string.end.emacs.lisp"
307+ ]
308+ }, include : " $self" ]
309+
310+
311+ # Formatting string, where "%" has special significance
312+ format :
313+ contentName : " string.quoted.double.emacs.lisp"
314+ begin : ' \\ G'
315+ end : ' (?=")'
316+ patterns : [{
317+ match : " (%[%cdefgosSxX])|(%.)"
318+ captures :
319+ 1 : name : " constant.other.placeholder.emacs.lisp"
320+ 2 : name : " invalid.illegal.placeholder.emacs.lisp"
321+ }, include : " #string-innards" ]
322+
272323
273324 # Primitives/Fundamental Lisp functions
274325 functions :
@@ -434,6 +485,11 @@ repository:
434485 end : ' "'
435486 beginCaptures : 0 : name : " punctuation.definition.string.begin.emacs.lisp"
436487 endCaptures : 0 : name : " punctuation.definition.string.end.emacs.lisp"
488+ patterns : [include : " #string-innards" ]
489+
490+
491+ # Escape sequences within double-quoted strings
492+ " string-innards" :
437493 patterns : [{
438494
439495 # Concealed newline
@@ -446,13 +502,6 @@ repository:
446502 name : " constant.character.escape.emacs.lisp"
447503 captures :
448504 1 : name : " punctuation.escape.backslash.emacs.lisp"
449- },{
450-
451- # Formatting placeholder
452- match : " (%[%cdefgosSxX])|(%.)"
453- captures :
454- 1 : name : " constant.other.placeholder.emacs.lisp"
455- 2 : name : " invalid.illegal.placeholder.emacs.lisp"
456505 }]
457506
458507
0 commit comments