11" Vim syntax file
2- " Language: M4
2+ " Language: M4
33" Maintainer: Claudio Fleiner ([email protected] )4- " URL: http://www.fleiner.com/vim/syntax/m4.vim
5- " (outdated)
64" Last Change: 2022 Jun 12
5+ " 2025 Sep 2 by Vim project: fix a few syntax issues #18192
76
87" This file will highlight user function calls if they use only
98" capital letters and have at least one argument (i.e. the '('
@@ -18,6 +17,23 @@ if !exists("main_syntax")
1817 let main_syntax= ' m4'
1918endif
2019
20+ " Reference: The Open Group Base Specifications, M4
21+ " https://pubs.opengroup.org/onlinepubs/9799919799/
22+
23+ " Quoting in M4:
24+ " – Quotes are nestable;
25+ " – The delimiters can be redefined with changequote(); here we only handle
26+ " the default pair: ` ... ';
27+ " – Quoted text in M4 is rescanned, not treated as a literal string;
28+ " Therefore the region is marked transparent so contained items retain
29+ " their normal highlighting.
30+ syn region m4Quoted
31+ \ matchgroup= m4QuoteDelim
32+ \ start = + `+
33+ \ end = + '+
34+ \ contains= @m 4Top
35+ \ transparent
36+
2137" define the m4 syntax
2238syn match m4Variable contained " \$\d\+ "
2339syn match m4Special contained " $[@*#]"
@@ -30,28 +46,26 @@ syn region m4Paren matchgroup=m4Delimiter start="(" end=")" contained contain
3046syn region m4Command matchgroup =m4Function start =" \<\( m4_\)\=\( define\| defn\| pushdef\) (" end =" )" contains =@m4Top
3147syn region m4Command matchgroup =m4Preproc start =" \<\( m4_\)\=\( include\| sinclude\) (" he =e - 1 end =" )" contains =@m4Top
3248syn region m4Command matchgroup =m4Statement start =" \<\( m4_\)\=\( syscmd\| esyscmd\| ifdef\| ifelse\| indir\| builtin\| shift\| errprint\| m4exit\| changecom\| changequote\| changeword\| m4wrap\| debugfile\| divert\| undivert\) (" he =e - 1 end =" )" contains =@m4Top
33- syn region m4Command matchgroup =m4builtin start =" \<\( m4_\)\=\( len\| index\| regexp\| substr\| translit\| patsubst\| format\| incr\| decr\| eval\| maketemp\) (" he =e - 1 end =" )" contains =@m4Top
49+ syn region m4Command matchgroup =m4Builtin start =" \<\( m4_\)\=\( len\| index\| regexp\| substr\| translit\| patsubst\| format\| incr\| decr\| eval\| maketemp\) (" he =e - 1 end =" )" contains =@m4Top
3450syn keyword m4Statement divert undivert
3551syn region m4Command matchgroup =m4Type start =" \<\( m4_\)\=\( undefine\| popdef\) (" he =e - 1 end =" )" contains =@m4Top
3652syn region m4Function matchgroup =m4Type start =" \< [_A-Z][_A-Z0-9]*(" he =e - 1 end =" )" contains =@m4Top
37- syn region m4String start =" `" end =" '" contains =SpellErrors
38- syn cluster m4Top contains =m4Comment,m4Constants,m4Special,m4Variable,m4String,m4Paren,m4Command,m4Statement,m4Function
53+ syn cluster m4Top contains =m4Comment,m4Constants,m4Special,m4Variable,m4Paren,m4Command,m4Statement,m4Function,m4Quoted
3954
4055" Define the default highlighting.
4156" Only when an item doesn't have highlighting yet
42- hi def link m4Delimiter Delimiter
43- hi def link m4Comment Comment
44- hi def link m4Function Function
45- hi def link m4Keyword Keyword
46- hi def link m4Special Special
47- hi def link m4String String
48- hi def link m4Statement Statement
49- hi def link m4Preproc PreProc
50- hi def link m4Type Type
51- hi def link m4Special Special
52- hi def link m4Variable Special
53- hi def link m4Constants Constant
54- hi def link m4Builtin Statement
57+ hi def link m4QuoteDelim Delimiter
58+ hi def link m4Delimiter Delimiter
59+ hi def link m4Comment Comment
60+ hi def link m4Function Function
61+ hi def link m4Keyword Keyword
62+ hi def link m4Special Special
63+ hi def link m4Statement Statement
64+ hi def link m4Preproc PreProc
65+ hi def link m4Type Type
66+ hi def link m4Variable Special
67+ hi def link m4Constants Constant
68+ hi def link m4Builtin Statement
5569
5670let b: current_syntax = " m4"
5771
0 commit comments