Refactor set-company-backend! & revise docstring
This commit is contained in:
parent
d01f39d658
commit
bc87ccf894
1 changed files with 8 additions and 9 deletions
|
@ -7,7 +7,7 @@
|
||||||
MODES should be one symbol or a list of them, representing major or minor modes.
|
MODES should be one symbol or a list of them, representing major or minor modes.
|
||||||
This will overwrite backends for MODES on consecutive uses.
|
This will overwrite backends for MODES on consecutive uses.
|
||||||
|
|
||||||
If BACKENDS is just 'nil, unset the backends for MODES.
|
If the car of BACKENDS is nil, unset the backends for MODES.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
|
@ -18,10 +18,12 @@ Examples:
|
||||||
'(:separate company-irony-c-headers company-irony))
|
'(:separate company-irony-c-headers company-irony))
|
||||||
(set-company-backend! 'sh-mode nil)"
|
(set-company-backend! 'sh-mode nil)"
|
||||||
(dolist (mode (doom-enlist modes))
|
(dolist (mode (doom-enlist modes))
|
||||||
(let ((fn (intern (format "+company|init-%s" mode)))
|
(let ((hook (intern (format "%s-hook" mode)))
|
||||||
(hook (intern (format "%s-hook" mode))))
|
(fn (intern (format "+company|init-%s" mode))))
|
||||||
(cond ((and backends (not (eq (car backends) 'nil)))
|
(cond ((null (car-safe backends))
|
||||||
(fset fn
|
(remove-hook hook fn)
|
||||||
|
(unintern fn))
|
||||||
|
((fset fn
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(when (or (eq major-mode mode)
|
(when (or (eq major-mode mode)
|
||||||
(and (boundp mode) (symbol-value mode)))
|
(and (boundp mode) (symbol-value mode)))
|
||||||
|
@ -30,10 +32,7 @@ Examples:
|
||||||
(dolist (backend (reverse backends))
|
(dolist (backend (reverse backends))
|
||||||
(cl-pushnew backend company-backends
|
(cl-pushnew backend company-backends
|
||||||
:test (if (symbolp backend) #'eq #'equal))))))
|
:test (if (symbolp backend) #'eq #'equal))))))
|
||||||
(add-hook hook fn))
|
(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