From 4bf98aecffe57648d15db90718134b00ac87ec3b Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sat, 12 Dec 2020 21:59:08 +0100 Subject: [PATCH] Fix BSD .include etc syntax in Makefiles * lisp/progmodes/make-mode.el (makefile-bsdmake-statements): Fix the BSD conditional syntax (bug#24000). (makefile-make-font-lock-keywords): Allow calling without keywords. (makefile-bsdmake-font-lock-keywords): Add the conditional syntax. Makefile inclusion, conditional structures and for loops reminiscent of the C programming language are provided in make. All such structures are identified by a line beginning with a single dot (`.') character. Whitespace characters may follow this dot, e.g., .include and . include are identical constructs --- lisp/progmodes/make-mode.el | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/lisp/progmodes/make-mode.el b/lisp/progmodes/make-mode.el index 3e49f84dbce..8b6a7fc1b48 100644 --- a/lisp/progmodes/make-mode.el +++ b/lisp/progmodes/make-mode.el @@ -343,8 +343,9 @@ not be enclosed in { } or ( )." "List of keywords understood by gmake.") (defconst makefile-bsdmake-statements - '(".elif" ".elifdef" ".elifmake" ".elifndef" ".elifnmake" ".else" ".endfor" - ".endif" ".for" ".if" ".ifdef" ".ifmake" ".ifndef" ".ifnmake" ".undef") + '("elif" "elifdef" "elifmake" "elifndef" "elifnmake" "else" "endfor" + "endif" "for" "if" "ifdef" "ifmake" "ifndef" "ifnmake" "poison" + "undef" "include") "List of keywords understood by BSD make.") (defun makefile-make-font-lock-keywords (var keywords space @@ -376,8 +377,9 @@ not be enclosed in { } or ( )." ("[^$]\\(\\$[@%*]\\)" 1 'makefile-targets append) - ;; Fontify conditionals and includes. - (,(concat "^\\(?: [ \t]*\\)?" + ,@(if keywords + ;; Fontify conditionals and includes. + `((,(concat "^\\(?: [ \t]*\\)?" (replace-regexp-in-string " " "[ \t]+" (if (eq (car keywords) t) @@ -385,7 +387,7 @@ not be enclosed in { } or ( )." (regexp-opt (cdr keywords) t)) (regexp-opt keywords t))) "\\>[ \t]*\\([^: \t\n#]*\\)") - (1 font-lock-keyword-face) (2 font-lock-variable-name-face)) + (1 font-lock-keyword-face) (2 font-lock-variable-name-face)))) ,@(if negation `((,negation (1 font-lock-negation-char-face prepend) @@ -493,13 +495,17 @@ not be enclosed in { } or ( )." 1 'makefile-makepp-perl t))) (defconst makefile-bsdmake-font-lock-keywords - (makefile-make-font-lock-keywords - ;; A lot more could be done for variables here: - makefile-var-use-regex - makefile-bsdmake-statements - t - "^\\(?: [ \t]*\\)?\\.\\(?:el\\)?if\\(n?\\)\\(?:def\\|make\\)?\\>[ \t]*\\(!?\\)" - '("^[ \t]*\\.for[ \t].+[ \t]\\(in\\)\\>" 1 font-lock-keyword-face))) + (append + (makefile-make-font-lock-keywords + ;; A lot more could be done for variables here: + makefile-var-use-regex + nil + t + "^\\(?: [ \t]*\\)?\\.\\(?:el\\)?if\\(n?\\)\\(?:def\\|make\\)?\\>[ \t]*\\(!?\\)" + '("^[ \t]*\\.for[ \t].+[ \t]\\(in\\)\\>" 1 font-lock-keyword-face)) + `((,(concat "^\\. *" (regexp-opt makefile-bsdmake-statements) "\\>") 0 + font-lock-keyword-face)))) + (defconst makefile-imake-font-lock-keywords (append -- 2.39.2