emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 4bf98ae: Fix BSD .include etc syntax in Makefiles


From: Lars Ingebrigtsen
Subject: master 4bf98ae: Fix BSD .include etc syntax in Makefiles
Date: Sat, 12 Dec 2020 15:59:17 -0500 (EST)

branch: master
commit 4bf98aecffe57648d15db90718134b00ac87ec3b
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    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 <file>
         and
               .   include <file>
    
         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 3e49f84..8b6a7fc 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]