Change unsetting with set-lookup-handlers!

Instead of passing :unset, pass in nil as its second argument.
This commit is contained in:
Henrik Lissner 2018-06-21 23:11:05 +02:00
parent ff7823bfc9
commit be48751a45
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -4,14 +4,14 @@
;;;###autodef ;;;###autodef
(defun set-lookup-handlers! (modes &rest plist) (defun set-lookup-handlers! (modes &rest plist)
"Defines a jump target for major MODES. "Define a jump target for major MODES.
This overwrites previously defined handlers for MODES. If used on minor modes, This overwrites previously defined handlers for MODES. If used on minor modes,
they are combined with handlers defined for other minor modes or the major mode they are combined with handlers defined for other minor modes or the major mode
it's activated in. it's activated in.
If the CAR of PLIST is :unset, other properties are ignored and all existing If the CAR of PLIST is nil, other properties are ignored and all existing jump
jump handlers for MODES are cleared. Otherwise, PLIST accepts the following handlers for MODES are cleared. Otherwise, PLIST accepts the following
properties: properties:
:definition FN :definition FN
@ -30,11 +30,12 @@ properties:
Defines an xref backend for a major-mode. If you define :definition and Defines an xref backend for a major-mode. If you define :definition and
:references along with :xref-backend, those will have higher precedence." :references along with :xref-backend, those will have higher precedence."
(dolist (mode (doom-enlist modes)) (dolist (mode (doom-enlist modes))
(let ((fn (intern (format "+lookup|init-%s" mode))) (let ((hook (intern (format "%s-hook" mode)))
(hook (intern (format "%s-hook" mode)))) (fn (intern (format "+lookup|init-%s" mode))))
(if (eq (car plist) :unset) (cond ((null (car plist))
(remove-hook hook fn) (remove-hook hook fn)
(fset fn (unintern fn))
((fset fn
(lambda () (lambda ()
(when (or (eq major-mode mode) (when (or (eq major-mode mode)
(and (boundp mode) (and (boundp mode)
@ -52,7 +53,7 @@ properties:
(add-hook '+lookup-file-functions file nil t)) (add-hook '+lookup-file-functions file nil t))
(when xref-backend (when xref-backend
(add-hook 'xref-backend-functions xref-backend nil t)))))) (add-hook 'xref-backend-functions xref-backend nil t))))))
(add-hook hook fn))))) (add-hook hook fn))))))
;;;###autoload ;;;###autoload
(def-setting! :lookup (modes &rest plist) (def-setting! :lookup (modes &rest plist)