[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/systemd a3d3921 111/131: extend multi-line matching to sec
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/systemd a3d3921 111/131: extend multi-line matching to sections and keys |
Date: |
Sun, 29 Aug 2021 11:35:25 -0400 (EDT) |
branch: elpa/systemd
commit a3d39214b70c3dde0be12a53260e3fa470530ad6
Author: Mark Oteiza <mvoteiza@udel.edu>
Commit: Mark Oteiza <mvoteiza@udel.edu>
extend multi-line matching to sections and keys
---
systemd.el | 36 +++++++++++++++++++++++-------------
1 file changed, 23 insertions(+), 13 deletions(-)
diff --git a/systemd.el b/systemd.el
index 4715d1b..7cce5d5 100644
--- a/systemd.el
+++ b/systemd.el
@@ -253,14 +253,27 @@ file, defaulting to the link under point, if any."
(setq flag (memq (following-char) '(?# ?\;))))))
flag))
-(defun systemd-comment-matcher (limit)
- "Matcher for comments.
-Only matches comments on lines passing `systemd-construct-start-p'."
- (let ((re "^[ \t]*?\\([#;]\\)\\(.*\\)$")
- match)
- (while (and (setq match (re-search-forward re limit t))
- (not (systemd-construct-start-p))))
- match))
+(defmacro define-systemd-matcher (name regexp &optional docstring)
+ "Define a new function NAME that matches REGEXP in a multi-line construct.
+Only returns matches of REGEXP on lines passing `systemd-construct-start-p'."
+ (declare (debug (symbolp stringp &optional stringp))
+ (indent 2) (doc-string 3))
+ `(defun ,name (limit)
+ ,docstring
+ (let (match)
+ (while (and (setq match (re-search-forward ,regexp limit t))
+ (not (systemd-construct-start-p))))
+ match)))
+
+(define-systemd-matcher systemd-comment-matcher "^[ \t]*?\\([#;]\\)\\(.*\\)$"
+ "Matcher for comments. ")
+
+(define-systemd-matcher systemd-section-matcher
+ "^\\(\\[\\([[:upper:]][[:alnum:]]+\\|X-.*?\\)\\]\\)"
+ "Matcher for section titles.")
+
+(define-systemd-matcher systemd-key-matcher "^\\([[:upper:]][[:alnum:]]+\\)="
+ "Matcher for keys (unit directives).")
(defun systemd-exec-prefix-anchored-matcher (limit)
"Matcher for the exec prefix in anchored font-lock rule.
@@ -281,11 +294,8 @@ See `font-lock-keywords' and (info \"(elisp) Search-based
Fontification\")."
`((systemd-comment-matcher
(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))
+ (systemd-section-matcher 1 'font-lock-type-face)
+ (systemd-key-matcher 1 'font-lock-keyword-face))
"Minimal expressions to highlight in `systemd-mode'.")
(defconst systemd-font-lock-keywords-2
- [nongnu] elpa/systemd 16be183 084/131: don't indiscriminately use relative file name, (continued)
- [nongnu] elpa/systemd 16be183 084/131: don't indiscriminately use relative file name, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd f0b29ad 087/131: systemd v232 directives, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 7874a10 090/131: future flycheck has a checker for units, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd fa1277d 092/131: add reminder, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 59ce8ad 095/131: simpler while test, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 9693935 099/131: nix extra newline, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 7bb8f09 104/131: correct syntax?, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd a4f4096 107/131: moar keywords, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd b0c1d64 109/131: add multi-line comment highlighting, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 5c9389d 110/131: move this matcher down with the other ones, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd a3d3921 111/131: extend multi-line matching to sections and keys,
ELPA Syncer <=
- [nongnu] elpa/systemd a9f82b1 124/131: add systemd-mode company backend buffer locally, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 401d71c 122/131: Add %E, %j, %J, %T, %V specifiers, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd ec8f6cf 128/131: happy new year, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd b6ae63a 131/131: add specifiers (leave obsoleted ones in for now), ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 0416fe4 130/131: drop some unneeded eval-when-compile, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 50c63c2 026/131: allow cycling completions in `systemd-doc-open`, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 612c3de 027/131: double bump, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 347c157 031/131: lexical binding, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd e7a2efb 021/131: mention `package-install-file` in README, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd ed00e3f 029/131: require 24.4 (with-eval-after-load), ELPA Syncer, 2021/08/29