branch: elpa/systemd
commit 070e15e4c083c43c716a223168a27497d5bfdef9
Author: Mark Oteiza <[email protected]>
Commit: Mark Oteiza <[email protected]>
autoload temp files generated by sd's tempfn_random
* adds 16 random hex digits to the end of file name
* instead of a bunch of autoloads, draw regexp into a pair of defconst
* not sure how to splice a reusable list of extensions into an rx call,
which would be nicer than duplicating it
---
systemd.el | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/systemd.el b/systemd.el
index bef7bd0..5076009 100644
--- a/systemd.el
+++ b/systemd.el
@@ -73,6 +73,22 @@
:type 'boolean
:group 'systemd)
+(defconst systemd-autoload-regexp
+ (eval-when-compile
+ (rx "."
+ (or "automount" "busname" "mount" "service" "slice"
+ "socket" "swap" "target" "timer" "link" "netdev" "network")
+ string-end))
+ "Regexp for file buffers in which to autoload `systemd-mode'.")
+
+(defconst systemd-tempfn-autoload-regexp
+ (eval-when-compile
+ (rx (or "automount" "busname" "mount" "service" "slice"
+ "socket" "swap" "target" "timer" "link" "netdev" "network"
+ "override.conf")
+ (?? (= 16 (char hex-digit))) string-end))
+ "Regexp for temp file buffers in which to autoload `systemd-mode'.")
+
(defvar systemd-font-lock-keywords
`(("^\\([#;]\\)\\(.*\\)$"
(1 'font-lock-comment-delimiter-face)
@@ -178,18 +194,10 @@ file, defaulting to the link under point, if any."
["Open systemd.directives(7)" systemd-doc-directives
:help "Index of configuration directives"]))
-;;;###autoload (add-to-list 'auto-mode-alist '("\\.automount\\'" .
systemd-mode))
-;;;###autoload (add-to-list 'auto-mode-alist '("\\.busname\\'" . systemd-mode))
-;;;###autoload (add-to-list 'auto-mode-alist '("\\.mount\\'" . systemd-mode))
-;;;###autoload (add-to-list 'auto-mode-alist '("\\.service\\'" . systemd-mode))
-;;;###autoload (add-to-list 'auto-mode-alist '("\\.slice\\'" . systemd-mode))
-;;;###autoload (add-to-list 'auto-mode-alist '("\\.socket\\'" . systemd-mode))
-;;;###autoload (add-to-list 'auto-mode-alist '("\\.target\\'" . systemd-mode))
-;;;###autoload (add-to-list 'auto-mode-alist '("\\.timer\\'" . systemd-mode))
-;;;###autoload (add-to-list 'auto-mode-alist '("\\.link\\'" . systemd-mode))
-;;;###autoload (add-to-list 'auto-mode-alist '("\\.netdev\\'" . systemd-mode))
-;;;###autoload (add-to-list 'auto-mode-alist '("\\.network\\'" . systemd-mode))
-;;;###autoload (add-to-list 'auto-mode-alist '("\\.override\\.conf.*\\'" .
systemd-mode))
+;;;###autoload
+(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
(define-derived-mode systemd-mode conf-mode "Systemd"