[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/systemd 0c871fc 042/131: Use four different candidate list
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/systemd 0c871fc 042/131: Use four different candidate lists: |
Date: |
Sun, 29 Aug 2021 11:35:11 -0400 (EDT) |
branch: elpa/systemd
commit 0c871fc508deb2fe84dab948d320fea36b851645
Author: Mark Oteiza <mvoteiza@udel.edu>
Commit: Mark Oteiza <mvoteiza@udel.edu>
Use four different candidate lists:
Section vs directive, normal unit vs network configuration
---
systemd-company.el | 37 +++++++++++++++++++++++++++++--------
1 file changed, 29 insertions(+), 8 deletions(-)
diff --git a/systemd-company.el b/systemd-company.el
index 5bfa38a..906f134 100644
--- a/systemd-company.el
+++ b/systemd-company.el
@@ -27,6 +27,10 @@
(declare-function company-begin-backend "company")
(declare-function company-grab-symbol "company")
+(defconst systemd-company-unit-sections
+ '("Unit" "Install" "Service")
+ "Configuration sections for systemd 224.")
+
(defconst systemd-company-unit-directives
;; TODO: keep a script of sorts for generating this list. systemd
;; source has a python script in tools/ for parsing the
@@ -107,6 +111,12 @@
"Where" "WorkingDirectory")
"Configuration directives for systemd 224.")
+(defconst systemd-company-network-sections
+ '("Match" "Link" "NetDev" "VLAN" "MACVLAN" "MACVTAP" "IPVLAN" "VXLAN"
+ "Tunnel" "Peer" "Tun" "Tap" "Bond" "Network" "Address" "Route" "DHCP"
+ "Bridge" "BridgeFDB")
+ "Network configuration sections for systemd 224.")
+
(defconst systemd-company-network-directives
;; /Network directives/,/Journal fields/p
'("ARPAllTargets" "ARPIPTargets" "ARPIntervalSec" "ARPProxy" "ARPValidate"
@@ -133,16 +143,20 @@
"WakeOnLan")
"Network configuration directives for systemd 224.")
-(defconst systemd-company-directives
- (append systemd-company-unit-directives systemd-company-network-directives)
- "Configuration directives for systemd.
-Combination of `systemd-company-unit-directives' and
-`systemd-company-network-directives'.")
-
(defun systemd-company--setup (enable)
(when (fboundp 'systemd-company--setup-company)
(systemd-company--setup-company enable)))
+(defun systemd-company-section-p ()
+ "Return t if current line begins with \"[\", otherwise nil"
+ (save-excursion
+ (beginning-of-line)
+ (looking-at "\\[")))
+
+(defun systemd-company-network-p ()
+ "Return non-nil if `buffer-name' has a network-type extension, otherwise nil"
+ (string-match "\\.\\(link\\|netdev\\|network\\)\\'" (buffer-name)))
+
(with-eval-after-load "company"
(defun systemd-company-backend (command &optional arg &rest ignored)
(interactive (list 'interactive))
@@ -151,8 +165,15 @@ Combination of `systemd-company-unit-directives' and
(prefix (and (eq major-mode 'systemd-mode)
(company-grab-symbol)))
(candidates
- (cl-remove-if-not (lambda (c) (string-prefix-p arg c))
- systemd-company-directives))))
+ (cl-remove-if-not
+ (lambda (c) (string-prefix-p arg c))
+ (if (systemd-company-network-p)
+ (if (systemd-company-section-p)
+ systemd-company-network-sections
+ systemd-company-network-directives)
+ (if (systemd-company-section-p)
+ systemd-company-unit-sections
+ systemd-company-unit-directives))))))
(defun systemd-company--setup-company (enable)
(when enable
(add-to-list (make-local-variable 'company-backends)
'systemd-company-backend))
- [nongnu] elpa/systemd 401d71c 122/131: Add %E, %j, %J, %T, %V specifiers, (continued)
- [nongnu] elpa/systemd 401d71c 122/131: Add %E, %j, %J, %T, %V specifiers, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd ec8f6cf 128/131: happy new year, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd b6ae63a 131/131: add specifiers (leave obsoleted ones in for now), ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 0416fe4 130/131: drop some unneeded eval-when-compile, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 50c63c2 026/131: allow cycling completions in `systemd-doc-open`, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 612c3de 027/131: double bump, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 347c157 031/131: lexical binding, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd e7a2efb 021/131: mention `package-install-file` in README, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd ed00e3f 029/131: require 24.4 (with-eval-after-load), ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd ef24360 037/131: spaces unneeded in syntax table modifications, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 0c871fc 042/131: Use four different candidate lists:,
ELPA Syncer <=
- [nongnu] elpa/systemd 602d9d3 050/131: reword some commentary, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 6fd29c5 070/131: font lock keywords: comments and sections, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd ff523bc 071/131: woops, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 2e6309d 002/131: add systemd-mode.el, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 37541b2 003/131: add facility for browsing documentation, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 930e82e 100/131: font lock additional exec prefix, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 9cfd315 102/131: simplify, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 1e7567a 117/131: prepare v1.6, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 077aedd 125/131: systemd 244 directives, ELPA Syncer, 2021/08/29
- [nongnu] elpa/systemd 53b44ad 001/131: initial commit, ELPA Syncer, 2021/08/29