branch: elpa/systemd commit a434645e766f69144fbb4047ddbeb5f4b8ebf0f6 Author: Mark Oteiza <mvote...@udel.edu> Commit: Mark Oteiza <mvote...@udel.edu>
improvements to autoload regexen many thanks to @Lompik * don't match empty unit names. AIUI unit names are alphanumeric with the exception of the group [-_.@], non ascii are backslash-escaped. * more strictly match temp file names: .# prefix, [[:hexdigit:]]{16} suffix. the filenames are a unit name with a unit suffix (systemctl edit --full) or just override.conf (edit without --full option) * add regex for dropin config files. This is just a file with ".conf" extension, with the added constraint that it's a file having some parent directory named "systemd" --- systemd.el | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/systemd.el b/systemd.el index 850448e..d6ae0a2 100644 --- a/systemd.el +++ b/systemd.el @@ -199,7 +199,7 @@ (defconst systemd-autoload-regexp (eval-when-compile - (rx "." + (rx (+? (or alphanumeric (any "-_.@\\"))) "." (or "automount" "busname" "mount" "service" "slice" "socket" "swap" "target" "timer" "link" "netdev" "network") string-end)) @@ -207,12 +207,20 @@ (defconst systemd-tempfn-autoload-regexp (eval-when-compile - (rx (or "automount" "busname" "mount" "service" "slice" - "socket" "swap" "target" "timer" "link" "netdev" "network" + (rx ".#" + (or (and (+? (or alphanumeric (any "-_.@\\"))) "." + (or "automount" "busname" "mount" "service" "slice" + "socket" "swap" "target" "timer" "link" "netdev" "network")) "override.conf") - (?? (= 16 (char hex-digit))) string-end)) + (= 16 (char hex-digit)) string-end)) "Regexp for temp file buffers in which to autoload `systemd-mode'.") +(defconst systemd-dropin-autoload-regexp + (eval-when-compile + (rx "/systemd/" (+? anything) ".d/" + (+? (or alphanumeric (any "-_.@\\"))) ".conf" string-end)) + "Regexp for dropin config file buffers in which to autoload `systemd-mode'.") + (defun systemd-get-value (start) "Return the value of the key whose value begins at position START. Lines ending in a backslash are concatenated with the next @@ -357,6 +365,8 @@ See systemd.unit(5) for details on unit file syntax.") (add-to-list 'auto-mode-alist `(,systemd-autoload-regexp . systemd-mode)) ;;;###autoload (add-to-list 'auto-mode-alist `(,systemd-tempfn-autoload-regexp . systemd-mode)) +;;;###autoload +(add-to-list 'auto-mode-alist `(,systemd-dropin-autoload-regexp . systemd-mode)) ;;;###autoload (define-derived-mode systemd-mode conf-mode "Systemd"