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

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

[nongnu] elpa/systemd 930e82e 100/131: font lock additional exec prefix


From: ELPA Syncer
Subject: [nongnu] elpa/systemd 930e82e 100/131: font lock additional exec prefix
Date: Sun, 29 Aug 2021 11:35:23 -0400 (EDT)

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

    font lock additional exec prefix
---
 systemd.el | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/systemd.el b/systemd.el
index 1b79065..3e7f6f3 100644
--- a/systemd.el
+++ b/systemd.el
@@ -202,6 +202,21 @@ file, defaulting to the link under point, if any."
   (interactive)
   (systemd-doc-man "systemd.directives(7)"))
 
+(defun systemd-exec-prefix-anchored-matcher (limit)
+  "Matcher for the exec prefix in anchored font-lock rule.
+See `font-lock-keywords' and (info \"(elisp) Search-based Fontification\")."
+  (let ((pos (car (match-data)))
+        (prefixes '(?- ?@ ?+))
+        char end res)
+    (while (and (memq (setq char (following-char)) prefixes)
+                (< (point) limit))
+      (forward-char)
+      (setq prefixes (delq char prefixes))
+      (setq end (point-marker)))
+    (when end
+      (prog1 (setq res (list (1+ pos) end))
+        (set-match-data res)))))
+
 (defun systemd-buffer-section-p ()
   "Return t if current line begins with \"[\", otherwise nil."
   (save-excursion
@@ -255,16 +270,16 @@ file, defaulting to the link under point, if any."
       ("^\\(\\[\\([[:upper:]][[:alnum:]]+\\|X-.*?\\)\\]\\)"
        1 'font-lock-type-face)
       ;; keys
-      ("^\\([[:upper:]][[:alnum:]]+\\)="
-       1 'font-lock-keyword-face)
+      ("^\\([[: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
-      ;; TODO account for @ being a prefix now
-      ("=\\(-@\\|@-\\|[@-]\\)" 1 'font-lock-negation-char-face)))
+      ("="
+       (systemd-exec-prefix-anchored-matcher
+        nil nil (0 'font-lock-negation-char-face)))))
   "Default expressions to highlight in `systemd-mode'.
 See systemd.unit(5) for details on unit file syntax.")
 



reply via email to

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