Allow set-company-backend! to unset backends
Passing nil as its second argument will unset previously set backends.
This commit is contained in:
parent
26caea7f2b
commit
97b42c449b
1 changed files with 14 additions and 9 deletions
|
@ -6,15 +6,20 @@
|
||||||
|
|
||||||
MODES should be one major-mode symbol or a list of them."
|
MODES should be one major-mode symbol or a list of them."
|
||||||
(dolist (mode (doom-enlist modes))
|
(dolist (mode (doom-enlist modes))
|
||||||
(let ((def-name (intern (format "+company|init-%s" mode))))
|
(let ((fn (intern (format "+company|init-%s" mode)))
|
||||||
(fset def-name
|
(hook (intern (format "%s-hook" mode))))
|
||||||
(lambda () (when (or (eq major-mode mode)
|
(cond (backends
|
||||||
(and (boundp mode) (symbol-value mode)))
|
(fset fn
|
||||||
(require 'company)
|
(lambda () (when (or (eq major-mode mode)
|
||||||
(make-variable-buffer-local 'company-backends)
|
(and (boundp mode) (symbol-value mode)))
|
||||||
(dolist (backend backends)
|
(require 'company)
|
||||||
(cl-pushnew backend company-backends :test #'equal)))))
|
(make-variable-buffer-local 'company-backends)
|
||||||
(add-hook (intern (format "%s-hook" mode)) def-name))))
|
(dolist (backend backends)
|
||||||
|
(cl-pushnew backend company-backends :test #'equal)))))
|
||||||
|
(add-hook hook fn))
|
||||||
|
(t
|
||||||
|
(fmakunbound fn)
|
||||||
|
(remove-hook hook fn))))))
|
||||||
|
|
||||||
;; FIXME obsolete :company-backend
|
;; FIXME obsolete :company-backend
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue