Compare commits

..

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

7 changed files with 76 additions and 404 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 nspawn-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

@ -2,56 +2,35 @@ ARP
ARPAllTargets ARPAllTargets
ARPIPTargets ARPIPTargets
ARPIntervalSec ARPIntervalSec
ARPProxy
ARPValidate ARPValidate
Activate
ActiveSlave
AdActorSystem
AdActorSystemPriority
AdSelect AdSelect
AdUserPortKey
Address Address
AddressAutoconfiguration
Advertise
AgeingTimeSec AgeingTimeSec
Alias
AllMulticast
AllSlavesActive AllSlavesActive
AllowLocalRemote
AllowPortToBeRoot AllowPortToBeRoot
AllowedIPs
Anonymize
Architecture Architecture
AssignToLoopback
AssociatedWith
AutoJoin 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
DNSStubListener
DUIDRawData DUIDRawData
DUIDType DUIDType
DefaultLeaseTimeSec DefaultLeaseTimeSec
DefaultPVID
DefaultRouteOnDevice
Description Description
DefaultPVID
Destination Destination
DestinationPort DestinationPort
DiscoverPathMTU DiscoverPathMTU
@ -60,44 +39,23 @@ DownDelaySec
Driver Driver
Duplex Duplex
DuplicateAddressDetection 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 GenericReceiveOffload
GenericSegmentationOffload GenericSegmentationOffload
GratuitousARP GratuitousARP
Group
GroupForwardMask
GroupPolicyExtension GroupPolicyExtension
HairPin HairPin
HelloTimeSec HelloTimeSec
@ -105,42 +63,19 @@ 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
@ -149,168 +84,84 @@ LLDP
LLMNR LLMNR
Label Label
LargeReceiveOffload 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 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 PrefixRoute
PresharedKey
PresharedKeyFile
PrimaryReselectPolicy PrimaryReselectPolicy
PrimarySlave
Priority
PrivateKey
PrivateKeyFile
Property
Protocol
ProxyARP ProxyARP
ProxyARPWiFi
PublicKey
QuickAck
RapidCommit
ReduceARPProxy
Remote Remote
RemoteChecksumRx RemoteChecksumRx
RemoteChecksumTx RemoteChecksumTx
ReorderHeader
RequestBroadcast RequestBroadcast
RequestOptions
RequiredForOnline
ResendIGMP ResendIGMP
RestartSec
Route
RouteMetric RouteMetric
RouteShortCircuit RouteShortCircuit
RouteTable RouteTable
RouterLifetimeSec
RouterPreference
RoutesToDNS
RxBufferSize
RxChannels
SSID
STP STP
SamplePoint
Scope Scope
SendHostname SendHostname
SendOption
SendRelease
SerializeTunneledPackets
SessionId
Source Source
SourcePort
TCP6SegmentationOffload
TCPSegmentationOffload TCPSegmentationOffload
TOS TOS
TTL TTL
TTLPropagate
Table Table
Timezone Timezone
To
TransmitHashPolicy TransmitHashPolicy
TripleSampling
Tunnel Tunnel
TunnelId
TxBufferSize
TxChannels
Type
TypeOfService
UDP6ZeroChecksumRx UDP6ZeroChecksumRx
UDP6ZeroChecksumTx UDP6ZeroChecksumTx
UDPChecksum UDPChecksum
UDPSourcePort UDPSegmentationOffload
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 +1,28 @@
Boot Boot
Ephemeral
ProcessTwo ProcessTwo
Parameters Parameters
Environment Environment
User User
WorkingDirectory WorkingDirectory
PivotRoot
Capability Capability
NoNewPrivileges DropCapability
KillSignal KillSignal
Personality Personality
MachineID MachineID
PrivateUsers PrivateUsers
NotifyReady NotifyReady
SystemCallFilter
LimitCPU
OOMScoreAdjust
CPUAffinity
Hostname
ResolvConf
Timezone
LinkJournal
ReadOnly ReadOnly
Volatile Volatile
Bind Bind
BindReadOnly
TemporaryFileSystem TemporaryFileSystem
Inaccessible
Overlay
PrivateUsersChown PrivateUsersChown
Private Private
VirtualEthernet VirtualEthernet
VirtualEthernetExtra VirtualEthernetExtra
Interface Interface
MACVLAN MACVLAN
IPVLAN
Bridge Bridge
Zone Zone
Port 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-2017 Mark Oteiza <mvoteiza@udel.edu>
;; Author: Mark Oteiza <mvoteiza@udel.edu> ;; Author: Mark Oteiza <mvoteiza@udel.edu>
;; Version: 1.6.1 ;; Version: 1.5
;; 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
@ -82,7 +78,7 @@
(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
@ -115,7 +108,7 @@
(defconst systemd-nspawn-sections (defconst systemd-nspawn-sections
'("Exec" "Files" "Network") '("Exec" "Files" "Network")
"Namespace container configuration sections for systemd 244.") "Namespace container configuration sections for systemd 232.")
(defconst systemd-nspawn-directives (defconst systemd-nspawn-directives
(eval-when-compile (eval-when-compile
@ -129,25 +122,28 @@
;;;###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)
@ -208,16 +204,19 @@ 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)
(= (following-char) ?\[)))
(defun systemd-file-network-p (filename) (defun systemd-file-network-p (filename)
"Return non-nil if FILENAME has a network-type extension, otherwise nil." "Return non-nil if FILENAME has a network-type extension, otherwise nil."
(string-match-p (rx "." (or "link" "netdev" "network") string-end) (string-match-p (eval-when-compile
(rx "." (or "link" "netdev" "network") string-end))
filename)) filename))
(defun systemd-file-nspawn-p (filename) (defun systemd-file-nspawn-p (filename)
"Return non-nil if FILENAME has an nspawn extension, otherwise nil." "Return non-nil if FILENAME has an nspawn extension, otherwise nil."
(string-match-p (rx ".nspawn" string-end) filename)) (string-match-p (eval-when-compile (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."
@ -237,7 +236,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 +245,32 @@ 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))) ;; TODO account for @ being a prefix now
("=\\(-@\\|@-\\|[@-]\\)" 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.")
@ -396,7 +297,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 +307,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)
(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-2017 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,21 @@ BusName
CPUAccounting CPUAccounting
CPUAffinity CPUAffinity
CPUQuota CPUQuota
CPUQuotaPeriodSec
CPUSchedulingPolicy CPUSchedulingPolicy
CPUSchedulingPriority CPUSchedulingPriority
CPUSchedulingResetOnFork CPUSchedulingResetOnFork
CPUShares CPUShares
CPUWeight 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 +62,7 @@ ConditionPathIsMountPoint
ConditionPathIsReadWrite ConditionPathIsReadWrite
ConditionPathIsSymbolicLink ConditionPathIsSymbolicLink
ConditionSecurity ConditionSecurity
ConditionUser
ConditionVirtualization ConditionVirtualization
ConfigurationDirectory
ConfigurationDirectoryMode
Conflicts Conflicts
DefaultDependencies DefaultDependencies
DefaultInstance DefaultInstance
@ -93,12 +73,10 @@ DeviceAllow
DevicePolicy DevicePolicy
DirectoryMode DirectoryMode
DirectoryNotEmpty DirectoryNotEmpty
DisableControllers
Documentation Documentation
DynamicUser DynamicUser
Environment Environment
EnvironmentFile EnvironmentFile
ExecCondition
ExecReload ExecReload
ExecStart ExecStart
ExecStartPost ExecStartPost
@ -107,16 +85,13 @@ ExecStop
ExecStopPost ExecStopPost
ExecStopPre ExecStopPre
FailureAction FailureAction
FailureActionExitStatus
FileDescriptorName FileDescriptorName
FileDescriptorStoreMax FileDescriptorStoreMax
FinalKillSignal
ForceUnmount ForceUnmount
FreeBind FreeBind
Group Group
GuessMainPID GuessMainPID
IOAccounting IOAccounting
IODeviceLatencyTargetSec
IODeviceWeight IODeviceWeight
IOReadBandwidthMax IOReadBandwidthMax
IOReadIOPSMax IOReadIOPSMax
@ -125,17 +100,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,7 +113,6 @@ KeepAlive
KeepAliveIntervalSec KeepAliveIntervalSec
KeepAliveProbes KeepAliveProbes
KeepAliveTimeSec KeepAliveTimeSec
KeyringMode
KillMode KillMode
KillSignal KillSignal
LazyUnmount LazyUnmount
@ -172,13 +140,6 @@ ListenSequentialPacket
ListenSpecial ListenSpecial
ListenStream ListenStream
ListenUSBFunction ListenUSBFunction
LockPersonality
LogExtraFields
LogLevelMax
LogRateLimitBurst
LogRateLimitIntervalSec
LogsDirectory
LogsDirectoryMode
MakeDirectory MakeDirectory
Mark Mark
MaxConnections MaxConnections
@ -189,30 +150,22 @@ MemoryHigh
MemoryLimit MemoryLimit
MemoryLow MemoryLow
MemoryMax MemoryMax
MemoryMin
MemorySwapMax 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,20 +179,18 @@ PathChanged
PathExists PathExists
PathExistsGlob PathExistsGlob
PathModified PathModified
PermissionsStartOnly
Persistent Persistent
Personality Personality
PipeSize PipeSize
Priority Priority
PrivateDevices PrivateDevices
PrivateMounts
PrivateNetwork PrivateNetwork
PrivateTmp PrivateTmp
PrivateUsers PrivateUsers
PropagatesReloadTo PropagatesReloadTo
ProtectControlGroups ProtectControlGroups
ProtectHome ProtectHome
ProtectHostname
ProtectKernelLogs
ProtectKernelModules ProtectKernelModules
ProtectKernelTunables ProtectKernelTunables
ProtectSystem ProtectSystem
@ -261,20 +212,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,8 +243,6 @@ Sockets
SourcePath SourcePath
StandardError StandardError
StandardInput StandardInput
StandardInputData
StandardInputText
StandardOutput StandardOutput
StartLimitAction StartLimitAction
StartLimitBurst StartLimitBurst
@ -307,11 +251,7 @@ StartupBlockIOWeight
StartupCPUShares StartupCPUShares
StartupCPUWeight StartupCPUWeight
StartupIOWeight StartupIOWeight
StateDirectory
StateDirectoryMode
StopWhenUnneeded StopWhenUnneeded
SuccessAction
SuccessActionExitStatus
SuccessExitStatus SuccessExitStatus
SupplementaryGroups SupplementaryGroups
Symlinks Symlinks
@ -329,9 +269,6 @@ TTYVHangup
TTYVTDisallocate TTYVTDisallocate
TasksAccounting TasksAccounting
TasksMax TasksMax
TemporaryFileSystem
TimeoutAbortSec
TimeoutCleanSec
TimeoutIdleSec TimeoutIdleSec
TimeoutSec TimeoutSec
TimeoutStartSec TimeoutStartSec
@ -345,7 +282,6 @@ UMask
USBFunctionDescriptors USBFunctionDescriptors
USBFunctionStrings USBFunctionStrings
Unit Unit
UnsetEnvironment
User User
UtmpIdentifier UtmpIdentifier
UtmpMode UtmpMode
@ -353,7 +289,6 @@ WakeSystem
WantedBy WantedBy
Wants Wants
WatchdogSec WatchdogSec
WatchdogSignal
What What
Where Where
WorkingDirectory WorkingDirectory