diff --git a/lisp/doom-lib.el b/lisp/doom-lib.el index f35e9580a..e2113a66c 100644 --- a/lisp/doom-lib.el +++ b/lisp/doom-lib.el @@ -241,6 +241,15 @@ TRIGGER-HOOK is a list of quoted hooks and/or sharp-quoted functions." ((add-hook hook fn -101))) fn))) +(defun doom-compile-function (fn &optional level) + "Compile FN, and natively, if possible." + (if (featurep 'native-compile) + (let ((native-comp-speed (or level native-comp-speed))) + (unless (subr-native-elisp-p (symbol-function fn)) + (native-compile fn))) + (unless (byte-code-function-p (symbol-function fn)) + (with-no-warnings (byte-compile fn))))) + ;; ;;; Sugars