Compare commits

...

16 Commits
v1.6 ... master

Author SHA1 Message Date
Mark Oteiza
8742607120 stop clobbering company-backends
* using add-hook to modify company-backends is bad juju
* there does not appear to be a sensible way for a mode to
  modify company-backends either in the variable docstring or the
  online documentation here

https://company-mode.github.io/manual/Backends.html

  so... we should not modify it.
* document the added effort to use the company backend
* the only additional fanciness to `systemd-company-backend' is that
  it will automatically insert an = after completing a directive, so
  it might be nice to work that into the capf completion somehow and
  trash the company-specific code
2023-01-31 22:02:07 -05:00
Mark Oteiza
964ec9d4e0 happy new year 2023-01-31 21:55:06 -05:00
Mark Oteiza
b6ae63a236 add specifiers (leave obsoleted ones in for now) 2021-02-09 15:52:26 -05:00
Mark Oteiza
0416fe454a drop some unneeded eval-when-compile 2021-02-09 15:52:05 -05:00
Mark Oteiza
20c9d97e24 happy new year 2021-02-09 15:51:44 -05:00
Mark Oteiza
ec8f6cfe9d happy new year 2020-01-30 13:29:39 -05:00
Mark Oteiza
51c148e09a update urls
drop mention of marmalade
2019-12-19 18:04:45 -05:00
Mark Oteiza
9265ef89ff update section lists
there are very many different specialized network sections now.  only
a subset of them have been added here
2019-12-19 18:03:47 -05:00
Mark Oteiza
077aedde23 systemd 244 directives
network stuff is getting split up across a bunch of different sections
which is annoying.  dnssec files are a thing now as well.  finding
a better way to do this would be nice
2019-12-19 18:01:39 -05:00
stardiviner
a9f82b1f8b add systemd-mode company backend buffer locally 2019-11-17 11:14:46 -05:00
Mark Oteiza
c6e06dfa93 happy new year 2019-01-01 04:23:36 -05:00
Lucas Werkmeister
401d71c2dd Add %E, %j, %J, %T, %V specifiers
These specifiers were added in systemd v239.
2018-06-29 17:06:22 -04:00
Lucas Werkmeister
21d50f27d8 Sort specifiers alphabetically
The systemd.unit(5) manpage sorts unit file specifiers alphabetically
since commit systemd/systemd@709f4c472c, and since the order in this
regular expression is even less relevant than in the manpage, let’s just
do the same to make it easy to compare the letter sets between the two.
2018-06-29 17:06:13 -04:00
Lucas Werkmeister
e97f78ee11 Add %S, %C, %L specifiers
These specifiers for the state, cache, and log directory root were added in systemd v236.
2018-04-14 14:11:36 -04:00
Mark Oteiza
228f0b99ca happy new year 2018-01-01 21:03:40 -05:00
Mark Oteiza
22f024fe8f systemd 235 2017-10-06 16:52:43 -04:00
6 changed files with 240 additions and 44 deletions

3
README
View File

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

View File

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

View File

@ -1,4 +1,5 @@
Boot
Ephemeral
ProcessTwo
Parameters
Environment
@ -6,15 +7,25 @@ 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

View File

@ -1,9 +1,9 @@
;;; systemd.el --- Major mode for editing systemd units -*- lexical-binding: t -*-
;; Copyright (C) 2014-2017 Mark Oteiza <mvoteiza@udel.edu>
;; Copyright (C) 2014-2023 Mark Oteiza <mvoteiza@udel.edu>
;; Author: Mark Oteiza <mvoteiza@udel.edu>
;; Version: 1.6
;; Version: 1.6.1
;; Package-Requires: ((emacs "24.4"))
;; Keywords: tools, unix
@ -33,7 +33,8 @@
;; network configuration. Both a completer for
;; `completion-at-point-functions' and a company backend are provided.
;; The latter can be enabled by adding `company-mode' to
;; `systemd-mode-hook'.
;; `systemd-mode-hook' and adding `systemd-company-backend' to
;; `company-backends'.
;;; Code:
@ -49,7 +50,7 @@
(defgroup systemd ()
"Major mode for editing systemd units."
:link '(url-link "http://www.freedesktop.org/wiki/Software/systemd/")
:link '(url-link "https://www.freedesktop.org/wiki/Software/systemd/")
:group 'tools)
(defcustom systemd-browse-url-function 'browse-url
@ -81,7 +82,7 @@
(defconst systemd-unit-sections
'("Unit" "Install" "Service")
"Configuration sections for systemd 225.")
"Configuration sections for systemd 244.")
(defconst systemd-unit-directives
(eval-when-compile
@ -94,10 +95,13 @@
"Configuration directives for systemd.")
(defconst systemd-network-sections
'("Match" "Link" "NetDev" "VLAN" "MACVLAN" "MACVTAP" "IPVLAN" "VXLAN"
'("Match" "Link" "NetDev" "VLAN" "MACVLAN" "MACVTAP" "IPVLAN" "IPVTAP" "VXLAN"
"GENEVE" "L2TP" "L2TPsession" "MACsec" "FooOverUDP"
"Tunnel" "Peer" "Tun" "Tap" "Bond" "Network" "Address" "Route" "DHCP"
"Bridge" "BridgeFDB")
"Network configuration sections for systemd 225.")
"Neighbor" "IPv6AddressLabel" "RoutingPolicyRule" "NextHop" "DHCPv4"
"DHCPv6" "IPv6AcceptRA" "DHCPServer" "IPv6Prefix" "CAN"
"Bridge" "BridgeFDB" "BridgeVLAN" "VXCAN" "WireGuard" "WireGuardPeer")
"Network configuration sections for systemd 244 (not exhaustive).")
(defconst systemd-network-directives
(eval-when-compile
@ -111,7 +115,7 @@
(defconst systemd-nspawn-sections
'("Exec" "Files" "Network")
"Namespace container configuration sections for systemd 232.")
"Namespace container configuration sections for systemd 244.")
(defconst systemd-nspawn-directives
(eval-when-compile
@ -125,28 +129,25 @@
;;;###autoload
(defconst systemd-autoload-regexp
(eval-when-compile
(rx (+? (any "a-zA-Z0-9-_.@\\")) "."
(or "automount" "busname" "mount" "service" "slice"
"socket" "swap" "target" "timer" "link" "netdev" "network")
string-end))
string-end)
"Regexp for file buffers in which to autoload `systemd-mode'.")
;;;###autoload
(defconst systemd-tempfn-autoload-regexp
(eval-when-compile
(rx ".#"
(or (and (+? (any "a-zA-Z0-9-_.@\\")) "."
(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'.")
;;;###autoload
(defconst systemd-dropin-autoload-regexp
(eval-when-compile
(rx "/systemd/" (+? anything) ".d/" (+? (not (any ?/))) ".conf" string-end))
(rx "/systemd/" (+? anything) ".d/" (+? (not (any ?/))) ".conf" string-end)
"Regexp for dropin config file buffers in which to autoload `systemd-mode'.")
(defun systemd-get-value (start)
@ -211,13 +212,12 @@ file, defaulting to the link under point, if any."
(defun systemd-file-network-p (filename)
"Return non-nil if FILENAME has a network-type extension, otherwise nil."
(string-match-p (eval-when-compile
(rx "." (or "link" "netdev" "network") string-end))
(string-match-p (rx "." (or "link" "netdev" "network") string-end)
filename))
(defun systemd-file-nspawn-p (filename)
"Return non-nil if FILENAME has an nspawn extension, otherwise nil."
(string-match-p (eval-when-compile (rx ".nspawn" string-end)) filename))
(string-match-p (rx ".nspawn" string-end) filename))
(defun systemd-completion-table (&rest _ignore)
"Return a list of completion candidates."
@ -237,7 +237,7 @@ file, defaulting to the link under point, if any."
(or (cdr bounds) (point))
(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."
(interactive (list 'interactive))
(pcase command
@ -319,7 +319,7 @@ See `font-lock-keywords' and (info \"(elisp) Search-based Fontification\")."
(set-match-data res)))))
(defconst systemd-font-lock-keywords-1
`((systemd-section-matcher 1 'font-lock-type-face)
'((systemd-section-matcher 1 'font-lock-type-face)
(systemd-key-matcher 1 'font-lock-keyword-face))
"Minimal expressions to highlight in `systemd-mode'.")
@ -337,7 +337,7 @@ See `font-lock-keywords' and (info \"(elisp) Search-based Fontification\")."
("\\$[A-Z_]+\\>"
(systemd-value-extend-region) nil (0 'font-lock-variable-name-face))
;; specifiers
("%[nNpPiIfcrRtuUhsmbHv%]"
("%[abBCEfgGhHiIjJlLmnNopPrRsStTuUvVw%]"
(systemd-value-extend-region) nil (0 'font-lock-constant-face))))
"Extended expressions to highlight in `systemd-mode'.")
@ -396,7 +396,7 @@ See systemd.unit(5) for details on unit file syntax.")
;;;###autoload
(define-derived-mode systemd-mode conf-mode "Systemd"
"Major mode for editing systemd unit files.
See http://www.freedesktop.org/wiki/Software/systemd/ for more
See https://www.freedesktop.org/wiki/Software/systemd/ for more
information about systemd.
In addition to any hooks its parent mode might have run, this
@ -407,7 +407,6 @@ Key bindings:
(set-keymap-parent systemd-mode-map nil)
(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 'font-lock-extend-region-functions
'systemd-font-lock-extend-region nil t)

View File

@ -1,6 +1,6 @@
;;; systemd-tests.el --- Tests for systemd.el -*- lexical-binding: t -*-
;; Copyright (C) 2016-2017 Mark Oteiza <mvoteiza@udel.edu>
;; Copyright (C) 2016-2020 Mark Oteiza <mvoteiza@udel.edu>
;; Author: Mark Oteiza <mvoteiza@udel.edu>

View File

@ -3,12 +3,15 @@ AccuracySec
After
Alias
AllowIsolate
AllowedCPUs
AllowedMemoryNodes
Also
AmbientCapabilities
AppArmorProfile
AssertACPower
AssertArchitecture
AssertCapability
AssertControlGroupController
AssertDirectoryNotEmpty
AssertFileIsExecutable
AssertFileNotEmpty
@ -16,6 +19,7 @@ AssertFirstBoot
AssertGroup
AssertHost
AssertKernelCommandLine
AssertKernelVersion
AssertNeedsUpdate
AssertPathExists
AssertPathExistsGlob
@ -43,15 +47,21 @@ BusName
CPUAccounting
CPUAffinity
CPUQuota
CPUQuotaPeriodSec
CPUSchedulingPolicy
CPUSchedulingPriority
CPUSchedulingResetOnFork
CPUShares
CPUWeight
CacheDirectory
CacheDirectoryMode
CapabilityBoundingSet
CollectMode
ConditionACPower
ConditionArchitecture
ConditionCPUs
ConditionCapability
ConditionControlGroupController
ConditionDirectoryNotEmpty
ConditionFileIsExecutable
ConditionFileNotEmpty
@ -59,6 +69,8 @@ ConditionFirstBoot
ConditionGroup
ConditionHost
ConditionKernelCommandLine
ConditionKernelVersion
ConditionMemory
ConditionNeedsUpdate
ConditionPathExists
ConditionPathExistsGlob
@ -69,6 +81,8 @@ ConditionPathIsSymbolicLink
ConditionSecurity
ConditionUser
ConditionVirtualization
ConfigurationDirectory
ConfigurationDirectoryMode
Conflicts
DefaultDependencies
DefaultInstance
@ -79,10 +93,12 @@ DeviceAllow
DevicePolicy
DirectoryMode
DirectoryNotEmpty
DisableControllers
Documentation
DynamicUser
Environment
EnvironmentFile
ExecCondition
ExecReload
ExecStart
ExecStartPost
@ -91,13 +107,16 @@ ExecStop
ExecStopPost
ExecStopPre
FailureAction
FailureActionExitStatus
FileDescriptorName
FileDescriptorStoreMax
FinalKillSignal
ForceUnmount
FreeBind
Group
GuessMainPID
IOAccounting
IODeviceLatencyTargetSec
IODeviceWeight
IOReadBandwidthMax
IOReadIOPSMax
@ -106,6 +125,11 @@ IOSchedulingPriority
IOWeight
IOWriteBandwidthMax
IOWriteIOPSMax
IPAccounting
IPAddressAllow
IPAddressDeny
IPEgressFilterPath
IPIngressFilterPath
IPTOS
IPTTL
IgnoreOnIsolate
@ -120,6 +144,7 @@ KeepAlive
KeepAliveIntervalSec
KeepAliveProbes
KeepAliveTimeSec
KeyringMode
KillMode
KillSignal
LazyUnmount
@ -147,6 +172,13 @@ ListenSequentialPacket
ListenSpecial
ListenStream
ListenUSBFunction
LockPersonality
LogExtraFields
LogLevelMax
LogRateLimitBurst
LogRateLimitIntervalSec
LogsDirectory
LogsDirectoryMode
MakeDirectory
Mark
MaxConnections
@ -157,23 +189,30 @@ MemoryHigh
MemoryLimit
MemoryLow
MemoryMax
MemoryMin
MemorySwapMax
MessageQueueMaxMessages
MessageQueueMessageSize
MountAPIVFS
MountFlags
NUMAMask
NUMAPolicy
NetworkNamespacePath
Nice
NoDelay
NoNewPrivileges
NonBlocking
NotifyAccess
OOMPolicy
OOMScoreAdjust
OnActiveSec
OnBootSec
OnCalendar
OnClockChange
OnFailure
OnFailureJobMode
OnStartupSec
OnTimezoneChange
OnUnitActiveSec
OnUnitInactiveSec
Options
@ -187,18 +226,20 @@ PathChanged
PathExists
PathExistsGlob
PathModified
PermissionsStartOnly
Persistent
Personality
PipeSize
Priority
PrivateDevices
PrivateMounts
PrivateNetwork
PrivateTmp
PrivateUsers
PropagatesReloadTo
ProtectControlGroups
ProtectHome
ProtectHostname
ProtectKernelLogs
ProtectKernelModules
ProtectKernelTunables
ProtectSystem
@ -220,17 +261,20 @@ RequiresMountsFor
Requisite
Restart
RestartForceExitStatus
RestartKillSignal
RestartPreventExitStatus
RestartSec
RestrictAddressFamilies
RestrictNamespaces
RestrictRealtime
RestrictSUIDSGID
ReusePort
RootDirectory
RootDirectoryStartOnly
RootImage
RuntimeDirectory
RuntimeDirectoryMode
RuntimeDirectoryPreserve
RuntimeMaxSec
SELinuxContext
SELinuxContextFromNet
@ -253,6 +297,8 @@ Sockets
SourcePath
StandardError
StandardInput
StandardInputData
StandardInputText
StandardOutput
StartLimitAction
StartLimitBurst
@ -261,7 +307,11 @@ StartupBlockIOWeight
StartupCPUShares
StartupCPUWeight
StartupIOWeight
StateDirectory
StateDirectoryMode
StopWhenUnneeded
SuccessAction
SuccessActionExitStatus
SuccessExitStatus
SupplementaryGroups
Symlinks
@ -279,6 +329,9 @@ TTYVHangup
TTYVTDisallocate
TasksAccounting
TasksMax
TemporaryFileSystem
TimeoutAbortSec
TimeoutCleanSec
TimeoutIdleSec
TimeoutSec
TimeoutStartSec
@ -292,6 +345,7 @@ UMask
USBFunctionDescriptors
USBFunctionStrings
Unit
UnsetEnvironment
User
UtmpIdentifier
UtmpMode
@ -299,6 +353,7 @@ WakeSystem
WantedBy
Wants
WatchdogSec
WatchdogSignal
What
Where
WorkingDirectory