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."
|
||||
(dolist (mode (doom-enlist modes))
|
||||
(let ((def-name (intern (format "+company|init-%s" mode))))
|
||||
(fset def-name
|
||||
(lambda () (when (or (eq major-mode mode)
|
||||
(and (boundp mode) (symbol-value mode)))
|
||||
(require 'company)
|
||||
(make-variable-buffer-local 'company-backends)
|
||||
(dolist (backend backends)
|
||||
(cl-pushnew backend company-backends :test #'equal)))))
|
||||
(add-hook (intern (format "%s-hook" mode)) def-name))))
|
||||
(let ((fn (intern (format "+company|init-%s" mode)))
|
||||
(hook (intern (format "%s-hook" mode))))
|
||||
(cond (backends
|
||||
(fset fn
|
||||
(lambda () (when (or (eq major-mode mode)
|
||||
(and (boundp mode) (symbol-value mode)))
|
||||
(require 'company)
|
||||
(make-variable-buffer-local 'company-backends)
|
||||
(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
|
||||
;;;###autoload
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue