Fix #2568: change when file-templates are expanded

This commit is contained in:
Henrik Lissner 2020-02-20 17:24:16 -05:00
parent 8a5ffc32f5
commit 037bcf3c12
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -137,10 +137,7 @@ must be non-read-only, empty, and there must be a rule in
(bobp) (eobp)
(not (member (substring (buffer-name) 0 1) '("*" " ")))
(not (file-exists-p buffer-file-name))
;; Prevent file-templates from breaking org-capture when target file
;; doesn't exist and has a file template.
(or (not (fboundp 'org-capture-get))
(not (org-capture-get :new-buffer)))
(not (buffer-modified-p))
(when-let (rule (cl-find-if #'+file-template-p +file-templates-alist))
(apply #'+file-templates--expand rule))))
@ -159,4 +156,4 @@ must be non-read-only, empty, and there must be a rule in
(yas-reload-all)))
;;
(add-hook 'find-file-hook #'+file-templates-check-h)
(add-hook 'doom-switch-buffer-hook #'+file-templates-check-h)