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
This commit is contained in:
Mark Oteiza 2023-01-31 22:02:07 -05:00
parent 964ec9d4e0
commit 8742607120

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2014-2023 Mark Oteiza <mvoteiza@udel.edu> ;; Copyright (C) 2014-2023 Mark Oteiza <mvoteiza@udel.edu>
;; Author: Mark Oteiza <mvoteiza@udel.edu> ;; Author: Mark Oteiza <mvoteiza@udel.edu>
;; Version: 1.6 ;; Version: 1.6.1
;; Package-Requires: ((emacs "24.4")) ;; Package-Requires: ((emacs "24.4"))
;; Keywords: tools, unix ;; Keywords: tools, unix
@ -33,7 +33,8 @@
;; 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'. ;; `systemd-mode-hook' and adding `systemd-company-backend' to
;; `company-backends'.
;;; Code: ;;; Code:
@ -406,7 +407,6 @@ Key bindings:
(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]*?[^;#]") (setq-local auto-fill-inhibit-regexp "^[ \t]*?[^;#]")
(add-hook 'company-backends #'systemd-company-backend nil 'local)
(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 (add-hook 'font-lock-extend-region-functions
'systemd-font-lock-extend-region nil t) 'systemd-font-lock-extend-region nil t)