Function: denote--prepare-note
denote--prepare-note is a byte-compiled function defined in denote.el.
Signature
(denote--prepare-note TITLE KEYWORDS DATE ID DIRECTORY FILE-TYPE TEMPLATE SIGNATURE)
Documentation
Prepare a new note file and return its path.
Arguments TITLE, KEYWORDS, DATE, ID, DIRECTORY, FILE-TYPE, TEMPLATE, and SIGNATURE should be valid for note creation.
Source Code
;; Defined in ~/.emacs.d/elpa/denote-4.2.3/denote.el
(defun denote--prepare-note (title keywords date id directory file-type template signature)
"Prepare a new note file and return its path.
Arguments TITLE, KEYWORDS, DATE, ID, DIRECTORY, FILE-TYPE,
TEMPLATE, and SIGNATURE should be valid for note creation."
(let* ((extension (denote--file-extension file-type))
(path (denote-format-file-name directory id keywords title extension signature))
;; TODO 2025-08-02: Is it safe to assume that an existing and
;; 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
(insert header)
(insert (cond
((stringp template) template)
((functionp template) (funcall template))
(t (user-error "Invalid template")))))
path))