emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/systemd 4c0ec1e 105/131: split font-lock-keywords into lev


From: ELPA Syncer
Subject: [nongnu] elpa/systemd 4c0ec1e 105/131: split font-lock-keywords into levels
Date: Sun, 29 Aug 2021 11:35:23 -0400 (EDT)

branch: elpa/systemd
commit 4c0ec1e599690ba8a3f65d0d916813af5342122f
Author: Mark Oteiza <mvoteiza@udel.edu>
Commit: Mark Oteiza <mvoteiza@udel.edu>

    split font-lock-keywords into levels
    
    more importantly, bind systemd-font-lock-keywords to a _symbol_.
    this makes hacking font-lock-keywords on the fly a little easier, in
    addition to adding to customization/granularity
    (info "(elisp) Font Lock Basics")
---
 systemd.el | 51 ++++++++++++++++++++++++++++++---------------------
 1 file changed, 30 insertions(+), 21 deletions(-)

diff --git a/systemd.el b/systemd.el
index 79d423f..42410b9 100644
--- a/systemd.el
+++ b/systemd.el
@@ -258,26 +258,32 @@ See `font-lock-keywords' and (info \"(elisp) Search-based 
Fontification\")."
     (`candidates (all-completions arg (systemd-completion-table nil)))
     (`post-completion (if (not (systemd-buffer-section-p)) (insert "=")))))
 
-(defvar systemd-font-lock-keywords
-  (eval-when-compile
-    `(("^[[:space:]]*?\\([#;]\\)\\(.*\\)$"
-       (1 'font-lock-comment-delimiter-face)
-       (2 'font-lock-comment-face))
-      ("\\\\$" 0 'font-lock-warning-face) ; line break
-      ;; sections
-      ("^\\(\\[\\([[:upper:]][[:alnum:]]+\\|X-.*?\\)\\]\\)"
-       1 'font-lock-type-face)
-      ;; keys
-      ("^\\([[:upper:]][[:alnum:]]+\\)=" 1 'font-lock-keyword-face)
-      ;; boolean arguments
-      (,(rx "=" (group (or "yes" "true" "on" "0" "no" "false" "off")) eol)
-       1 'font-lock-constant-face)
-      ;; specifiers
-      ("%[nNpPiIfcrRtuUhsmbHv%]" 0 'font-lock-constant-face)
-      ;; exec prefixes
-      ("="
-       (systemd-exec-prefix-anchored-matcher
-        nil nil (0 'font-lock-negation-char-face)))))
+(defconst systemd-font-lock-keywords-1
+  `(("^[[:space:]]*?\\([#;]\\)\\(.*\\)$"
+     (1 'font-lock-comment-delimiter-face)
+     (2 'font-lock-comment-face))
+    ;; sections
+    ("^\\(\\[\\([[:upper:]][[:alnum:]]+\\|X-.*?\\)\\]\\)"
+     1 'font-lock-type-face)
+    ;; keys
+    ("^\\([[:upper:]][[:alnum:]]+\\)=" 1 'font-lock-keyword-face))
+  "Minimal expressions to highlight in `systemd-mode'.")
+
+(defconst systemd-font-lock-keywords-2
+  `(,@systemd-font-lock-keywords-1
+    ("\\\\$" 0 'font-lock-warning-face) ; line break
+    ;; boolean arguments
+    (,(rx "=" (group (or "yes" "true" "on" "0" "no" "false" "off")) eol)
+     1 'font-lock-constant-face)
+    ;; specifiers
+    ("%[nNpPiIfcrRtuUhsmbHv%]" 0 'font-lock-constant-face)
+    ;; exec prefixes
+    ("="
+     (systemd-exec-prefix-anchored-matcher
+      nil nil (0 'font-lock-negation-char-face))))
+  "Extended expressions to highlight in `systemd-mode'.")
+
+(defvar systemd-font-lock-keywords 'systemd-font-lock-keywords-2
   "Default expressions to highlight in `systemd-mode'.
 See systemd.unit(5) for details on unit file syntax.")
 
@@ -322,7 +328,10 @@ Key bindings:
   (conf-mode-initialize systemd-comment-start)
   (add-hook 'company-backends #'systemd-company-backend)
   (add-hook 'completion-at-point-functions #'systemd-complete-at-point nil t)
-  (setq font-lock-defaults '(systemd-font-lock-keywords t)))
+  (setq font-lock-defaults
+        '((systemd-font-lock-keywords
+           systemd-font-lock-keywords-1 systemd-font-lock-keywords-2)
+          t)))
 
 (provide 'systemd)
 



reply via email to

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