fix(file-templates): org-capture errors on new files
If an org-capture template generates a new, blank file, Doom steps in to insert a yasnippet file-template into the buffer. If the file template has text fields, it leaves the new buffer in an "editing snippets" state (and insert mode) which causes errors downstream when org-capture tries to modify the buffer. The file-templates module employs some heuristics to prevent false positives like these, but packages (and org-capture) can get around this by simply generating and switching to the org buffer before modifying it. This commit no-ops file-template expansion in any org-capture session, which should resolve these issues. Fix: #6160 Fix: #6741
This commit is contained in:
parent
5018f938b1
commit
802f015f26
1 changed files with 8 additions and 7 deletions
|
@ -138,13 +138,14 @@ information.")
|
||||||
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."
|
||||||
(and (not +file-templates-inhibit)
|
(and (not +file-templates-inhibit)
|
||||||
buffer-file-name
|
buffer-file-name ; this buffer represents a file and
|
||||||
(not buffer-read-only)
|
(not buffer-read-only) ; ...isn't read-only
|
||||||
(bobp) (eobp)
|
(bobp) (eobp) ; ...is empty
|
||||||
(not (member (substring (buffer-name) 0 1) '("*" " ")))
|
(not (member (substring (buffer-name) 0 1) '("*" " "))) ; ...isn't a "special" buffer
|
||||||
(not (file-exists-p buffer-file-name))
|
(not (bound-and-true-p org-capture-current-plist)) ; ...isn't an org-capture buffer
|
||||||
(not (buffer-modified-p))
|
(not (file-exists-p buffer-file-name)) ; ...is a new file
|
||||||
(null (buffer-base-buffer))
|
(not (buffer-modified-p)) ; ...hasn't been modified
|
||||||
|
(null (buffer-base-buffer)) ; ...isn't an indirect clone
|
||||||
(when-let (rule (cl-find-if #'+file-template-p +file-templates-alist))
|
(when-let (rule (cl-find-if #'+file-template-p +file-templates-alist))
|
||||||
(apply #'+file-templates--expand rule))))
|
(apply #'+file-templates--expand rule))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue