Ensure :get-file-type-function is called only when file exists

Otherwise we get an error upon creating the file.

Thanks to potchie-maker for reporting the bug in issue 709:
<https://github.com/protesilaos/denote/issues/709>.
This commit is contained in:
Protesilaos 2026-05-27 20:28:38 +03:00
parent 77813e9956
commit 420710fb17
No known key found for this signature in database
GPG key ID: 99BD6459CD5CA3EA
2 changed files with 5 additions and 3 deletions

View file

@ -7132,8 +7132,9 @@ Denote is meant to be a collective effort. Every bit of help matters.
bdillahu, coherentstate, doolio, duli, drcxd, elge70, elliottw,
fingerknight, GuutBoy, hpgisler, hyperfocus1337,johkneisl,
jtpavlock, juh, leafarbelm, mentalisttraceur, mjkalyan, oatmealm,
Pratik-Mishra-4979, pRot0ta1p, rbenit68, relict007, sarcom-sar,
sienic, skissue, sundar bp, wuzhihao, yetanotherfossman, zadca123
potchie-maker, Pratik-Mishra-4979, pRot0ta1p, rbenit68, relict007,
sarcom-sar, sienic, skissue, sundar bp, wuzhihao, yetanotherfossman,
zadca123
Special thanks to Peter Povinec who helped refine the file-naming
scheme, which is the cornerstone of this project.

View file

@ -3961,7 +3961,8 @@ Return nil if FILE is not recognized."
(found (seq-find
(lambda (type)
(let ((properties (cdr type)))
(if-let* ((file-type-fn (plist-get properties :get-file-type-function)))
(if-let* ((file-type-fn (plist-get properties :get-file-type-function))
(_ (file-exists-p file)))
(funcall file-type-fn file)
(ignore-errors
(denote--regexp-in-file-p (plist-get properties :title-key-regexp) file)))))