Only trigger file-templates for non-existent files #1682

Possibly addresses #1401 too
This commit is contained in:
Henrik Lissner 2019-08-19 14:18:17 -04:00
parent 7138d47ef4
commit fb619bdb0f
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -118,7 +118,8 @@ information.")
"Check if the current buffer is a candidate for file template expansion. It "Check if the current buffer is a candidate for file template expansion. It
must be non-read-only, empty, and there must be a rule in must be non-read-only, empty, and there must be a rule in
`+file-templates-alist' that applies to it." `+file-templates-alist' that applies to it."
(when (and (not buffer-read-only) (when (and (not (file-exists-p (buffer-file-name)))
(not buffer-read-only)
(bobp) (eobp) (bobp) (eobp)
(not (string-match-p "^ *\\*" (buffer-name)))) (not (string-match-p "^ *\\*" (buffer-name))))
(when-let (rule (cl-find-if #'+file-template-p +file-templates-alist)) (when-let (rule (cl-find-if #'+file-template-p +file-templates-alist))