The highlighting of assignments is not syntax controlled in makefile-mode
.
It is done via regular expressions inmakefile-font-lock-keywords
.
The list makefile-font-lock-keywords
is constructed by the function makefile-make-font-lock-keywords
which uses the variable makefile-macroassign-regex
for macro assignments.
If you change makefile-macroassign-regex
you must also re-run makefile-make-font-lock-keywords
to reconstruct the font-lock keyword lists you need.
Also makefile-imenu-generic-expression
is constructed from makefile-macroassign-regex
so you need to reconstruct the value of that variable as well.
I demonstrate that by a self-defined major mode derived from makefile-mode
.
The most important change in that major mode is the added +
-sign in the character groups of makefile-macroassign-regex
.
(define-derived-mode my-makefile-mode makefile-mode "myMake"
"Makefiles with additional operator +=."
(setq-local makefile-macroassign-regex
"\\(?:^\\|^export\\|^override\\|:\\|:[ \t]*override\\)[ \t]*\\([^ \n\t+][^:#= \t\n+]*\\)[ \t]*\\(?:!=\\|[*:+]?[:?]?=\\)")
(setq-local makefile-font-lock-keywords
(makefile-make-font-lock-keywords
makefile-var-use-regex
makefile-statements
t))
(setq-local makefile-imenu-generic-expression
`(("Dependencies" makefile-previous-dependency 1)
("Macro Assignment" ,makefile-macroassign-regex 1))))