diff --git a/core/core-lib.el b/core/core-lib.el index e22918f22..72bf0cb94 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -226,7 +226,20 @@ compilation. This will no-op on features that have been disabled by the user." (load next :no-message :no-error)))) #'progn #'with-no-warnings) - (cond ((symbolp targets) + (cond ((eq (car-safe targets) :when) + `(if ,(cadr targets) + (progn ,@body) + ,(let* ((hook 'after-load-functions) + (fun (intern (format "doom|delay-form-in-%s" hook)))) + `(progn + (fset ',fun (lambda (&rest args) + (when ,(or (car (cdr-safe targets)) t) + (remove-hook ',hook #',fun) + (ignore args) + ,@body))) + (put ',fun 'permanent-local-hook t) + (add-hook ',hook #',fun))))) + ((symbolp targets) `(eval-after-load ',targets '(progn ,@body))) ((and (consp targets) (memq (car targets) '(:or :any))) diff --git a/modules/feature/file-templates/autoload.el b/modules/feature/file-templates/autoload.el index 4cd82e4ff..43315b931 100644 --- a/modules/feature/file-templates/autoload.el +++ b/modules/feature/file-templates/autoload.el @@ -22,12 +22,14 @@ these properties: :ignore BOOL If non-nil, don't expand any template for this file and don't test any other file template rule against this buffer." - `(push (list ,pred ,@plist) +file-templates-alist)) + (after! (:when (boundp '+file-templates-alist)) + (push `(,pred ,@plist) +file-templates-alist))) ;;;###autodef (defun set-file-templates! (&rest templates) "Like `doom--set:file-template', but register many file templates at once." - `(setq +file-templates-alist (append (list ,@templates) +file-templates-alist))) + (after! (:when (boundp '+file-templates-alist)) + (setq +file-templates-alist (append (list templates) +file-templates-alist)))) ;; FIXME obsolete :file-template ;;;###autoload