feat(file-templates): add apply method

Factor template application code into command file-templates-apply.
This allows it to be invoked by the user.
This commit is contained in:
dmr
2024-12-01 16:23:51 +00:00
committed by GitHub
parent 05e34351ea
commit 52d1c208d4

View File

@ -146,9 +146,13 @@ must be non-read-only, empty, and there must be a rule in
(not (file-exists-p buffer-file-name)) ; ...is a new file (not (file-exists-p buffer-file-name)) ; ...is a new file
(not (buffer-modified-p)) ; ...hasn't been modified (not (buffer-modified-p)) ; ...hasn't been modified
(null (buffer-base-buffer)) ; ...isn't an indirect clone (null (buffer-base-buffer)) ; ...isn't an indirect clone
(when-let (rule (cl-find-if #'+file-template-p +file-templates-alist)) (+file-templates/apply)))
(apply #'+file-templates--expand rule))))
(defun +file-templates/apply ()
"Actually expand a file template if one exists"
(interactive)
(when-let* ((rule (cl-find-if #'+file-template-p +file-templates-alist)))
(apply #'+file-templates--expand rule)))
;; ;;
;;; Bootstrap ;;; Bootstrap