Compare commits

..

No commits in common. "master" and "v1.4.1" have entirely different histories.

7 changed files with 83 additions and 491 deletions

View File

@ -1,6 +1,6 @@
SRC = systemd.el SRC = systemd.el
DATA = unit-directives.txt network-directives.txt nspawn-directives.txt DATA = unit-directives.txt network-directives.txt
DISTFILES := Makefile $(SRC) $(DATA) LICENSE README systemd-pkg.el test DISTFILES := Makefile $(SRC) $(DATA) LICENSE README systemd-pkg.el tests
VERSION := $(shell awk '/^;; Version:/ {print $$3}' $(SRC)) VERSION := $(shell awk '/^;; Version:/ {print $$3}' $(SRC))
@ -18,13 +18,13 @@ systemd-pkg.el: $(SRC)
systemd.elc: $(DATA) systemd.elc: $(DATA)
check: test/systemd-tests.el systemd.elc check: tests/systemd-tests.el systemd.elc
@$(EMACS) -Q --batch -L . --eval "(progn \ @$(EMACS) -Q --batch -L . --eval "(progn \
(load-file \"test/systemd-tests.el\") \ (load-file \"tests/systemd-tests.el\") \
(ert-run-tests-batch-and-exit))" (ert-run-tests-batch-and-exit))"
clean: clean:
$(RM) $(SRC:.el=.elc) systemd-pkg.el $(RM) $(SRC:.el=.elc)
dist: clean systemd-pkg.el dist: clean systemd-pkg.el
mkdir systemd-$(VERSION) mkdir systemd-$(VERSION)

3
README
View File

@ -7,7 +7,8 @@ in `systemd.el`.
Installation Installation
------------ ------------
Available as the `systemd` package on MELPA <https://melpa.org/>. Available as the `systemd` package on MELPA <http://melpa.org/> and
marmalade <https://marmalade-repo.org/>.
In Emacs, one can locally install as a package with `make dist` and In Emacs, one can locally install as a package with `make dist` and

View File

@ -1,56 +1,30 @@
ARP
ARPAllTargets ARPAllTargets
ARPIPTargets ARPIPTargets
ARPIntervalSec ARPIntervalSec
ARPProxy
ARPValidate ARPValidate
Activate
ActiveSlave
AdActorSystem
AdActorSystemPriority
AdSelect AdSelect
AdUserPortKey
Address Address
AddressAutoconfiguration
Advertise
AgeingTimeSec
Alias
AllMulticast
AllSlavesActive AllSlavesActive
AllowLocalRemote
AllowPortToBeRoot AllowPortToBeRoot
AllowedIPs
Anonymize
Architecture Architecture
AssignToLoopback
AssociatedWith
AutoJoin
AutoNegotiation
BSSID
BindCarrier BindCarrier
BitRate
BitsPerSecond BitsPerSecond
BlackList
Bond Bond
Bridge Bridge
Broadcast Cache
ClientIdentifier ClientIdentifier
CombinedChannels
ConfigureWithoutCarrier
CopyDSCP CopyDSCP
Cost Cost
CriticalConnection
DHCP DHCP
DHCPServer DHCPServer
DNS DNS
DNSDefaultRoute
DNSLifetimeSec
DNSOverTLS
DNSSEC DNSSEC
DNSSECNegativeTrustAnchors DNSSECNegativeTrustAnchors
DUIDRawData DUIDRawData
DUIDType DUIDType
DefaultLeaseTimeSec DefaultLeaseTimeSec
DefaultPVID
DefaultRouteOnDevice
Description Description
Destination Destination
DestinationPort DestinationPort
@ -59,88 +33,40 @@ Domains
DownDelaySec DownDelaySec
Driver Driver
Duplex Duplex
DuplicateAddressDetection
DynamicTransmitLoadBalancing
ERSPANIndex
EgressUntagged EgressUntagged
EmitDNS EmitDNS
EmitDomains
EmitLLDP EmitLLDP
EmitNTP EmitNTP
EmitRouter EmitRouter
EmitSIP
EmitTimezone EmitTimezone
Encapsulation
EncapsulationLimit EncapsulationLimit
EncapsulationType
Encrypt
Endpoint
FDBAgeingSec FDBAgeingSec
FOUDestinationPort
FOUSourcePort
FailOverMACPolicy FailOverMACPolicy
Family FallbackDNS
FallbackNTP
FastLeave FastLeave
FastOpenNoCookie
FirewallMark
Flags
FlowLabel
FooOverUDP
ForceDHCPv6PDOtherInformation
ForwardDelaySec ForwardDelaySec
From
GVRP
Gateway Gateway
GatewayOnLink
GenericProtocolExtension
GenericReceiveOffload
GenericSegmentationOffload
GratuitousARP GratuitousARP
Group
GroupForwardMask
GroupPolicyExtension GroupPolicyExtension
HairPin HairPin
HelloTimeSec HelloTimeSec
HomeAddress
Host Host
Hostname Hostname
IAID IAID
IPDoNotFragment
IPForward IPForward
IPMasquerade IPMasquerade
IPProtocol
IPServiceType
IPVLAN
IPv4LLRoute IPv4LLRoute
IPv4ProxyARP
IPv6AcceptRA IPv6AcceptRA
IPv6DuplicateAddressDetection IPv6DuplicateAddressDetection
IPv6FlowLabel IPv6FlowLabel
IPv6HopLimit IPv6HopLimit
IPv6MTUBytes
IPv6Preference
IPv6PrefixDelegation
IPv6PrivacyExtensions IPv6PrivacyExtensions
IPv6ProxyNDP
IPv6ProxyNDPAddress
IPv6RapidDeploymentPrefix
IPv6Token IPv6Token
ISATAP
Id Id
IgnoreCarrierLoss
IncomingInterface
Independent
InitialAdvertisedReceiveWindow
InitialCongestionWindow
InputKey InputKey
InterfaceId
InvertRule
KeepConfiguration
KernelCommandLine KernelCommandLine
KernelVersion
Key Key
KeyFile
KeyId
Kind Kind
L2MissNotification L2MissNotification
L3MissNotification L3MissNotification
@ -148,169 +74,76 @@ LACPTransmitRate
LLDP LLDP
LLMNR LLMNR
Label Label
LargeReceiveOffload
Layer2SpecificHeader
LearnPacketIntervalSec LearnPacketIntervalSec
Learning
LifetimeSec
LinkLayerAddress
LinkLocalAddressing LinkLocalAddressing
ListenPort
Local Local
LooseBinding
MACAddress MACAddress
MACAddressPolicy MACAddressPolicy
MACVLAN MACVLAN
MACsec
MIIMonitorSec MIIMonitorSec
MTUBytes MTUBytes
MVRP
MacLearning MacLearning
ManageTemporaryAddress
Managed
MaxAgeSec MaxAgeSec
MaxAttempts
MaxLeaseTimeSec MaxLeaseTimeSec
MaximumFDBEntries MaximumFDBEntries
Metric Metric
MinLinks MinLinks
Mode Mode
MultiQueue MultiQueue
Multicast
MulticastDNS MulticastDNS
MulticastFlood
MulticastIGMPVersion
MulticastQuerier MulticastQuerier
MulticastRouter
MulticastSnooping MulticastSnooping
MulticastToUnicast
NTP NTP
Name Name
NamePolicy NamePolicy
NeighborSuppression OneQueue
NetworkEmulatorDelayJitterSec
NetworkEmulatorDelaySec
NetworkEmulatorDuplicateRate
NetworkEmulatorLossRate
NetworkEmulatorPacketLimit
OnLink
OriginalName OriginalName
OtherChannels
OtherInformation
OutgoingInterface
OutputKey OutputKey
PVID PVID
PacketInfo PacketInfo
PacketNumber
PacketsPerSlave PacketsPerSlave
Parent
Path Path
Peer Peer
PeerPort
PeerSessionId
PeerTunnelId
PersistentKeepalive
PoolOffset PoolOffset
PoolSize PoolSize
Port
PortRange PortRange
PreferredLifetime PreferredLifetime
PreferredLifetimeSec
PreferredSource PreferredSource
Prefix
PrefixDelegationHint
PrefixRoute
PresharedKey
PresharedKeyFile
PrimaryReselectPolicy PrimaryReselectPolicy
PrimarySlave
Priority
PrivateKey
PrivateKeyFile
Property
Protocol
ProxyARP ProxyARP
ProxyARPWiFi
PublicKey
QuickAck
RapidCommit
ReduceARPProxy
Remote Remote
RemoteChecksumRx
RemoteChecksumTx
ReorderHeader
RequestBroadcast RequestBroadcast
RequestOptions
RequiredForOnline
ResendIGMP ResendIGMP
RestartSec
Route
RouteMetric RouteMetric
RouteShortCircuit RouteShortCircuit
RouteTable
RouterLifetimeSec
RouterPreference
RoutesToDNS
RxBufferSize
RxChannels
SSID
STP
SamplePoint
Scope Scope
SendHostname SendHostname
SendOption
SendRelease
SerializeTunneledPackets
SessionId
Source Source
SourcePort
TCP6SegmentationOffload
TCPSegmentationOffload
TOS TOS
TTL TTL
TTLPropagate
Table Table
Timezone Timezone
To
TransmitHashPolicy TransmitHashPolicy
TripleSampling
Tunnel Tunnel
TunnelId UDP6ZeroCheckSumRx
TxBufferSize
TxChannels
Type
TypeOfService
UDP6ZeroChecksumRx
UDP6ZeroChecksumTx UDP6ZeroChecksumTx
UDPChecksum UDPCheckSum
UDPSourcePort
UnicastFlood UnicastFlood
Unmanaged
UpDelaySec UpDelaySec
UseAutonomousPrefix
UseBPDU UseBPDU
UseDNS UseDNS
UseDomains UseDomains
UseForEncoding
UseHostname UseHostname
UseMTU UseMTU
UseNTP UseNTP
UseOnLinkPrefix
UseRoutes UseRoutes
UseSIP
UseTimezone UseTimezone
User
UserClass
VLAN VLAN
VLANFiltering VLANFiltering
VLANId VLANId
VNI
VNetHeader VNetHeader
VRF VRF
VXLAN VXLAN
ValidLifetimeSec
VendorClassIdentifier VendorClassIdentifier
Virtualization Virtualization
WLANInterfaceType
WakeOnLan WakeOnLan
Xfrm

View File

@ -1,38 +0,0 @@
Boot
Ephemeral
ProcessTwo
Parameters
Environment
User
WorkingDirectory
PivotRoot
Capability
NoNewPrivileges
KillSignal
Personality
MachineID
PrivateUsers
NotifyReady
SystemCallFilter
LimitCPU
OOMScoreAdjust
CPUAffinity
Hostname
ResolvConf
Timezone
LinkJournal
ReadOnly
Volatile
Bind
TemporaryFileSystem
Inaccessible
Overlay
PrivateUsersChown
Private
VirtualEthernet
VirtualEthernetExtra
Interface
MACVLAN
Bridge
Zone
Port

View File

@ -1,9 +1,9 @@
;;; systemd.el --- Major mode for editing systemd units -*- lexical-binding: t -*- ;;; systemd.el --- Major mode for editing systemd units -*- lexical-binding: t -*-
;; Copyright (C) 2014-2023 Mark Oteiza <mvoteiza@udel.edu> ;; Copyright (C) 2014-2016 Mark Oteiza <mvoteiza@udel.edu>
;; Author: Mark Oteiza <mvoteiza@udel.edu> ;; Author: Mark Oteiza <mvoteiza@udel.edu>
;; Version: 1.6.1 ;; Version: 1.4.1
;; Package-Requires: ((emacs "24.4")) ;; Package-Requires: ((emacs "24.4"))
;; Keywords: tools, unix ;; Keywords: tools, unix
@ -24,7 +24,7 @@
;; Major mode for editing systemd units. ;; Major mode for editing systemd units.
;; Similar to `conf-mode' but with enhanced highlighting; e.g. for ;; Similar to `conf-mode' but with added highlighting; e.g. for
;; specifiers and booleans. Employs strict regex for whitespace. ;; specifiers and booleans. Employs strict regex for whitespace.
;; Features a facility for browsing documentation: use C-c C-o to open ;; Features a facility for browsing documentation: use C-c C-o to open
;; links to documentation in a unit (cf. systemctl help). ;; links to documentation in a unit (cf. systemctl help).
@ -33,8 +33,7 @@
;; network configuration. Both a completer for ;; network configuration. Both a completer for
;; `completion-at-point-functions' and a company backend are provided. ;; `completion-at-point-functions' and a company backend are provided.
;; The latter can be enabled by adding `company-mode' to ;; The latter can be enabled by adding `company-mode' to
;; `systemd-mode-hook' and adding `systemd-company-backend' to ;; `systemd-mode-hook'.
;; `company-backends'.
;;; Code: ;;; Code:
@ -45,12 +44,9 @@
(declare-function company-begin-backend "company") (declare-function company-begin-backend "company")
(declare-function company-grab-symbol "company") (declare-function company-grab-symbol "company")
(defvar font-lock-beg)
(defvar font-lock-end)
(defgroup systemd () (defgroup systemd ()
"Major mode for editing systemd units." "Major mode for editing systemd units."
:link '(url-link "https://www.freedesktop.org/wiki/Software/systemd/") :link '(url-link "http://www.freedesktop.org/wiki/Software/systemd/")
:group 'tools) :group 'tools)
(defcustom systemd-browse-url-function 'browse-url (defcustom systemd-browse-url-function 'browse-url
@ -77,12 +73,12 @@
(defcustom systemd-mode-hook nil (defcustom systemd-mode-hook nil
"Hook run after entering `systemd-mode'." "Hook run after entering `systemd-mode'."
:type 'hook :type 'hook
:options '(company-mode flycheck-mode) :options '(company-mode)
:group 'systemd) :group 'systemd)
(defconst systemd-unit-sections (defconst systemd-unit-sections
'("Unit" "Install" "Service") '("Unit" "Install" "Service")
"Configuration sections for systemd 244.") "Configuration sections for systemd 225.")
(defconst systemd-unit-directives (defconst systemd-unit-directives
(eval-when-compile (eval-when-compile
@ -95,13 +91,10 @@
"Configuration directives for systemd.") "Configuration directives for systemd.")
(defconst systemd-network-sections (defconst systemd-network-sections
'("Match" "Link" "NetDev" "VLAN" "MACVLAN" "MACVTAP" "IPVLAN" "IPVTAP" "VXLAN" '("Match" "Link" "NetDev" "VLAN" "MACVLAN" "MACVTAP" "IPVLAN" "VXLAN"
"GENEVE" "L2TP" "L2TPsession" "MACsec" "FooOverUDP"
"Tunnel" "Peer" "Tun" "Tap" "Bond" "Network" "Address" "Route" "DHCP" "Tunnel" "Peer" "Tun" "Tap" "Bond" "Network" "Address" "Route" "DHCP"
"Neighbor" "IPv6AddressLabel" "RoutingPolicyRule" "NextHop" "DHCPv4" "Bridge" "BridgeFDB")
"DHCPv6" "IPv6AcceptRA" "DHCPServer" "IPv6Prefix" "CAN" "Network configuration sections for systemd 225.")
"Bridge" "BridgeFDB" "BridgeVLAN" "VXCAN" "WireGuard" "WireGuardPeer")
"Network configuration sections for systemd 244 (not exhaustive).")
(defconst systemd-network-directives (defconst systemd-network-directives
(eval-when-compile (eval-when-compile
@ -113,53 +106,44 @@
(split-string (buffer-string)))) (split-string (buffer-string))))
"Network configuration directives for systemd.") "Network configuration directives for systemd.")
(defconst systemd-nspawn-sections
'("Exec" "Files" "Network")
"Namespace container configuration sections for systemd 244.")
(defconst systemd-nspawn-directives
(eval-when-compile
(with-temp-buffer
(insert-file-contents
(let ((f "nspawn-directives.txt"))
(if (null load-file-name) f
(expand-file-name f (file-name-directory load-file-name)))))
(split-string (buffer-string))))
"Namespace container configuration directives for systemd.")
;;;###autoload ;;;###autoload
(defconst systemd-autoload-regexp (defconst systemd-autoload-regexp
(rx (+? (any "a-zA-Z0-9-_.@\\")) "." (eval-when-compile
(or "automount" "busname" "mount" "service" "slice" (rx (+? (any "a-zA-Z0-9-_.@\\")) "."
"socket" "swap" "target" "timer" "link" "netdev" "network") (or "automount" "busname" "mount" "service" "slice"
string-end) "socket" "swap" "target" "timer" "link" "netdev" "network")
string-end))
"Regexp for file buffers in which to autoload `systemd-mode'.") "Regexp for file buffers in which to autoload `systemd-mode'.")
;;;###autoload ;;;###autoload
(defconst systemd-tempfn-autoload-regexp (defconst systemd-tempfn-autoload-regexp
(rx ".#" (eval-when-compile
(or (and (+? (any "a-zA-Z0-9-_.@\\")) "." (rx ".#"
(or "automount" "busname" "mount" "service" "slice" (or (and (+? (any "a-zA-Z0-9-_.@\\")) "."
"socket" "swap" "target" "timer" "link" "netdev" "network")) (or "automount" "busname" "mount" "service" "slice"
"override.conf") "socket" "swap" "target" "timer" "link" "netdev" "network"))
(= 16 (char hex-digit)) string-end) "override.conf")
(= 16 (char hex-digit)) string-end))
"Regexp for temp file buffers in which to autoload `systemd-mode'.") "Regexp for temp file buffers in which to autoload `systemd-mode'.")
;;;###autoload ;;;###autoload
(defconst systemd-dropin-autoload-regexp (defconst systemd-dropin-autoload-regexp
(rx "/systemd/" (+? anything) ".d/" (+? (not (any ?/))) ".conf" string-end) (eval-when-compile
(rx "/systemd/" (+? anything) ".d/" (+? (not (any ?/))) ".conf" string-end))
"Regexp for dropin config file buffers in which to autoload `systemd-mode'.") "Regexp for dropin config file buffers in which to autoload `systemd-mode'.")
(defun systemd-get-value (start) (defun systemd-get-value (start)
"Return the value of the key whose value begins at position START. "Return the value of the key whose value begins at position START.
Lines ending in a backslash are concatenated with the next Lines ending in a backslash are concatenated with the next
according to systemd.unit(5)." according to systemd.unit(5)."
(let (end) (let ((break "\\\\\n")
end)
(save-excursion (save-excursion
(while (= (char-before (line-end-position)) ?\\) (while (progn (goto-char (1- (line-end-position)))
(looking-at break))
(forward-line)) (forward-line))
(setq end (line-end-position)) (setq end (line-end-position))
(replace-regexp-in-string "\\\\\n" " " (buffer-substring start end))))) (replace-regexp-in-string break " " (buffer-substring start end)))))
(defun systemd-doc-find () (defun systemd-doc-find ()
"Find the value of the unit's “Documentation” keys. "Find the value of the unit's “Documentation” keys.
@ -208,27 +192,22 @@ file, defaulting to the link under point, if any."
(defun systemd-buffer-section-p () (defun systemd-buffer-section-p ()
"Return t if current line begins with \"[\", otherwise nil." "Return t if current line begins with \"[\", otherwise nil."
(= (char-after (line-beginning-position)) ?\[)) (save-excursion
(beginning-of-line)
(looking-at "\\[")))
(defun systemd-file-network-p (filename) (defun systemd-buffer-network-p ()
"Return non-nil if FILENAME has a network-type extension, otherwise nil." "Return non-nil if `buffer-name' has a network-type extension, otherwise nil."
(string-match-p (rx "." (or "link" "netdev" "network") string-end) (string-match-p (eval-when-compile
filename)) (rx "." (or "link" "netdev" "network") string-end))
(buffer-name)))
(defun systemd-file-nspawn-p (filename)
"Return non-nil if FILENAME has an nspawn extension, otherwise nil."
(string-match-p (rx ".nspawn" string-end) filename))
(defun systemd-completion-table (&rest _ignore) (defun systemd-completion-table (&rest _ignore)
"Return a list of completion candidates." "Return a list of completion candidates."
(let ((sectionp (systemd-buffer-section-p)) (let ((sectionp (systemd-buffer-section-p)))
(name (buffer-name))) (if (systemd-buffer-network-p)
(cond (if sectionp systemd-network-sections systemd-network-directives)
((systemd-file-nspawn-p name) (if sectionp systemd-unit-sections systemd-unit-directives))))
(if sectionp systemd-nspawn-sections systemd-nspawn-directives))
((systemd-file-network-p name)
(if sectionp systemd-network-sections systemd-network-directives))
(t (if sectionp systemd-unit-sections systemd-unit-directives)))))
(defun systemd-complete-at-point () (defun systemd-complete-at-point ()
"Complete the symbol at point." "Complete the symbol at point."
@ -237,7 +216,7 @@ file, defaulting to the link under point, if any."
(or (cdr bounds) (point)) (or (cdr bounds) (point))
(completion-table-dynamic #'systemd-completion-table)))) (completion-table-dynamic #'systemd-completion-table))))
(defun systemd-company-backend (command &optional arg &rest _ignored) (defun systemd-company-backend (command &optional arg &rest ignored)
"Backend for `company-mode' in `systemd-mode' buffers." "Backend for `company-mode' in `systemd-mode' buffers."
(interactive (list 'interactive)) (interactive (list 'interactive))
(pcase command (pcase command
@ -246,130 +225,31 @@ file, defaulting to the link under point, if any."
(`candidates (all-completions arg (systemd-completion-table nil))) (`candidates (all-completions arg (systemd-completion-table nil)))
(`post-completion (if (not (systemd-buffer-section-p)) (insert "="))))) (`post-completion (if (not (systemd-buffer-section-p)) (insert "=")))))
(defun systemd-construct-start-p () (defvar systemd-font-lock-keywords
"Return non-nil if the current line is the first in a multi-line construct." (eval-when-compile
(let ((flag t)) `(("^[[:space:]]*?\\([#;]\\)\\(.*\\)$"
(save-excursion (1 'font-lock-comment-delimiter-face)
(while (and (zerop (forward-line -1)) (2 'font-lock-comment-face))
(eq ?\\ (char-before (line-end-position))) ("\\\\$" 0 'font-lock-warning-face) ; line break
(skip-chars-forward " \t") ;; sections
(setq flag (memq (following-char) '(?# ?\;)))))) ("^\\(\\[\\([[:upper:]][[:alnum:]]+\\|X-.*?\\)\\]\\)"
flag)) 1 'font-lock-type-face)
;; keys
(defun systemd-syntax-propertize (start end) ("^\\([[:upper:]][[:alnum:]]+\\)="
"`systemd-propertize-function' for `systemd-mode' buffers." 1 'font-lock-keyword-face)
(let ((case-fold-search nil)) ;; boolean arguments
(goto-char start) (,(rx "=" (group (or "yes" "true" "on" "0" "no" "false" "off")) eol)
(funcall 1 'font-lock-constant-face)
(syntax-propertize-rules ;; specifiers
("^[ \t]*\\([;#]\\)$?" ("%[nNpPiIfcrRtuUhsmbHv%]" 0 'font-lock-constant-face)
(1 (when (systemd-construct-start-p) (string-to-syntax "<"))))) ;; exec prefixes
start end))) ("=\\(-@\\|@-\\|[@-]\\)" 1 'font-lock-negation-char-face)))
(defun systemd-value-extend-region ()
"Return the EOL position of the last line of the construct at point."
(while (and (= (char-before (line-end-position)) ?\\)
(skip-chars-forward " \t")
(not (memq (following-char) '(?# ?\;)))
(zerop (forward-line))))
(line-end-position))
(defun systemd-font-lock-extend-region ()
(goto-char font-lock-beg)
(while (and (zerop (forward-line -1))
(= (char-before (line-end-position)) ?\\)
(skip-chars-forward " \t")
(not (memq (following-char) '(?# ?\;)))))
(setq font-lock-beg (point-marker))
(goto-char font-lock-end)
(setq font-lock-end (systemd-value-extend-region)))
(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-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.
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 (remq char prefixes))
(setq end (point-marker)))
(when end
(prog1 (setq res (list (1+ pos) end))
(set-match-data res)))))
(defconst systemd-font-lock-keywords-1
'((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
`(,@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)
("="
;; exec prefixes
(systemd-exec-prefix-anchored-matcher
nil nil (0 'font-lock-negation-char-face))
;; environment variables
("\\$[A-Z_]+\\>"
(systemd-value-extend-region) nil (0 'font-lock-variable-name-face))
;; specifiers
("%[abBCEfgGhHiIjJlLmnNopPrRsStTuUvVw%]"
(systemd-value-extend-region) nil (0 'font-lock-constant-face))))
"Extended expressions to highlight in `systemd-mode'.")
(defconst systemd-font-lock-keywords-3
`(,@systemd-font-lock-keywords-2
("^Type=\\(simple\\|forking\\|oneshot\\|dbus\\|notify\\|idle\\)$"
1 'font-lock-builtin-face)
(,(rx bol "Restart="
(group (or "no" "on-success" "on-failure"
"on-abnormal" "on-watchdog" "on-abort" "always"))
eol)
1 'font-lock-builtin-face)
("^KillMode=\\(control-group\\|process\\|mixed\\|none\\)$"
1 'font-lock-builtin-face)
(,(rx bol "KillSignal="
(group
(or "SIGHUP" "SIGINT" "SIGQUIT" "SIGILL" "SIGABRT" "SIGFPE" "SIGKILL"
"SIGSEGV" "SIGPIPE" "SIGALRM" "SIGTERM" "SIGUSR1" "SIGUSR2"
"SIGCHLD" "SIGCONT" "SIGSTOP" "SIGTSTP" "SIGTTIN" "SIGTTOU"))
eol)
1 'font-lock-constant-face))
"Flamboyant expressions to highlight in `systemd-mode'.")
(defvar systemd-font-lock-keywords 'systemd-font-lock-keywords-2
"Default expressions to highlight in `systemd-mode'. "Default expressions to highlight in `systemd-mode'.
See systemd.unit(5) for details on unit file syntax.") See systemd.unit(5) for details on unit file syntax.")
(defvar systemd-mode-syntax-table (defvar systemd-mode-syntax-table
(let ((table (make-syntax-table))) (let ((table (make-syntax-table)))
(modify-syntax-entry ?% "/" table) (modify-syntax-entry ?\% "\\" table)
(modify-syntax-entry ?$ "'" table)
(modify-syntax-entry ?\; "." table)
table) table)
"Syntax table used in `systemd-mode' buffers.") "Syntax table used in `systemd-mode' buffers.")
@ -388,7 +268,6 @@ See systemd.unit(5) for details on unit file syntax.")
["Open systemd.directives(7)" systemd-doc-directives ["Open systemd.directives(7)" systemd-doc-directives
:help "Index of configuration directives"])) :help "Index of configuration directives"]))
;;;###autoload (add-to-list 'auto-mode-alist '("\\.nspawn\\'" . systemd-mode))
;;;###autoload (add-to-list 'auto-mode-alist `(,systemd-autoload-regexp . 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 (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 (add-to-list 'auto-mode-alist `(,systemd-dropin-autoload-regexp . systemd-mode))
@ -396,7 +275,7 @@ See systemd.unit(5) for details on unit file syntax.")
;;;###autoload ;;;###autoload
(define-derived-mode systemd-mode conf-mode "Systemd" (define-derived-mode systemd-mode conf-mode "Systemd"
"Major mode for editing systemd unit files. "Major mode for editing systemd unit files.
See https://www.freedesktop.org/wiki/Software/systemd/ for more See http://www.freedesktop.org/wiki/Software/systemd/ for more
information about systemd. information about systemd.
In addition to any hooks its parent mode might have run, this In addition to any hooks its parent mode might have run, this
@ -406,16 +285,9 @@ Key bindings:
\\{systemd-mode-map}" \\{systemd-mode-map}"
(set-keymap-parent systemd-mode-map nil) (set-keymap-parent systemd-mode-map nil)
(conf-mode-initialize systemd-comment-start) (conf-mode-initialize systemd-comment-start)
(setq-local auto-fill-inhibit-regexp "^[ \t]*?[^;#]") (add-hook 'company-backends #'systemd-company-backend nil)
(add-hook 'completion-at-point-functions #'systemd-complete-at-point nil t) (add-hook 'completion-at-point-functions #'systemd-complete-at-point nil t)
(add-hook 'font-lock-extend-region-functions (setq font-lock-defaults '(systemd-font-lock-keywords t)))
'systemd-font-lock-extend-region nil t)
(setq-local syntax-propertize-function #'systemd-syntax-propertize)
(setq font-lock-defaults
'((systemd-font-lock-keywords
systemd-font-lock-keywords-1
systemd-font-lock-keywords-2
systemd-font-lock-keywords-3))))
(provide 'systemd) (provide 'systemd)

View File

@ -1,6 +1,6 @@
;;; systemd-tests.el --- Tests for systemd.el -*- lexical-binding: t -*- ;;; systemd-tests.el --- Tests for systemd.el -*- lexical-binding: t -*-
;; Copyright (C) 2016-2020 Mark Oteiza <mvoteiza@udel.edu> ;; Copyright (C) 2016 Mark Oteiza <mvoteiza@udel.edu>
;; Author: Mark Oteiza <mvoteiza@udel.edu> ;; Author: Mark Oteiza <mvoteiza@udel.edu>
@ -83,3 +83,4 @@ only if in an appropriately named parent directory."
(provide 'systemd-tests) (provide 'systemd-tests)
;;; systemd-tests.el ends here ;;; systemd-tests.el ends here

View File

@ -3,23 +3,18 @@ AccuracySec
After After
Alias Alias
AllowIsolate AllowIsolate
AllowedCPUs
AllowedMemoryNodes
Also Also
AmbientCapabilities AmbientCapabilities
AppArmorProfile AppArmorProfile
AssertACPower AssertACPower
AssertArchitecture AssertArchitecture
AssertCapability AssertCapability
AssertControlGroupController
AssertDirectoryNotEmpty AssertDirectoryNotEmpty
AssertFileIsExecutable AssertFileIsExecutable
AssertFileNotEmpty AssertFileNotEmpty
AssertFirstBoot AssertFirstBoot
AssertGroup
AssertHost AssertHost
AssertKernelCommandLine AssertKernelCommandLine
AssertKernelVersion
AssertNeedsUpdate AssertNeedsUpdate
AssertPathExists AssertPathExists
AssertPathExistsGlob AssertPathExistsGlob
@ -28,13 +23,10 @@ AssertPathIsMountPoint
AssertPathIsReadWrite AssertPathIsReadWrite
AssertPathIsSymbolicLink AssertPathIsSymbolicLink
AssertSecurity AssertSecurity
AssertUser
AssertVirtualization AssertVirtualization
Backlog Backlog
Before Before
BindIPv6Only BindIPv6Only
BindPaths
BindReadOnlyPaths
BindToDevice BindToDevice
BindsTo BindsTo
BlockIOAccounting BlockIOAccounting
@ -47,30 +39,20 @@ BusName
CPUAccounting CPUAccounting
CPUAffinity CPUAffinity
CPUQuota CPUQuota
CPUQuotaPeriodSec
CPUSchedulingPolicy CPUSchedulingPolicy
CPUSchedulingPriority CPUSchedulingPriority
CPUSchedulingResetOnFork CPUSchedulingResetOnFork
CPUShares CPUShares
CPUWeight
CacheDirectory
CacheDirectoryMode
CapabilityBoundingSet CapabilityBoundingSet
CollectMode
ConditionACPower ConditionACPower
ConditionArchitecture ConditionArchitecture
ConditionCPUs
ConditionCapability ConditionCapability
ConditionControlGroupController
ConditionDirectoryNotEmpty ConditionDirectoryNotEmpty
ConditionFileIsExecutable ConditionFileIsExecutable
ConditionFileNotEmpty ConditionFileNotEmpty
ConditionFirstBoot ConditionFirstBoot
ConditionGroup
ConditionHost ConditionHost
ConditionKernelCommandLine ConditionKernelCommandLine
ConditionKernelVersion
ConditionMemory
ConditionNeedsUpdate ConditionNeedsUpdate
ConditionPathExists ConditionPathExists
ConditionPathExistsGlob ConditionPathExistsGlob
@ -79,10 +61,7 @@ ConditionPathIsMountPoint
ConditionPathIsReadWrite ConditionPathIsReadWrite
ConditionPathIsSymbolicLink ConditionPathIsSymbolicLink
ConditionSecurity ConditionSecurity
ConditionUser
ConditionVirtualization ConditionVirtualization
ConfigurationDirectory
ConfigurationDirectoryMode
Conflicts Conflicts
DefaultDependencies DefaultDependencies
DefaultInstance DefaultInstance
@ -93,12 +72,9 @@ DeviceAllow
DevicePolicy DevicePolicy
DirectoryMode DirectoryMode
DirectoryNotEmpty DirectoryNotEmpty
DisableControllers
Documentation Documentation
DynamicUser
Environment Environment
EnvironmentFile EnvironmentFile
ExecCondition
ExecReload ExecReload
ExecStart ExecStart
ExecStartPost ExecStartPost
@ -107,16 +83,12 @@ ExecStop
ExecStopPost ExecStopPost
ExecStopPre ExecStopPre
FailureAction FailureAction
FailureActionExitStatus
FileDescriptorName FileDescriptorName
FileDescriptorStoreMax FileDescriptorStoreMax
FinalKillSignal
ForceUnmount
FreeBind FreeBind
Group Group
GuessMainPID GuessMainPID
IOAccounting IOAccounting
IODeviceLatencyTargetSec
IODeviceWeight IODeviceWeight
IOReadBandwidthMax IOReadBandwidthMax
IOReadIOPSMax IOReadIOPSMax
@ -125,17 +97,11 @@ IOSchedulingPriority
IOWeight IOWeight
IOWriteBandwidthMax IOWriteBandwidthMax
IOWriteIOPSMax IOWriteIOPSMax
IPAccounting
IPAddressAllow
IPAddressDeny
IPEgressFilterPath
IPIngressFilterPath
IPTOS IPTOS
IPTTL IPTTL
IgnoreOnIsolate IgnoreOnIsolate
IgnoreSIGPIPE IgnoreSIGPIPE
InaccessiblePaths InaccessiblePaths
JobRunningTimeoutSec
JobTimeoutAction JobTimeoutAction
JobTimeoutRebootArgument JobTimeoutRebootArgument
JobTimeoutSec JobTimeoutSec
@ -144,10 +110,8 @@ KeepAlive
KeepAliveIntervalSec KeepAliveIntervalSec
KeepAliveProbes KeepAliveProbes
KeepAliveTimeSec KeepAliveTimeSec
KeyringMode
KillMode KillMode
KillSignal KillSignal
LazyUnmount
LimitAS LimitAS
LimitCORE LimitCORE
LimitCPU LimitCPU
@ -172,47 +136,30 @@ ListenSequentialPacket
ListenSpecial ListenSpecial
ListenStream ListenStream
ListenUSBFunction ListenUSBFunction
LockPersonality
LogExtraFields
LogLevelMax
LogRateLimitBurst
LogRateLimitIntervalSec
LogsDirectory
LogsDirectoryMode
MakeDirectory MakeDirectory
Mark Mark
MaxConnections MaxConnections
MaxConnectionsPerSource
MemoryAccounting MemoryAccounting
MemoryDenyWriteExecute MemoryDenyWriteExecute
MemoryHigh MemoryHigh
MemoryLimit MemoryLimit
MemoryLow MemoryLow
MemoryMax MemoryMax
MemoryMin
MemorySwapMax
MessageQueueMaxMessages MessageQueueMaxMessages
MessageQueueMessageSize MessageQueueMessageSize
MountAPIVFS
MountFlags MountFlags
NUMAMask
NUMAPolicy
NetworkNamespacePath
Nice Nice
NoDelay NoDelay
NoNewPrivileges NoNewPrivileges
NonBlocking NonBlocking
NotifyAccess NotifyAccess
OOMPolicy
OOMScoreAdjust OOMScoreAdjust
OnActiveSec OnActiveSec
OnBootSec OnBootSec
OnCalendar OnCalendar
OnClockChange
OnFailure OnFailure
OnFailureJobMode OnFailureJobMode
OnStartupSec OnStartupSec
OnTimezoneChange
OnUnitActiveSec OnUnitActiveSec
OnUnitInactiveSec OnUnitInactiveSec
Options Options
@ -226,22 +173,16 @@ PathChanged
PathExists PathExists
PathExistsGlob PathExistsGlob
PathModified PathModified
PermissionsStartOnly
Persistent Persistent
Personality Personality
PipeSize PipeSize
Priority Priority
PrivateDevices PrivateDevices
PrivateMounts
PrivateNetwork PrivateNetwork
PrivateTmp PrivateTmp
PrivateUsers
PropagatesReloadTo PropagatesReloadTo
ProtectControlGroups
ProtectHome ProtectHome
ProtectHostname
ProtectKernelLogs
ProtectKernelModules
ProtectKernelTunables
ProtectSystem ProtectSystem
RandomizedDelaySec RandomizedDelaySec
ReadOnlyPaths ReadOnlyPaths
@ -253,7 +194,6 @@ RefuseManualStop
ReloadPropagatedFrom ReloadPropagatedFrom
RemainAfterElapse RemainAfterElapse
RemainAfterExit RemainAfterExit
RemoveIPC
RemoveOnStop RemoveOnStop
RequiredBy RequiredBy
Requires Requires
@ -261,20 +201,15 @@ RequiresMountsFor
Requisite Requisite
Restart Restart
RestartForceExitStatus RestartForceExitStatus
RestartKillSignal
RestartPreventExitStatus RestartPreventExitStatus
RestartSec RestartSec
RestrictAddressFamilies RestrictAddressFamilies
RestrictNamespaces
RestrictRealtime RestrictRealtime
RestrictSUIDSGID
ReusePort ReusePort
RootDirectory RootDirectory
RootDirectoryStartOnly RootDirectoryStartOnly
RootImage
RuntimeDirectory RuntimeDirectory
RuntimeDirectoryMode RuntimeDirectoryMode
RuntimeDirectoryPreserve
RuntimeMaxSec RuntimeMaxSec
SELinuxContext SELinuxContext
SELinuxContextFromNet SELinuxContextFromNet
@ -297,21 +232,14 @@ Sockets
SourcePath SourcePath
StandardError StandardError
StandardInput StandardInput
StandardInputData
StandardInputText
StandardOutput StandardOutput
StartLimitAction StartLimitAction
StartLimitBurst StartLimitBurst
StartLimitIntervalSec StartLimitIntervalSec
StartupBlockIOWeight StartupBlockIOWeight
StartupCPUShares StartupCPUShares
StartupCPUWeight
StartupIOWeight StartupIOWeight
StateDirectory
StateDirectoryMode
StopWhenUnneeded StopWhenUnneeded
SuccessAction
SuccessActionExitStatus
SuccessExitStatus SuccessExitStatus
SupplementaryGroups SupplementaryGroups
Symlinks Symlinks
@ -329,9 +257,6 @@ TTYVHangup
TTYVTDisallocate TTYVTDisallocate
TasksAccounting TasksAccounting
TasksMax TasksMax
TemporaryFileSystem
TimeoutAbortSec
TimeoutCleanSec
TimeoutIdleSec TimeoutIdleSec
TimeoutSec TimeoutSec
TimeoutStartSec TimeoutStartSec
@ -345,7 +270,6 @@ UMask
USBFunctionDescriptors USBFunctionDescriptors
USBFunctionStrings USBFunctionStrings
Unit Unit
UnsetEnvironment
User User
UtmpIdentifier UtmpIdentifier
UtmpMode UtmpMode
@ -353,7 +277,6 @@ WakeSystem
WantedBy WantedBy
Wants Wants
WatchdogSec WatchdogSec
WatchdogSignal
What What
Where Where
WorkingDirectory WorkingDirectory