Disable lookup handlers if minor mode is disabled
This commit is contained in:
parent
7f5d961d89
commit
380c3ac268
1 changed files with 23 additions and 20 deletions
|
@ -64,35 +64,38 @@ This can be passed nil as its second argument to unset handlers for MODES. e.g.
|
||||||
(cond ((null (car plist))
|
(cond ((null (car plist))
|
||||||
(remove-hook hook fn)
|
(remove-hook hook fn)
|
||||||
(unintern fn nil))
|
(unintern fn nil))
|
||||||
((fset fn
|
((fset
|
||||||
(lambda ()
|
fn
|
||||||
(when (or (eq major-mode mode)
|
(lambda ()
|
||||||
(and (boundp mode)
|
(cl-mapc #'+lookup--set-handler
|
||||||
(symbol-value mode)))
|
(list definition
|
||||||
(cl-mapc #'+lookup--set-handler
|
references
|
||||||
(list definition
|
documentation
|
||||||
references
|
file
|
||||||
documentation
|
xref-backend)
|
||||||
file
|
(list '+lookup-definition-functions
|
||||||
xref-backend)
|
'+lookup-references-functions
|
||||||
(list '+lookup-definition-functions
|
'+lookup-documentation-functions
|
||||||
'+lookup-references-functions
|
'+lookup-file-functions
|
||||||
'+lookup-documentation-functions
|
'xref-backend-functions)
|
||||||
'+lookup-file-functions
|
(make-list 5 async)
|
||||||
'xref-backend-functions)
|
(make-list 5 (or (eq major-mode mode)
|
||||||
(make-list 5 async)))))
|
(and (boundp mode)
|
||||||
|
(symbol-value mode)))))))
|
||||||
(add-hook hook fn))))))
|
(add-hook hook fn))))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;;; Helpers
|
;;; Helpers
|
||||||
|
|
||||||
(defun +lookup--set-handler (spec functions-var &optional async)
|
(defun +lookup--set-handler (spec functions-var &optional async enable)
|
||||||
(when spec
|
(when spec
|
||||||
(cl-destructuring-bind (fn . plist)
|
(cl-destructuring-bind (fn . plist)
|
||||||
(doom-enlist spec)
|
(doom-enlist spec)
|
||||||
(put fn '+lookup-async (or (plist-get plist :async) async))
|
(if (not enable)
|
||||||
(add-hook functions-var fn nil t))))
|
(remove-hook functions-var fn 'local)
|
||||||
|
(put fn '+lookup-async (or (plist-get plist :async) async))
|
||||||
|
(add-hook functions-var fn nil 'local)))))
|
||||||
|
|
||||||
(defun +lookup--run-handler (handler identifier)
|
(defun +lookup--run-handler (handler identifier)
|
||||||
(if (commandp handler)
|
(if (commandp handler)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue