mirror of
https://github.com/protesilaos/denote.git
synced 2026-09-10 07:16:20 -04:00
Make denote--prepare-note only error if an existing file is not empty
This way we avoid cases where some other function saves the buffer before we get to operate on it. One such example is 'lsp-auto-touch-files', as noted by wuzhihao in issue 627: <https://github.com/protesilaos/denote/issues/627>.
This commit is contained in:
parent
955618e75c
commit
307db01003
|
|
@ -6458,7 +6458,7 @@ Denote is meant to be a collective effort. Every bit of help matters.
|
|||
fingerknight, hpgisler, hyperfocus1337,johkneisl, jtpavlock, juh,
|
||||
leafarbelm, mentalisttraceur, mjkalyan, oatmealm, pRot0ta1p,
|
||||
rbenit68, relict007, sarcom-sar, sienic, skissue, sundar bp,
|
||||
yetanotherfossman, zadca123
|
||||
wuzhihao, yetanotherfossman, zadca123
|
||||
|
||||
Special thanks to Peter Povinec who helped refine the file-naming
|
||||
scheme, which is the cornerstone of this project.
|
||||
|
|
|
|||
|
|
@ -2917,8 +2917,11 @@ Arguments TITLE, KEYWORDS, DATE, ID, DIRECTORY, FILE-TYPE,
|
|||
TEMPLATE, and SIGNATURE should be valid for note creation."
|
||||
(let* ((path (denote-format-file-name
|
||||
directory id keywords title (denote--file-extension file-type) signature))
|
||||
(buffer (if (file-regular-p path)
|
||||
(user-error "A file named `%s' already exists" path)
|
||||
;; NOTE 2025-08-02: Is it safe to assume that an
|
||||
;; existing+empty file is good for us to use? Otherwise, we
|
||||
;; should have a `y-or-n-p' prompt here.
|
||||
(buffer (if (and (file-regular-p path) (not (denote--file-empty-p path)))
|
||||
(user-error "A file named `%s' already exists and is not empty" path)
|
||||
(find-file path)))
|
||||
(header (denote--format-front-matter title date keywords id signature file-type)))
|
||||
(with-current-buffer buffer
|
||||
|
|
|
|||
Loading…
Reference in a new issue