Skip to content

Commit 510ca80

Browse files
dlejaychrisbra
authored andcommitted
runtime(m4): Improve comments, distinguish them from #-lines
closes: #18200 Signed-off-by: Damien Lejay <damien@lejay.be> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 37e7728 commit 510ca80

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

runtime/syntax/m4.vim

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
" Maintainer: Claudio Fleiner (claudio@fleiner.com)
44
" Last Change: 2022 Jun 12
55
" 2025 Sep 2 by Vim project: fix a few syntax issues #18192
6+
" 2025 Sep 5 by Vim project: introduce m4Disabled region #18200
67

78
" This file will highlight user function calls if they use only
89
" capital letters and have at least one argument (i.e. the '('
@@ -24,7 +25,7 @@ endif
2425
" – Quotes are nestable;
2526
" – The delimiters can be redefined with changequote(); here we only handle
2627
" the default pair: ` ... ';
27-
" – Quoted text in M4 is rescanned, not treated as a literal string;
28+
" – Quoted text in M4 is rescanned, not treated as a literal string.
2829
" Therefore the region is marked transparent so contained items retain
2930
" their normal highlighting.
3031
syn region m4Quoted
@@ -34,11 +35,20 @@ syn region m4Quoted
3435
\ contains=@m4Top
3536
\ transparent
3637

38+
" Comments in M4:
39+
" – According to the Open Group Base Specification, comments start with
40+
" a <number-sign> (#) and end at <newline>, unless redefined with changecom().
41+
" We only handle the default here.
42+
" – Comments in M4 are not like in most languages: they do not remove the text,
43+
" they simply prevent any macros from being expanded, while the text remains
44+
" in the output. This region therefore disables any other matches.
45+
" – Comments themselves are disabled when quoted.
46+
syn region m4Disabled start=+#+ end=+$+ containedin=ALLBUT,m4Quoted
47+
3748
" define the m4 syntax
3849
syn match m4Variable contained "\$\d\+"
3950
syn match m4Special contained "$[@*#]"
4051
syn match m4Comment "\<\(m4_\)\=dnl\>.*" contains=SpellErrors
41-
syn match m4Comment "#.*" contains=SpellErrors
4252
syn match m4Constants "\<\(m4_\)\=__file__"
4353
syn match m4Constants "\<\(m4_\)\=__line__"
4454
syn keyword m4Constants divnum sysval m4_divnum m4_sysval

0 commit comments

Comments
 (0)