Function: denote-format-file-name
denote-format-file-name is a byte-compiled function defined in
denote.el.
Signature
(denote-format-file-name DIR-PATH ID KEYWORDS TITLE EXTENSION SIGNATURE)
Documentation
Format file name.
DIR-PATH, ID, KEYWORDS, TITLE, EXTENSION and SIGNATURE are
expected to be supplied by denote or equivalent command.
DIR-PATH is a string pointing to a directory. It ends with a
forward slash (the function denote-directories makes sure this is
the case when returning the value of the variable denote-directory(var)/denote-directory(fun)).
DIR-PATH cannot be nil or an empty string.
ID is a string holding the identifier of the note. It can be an empty string, in which case its respective file name component is not added to the base file name.
DIR-PATH and ID form the base file name.
KEYWORDS is a list of strings that is reduced to a single string
by denote-keywords-combine. KEYWORDS can be an empty list or
a nil value, in which case the relevant file name component is
not added to the base file name.
TITLE and SIGNATURE are strings. They can be an empty string, in which case their respective file name component is not added to the base file name.
EXTENSION is a string that contains a dot followed by the file type extension. It can be an empty string or a nil value, in which case it is not added to the base file name.
Source Code
;; Defined in ~/.emacs.d/elpa/denote-4.2.3/denote.el
;;;; New note
;;;;; Common helpers for new notes
(defun denote-format-file-name (dir-path id keywords title extension signature)
"Format file name.
DIR-PATH, ID, KEYWORDS, TITLE, EXTENSION and SIGNATURE are
expected to be supplied by `denote' or equivalent command.
DIR-PATH is a string pointing to a directory. It ends with a
forward slash (the function `denote-directories' makes sure this is
the case when returning the value of the variable `denote-directory').
DIR-PATH cannot be nil or an empty string.
ID is a string holding the identifier of the note. It can be an
empty string, in which case its respective file name component is
not added to the base file name.
DIR-PATH and ID form the base file name.
KEYWORDS is a list of strings that is reduced to a single string
by `denote-keywords-combine'. KEYWORDS can be an empty list or
a nil value, in which case the relevant file name component is
not added to the base file name.
TITLE and SIGNATURE are strings. They can be an empty string, in
which case their respective file name component is not added to
the base file name.
EXTENSION is a string that contains a dot followed by the file
type extension. It can be an empty string or a nil value, in
which case it is not added to the base file name."
(cond
((null dir-path)
(error "DIR-PATH must not be nil"))
((string-empty-p dir-path)
(error "DIR-PATH must not be an empty string"))
((not (string-suffix-p "/" dir-path))
(error "DIR-PATH does not end with a / as directories ought to")))
(let ((file-name "")
(components (seq-union denote-file-name-components-order
'(identifier signature title keywords))))
(dolist (component components)
(cond ((and (eq component 'identifier) id (not (string-empty-p id)))
(setq file-name (concat file-name "@@" (denote-sluggify 'identifier id))))
((and (eq component 'title) title (not (string-empty-p title)))
(setq file-name (concat file-name "--" (denote-sluggify-and-apply-rules 'title title))))
((and (eq component 'keywords) keywords)
(setq file-name (concat file-name "__" (denote-keywords-combine (denote-sluggify-keywords-and-apply-rules keywords)))))
((and (eq component 'signature) signature (not (string-empty-p signature)))
(setq file-name (concat file-name "==" (denote-sluggify-and-apply-rules 'signature signature))))))
(when (string-empty-p file-name)
(error "There should be at least one file name component"))
(setq file-name (concat file-name extension))
;; Do not prepend identifier with @@ if it is the first component and has the format 00000000T000000.
(when (and (not denote-identifier-delimiter-always-present-in-file-name)
(string-prefix-p "@@" file-name)
(string-match-p (concat "\\`" denote-date-identifier-regexp "\\'") id))
(setq file-name (substring file-name 2)))
(concat dir-path file-name)))