Function: denote-file-has-denoted-filename-p
denote-file-has-denoted-filename-p is a byte-compiled function defined
in denote.el.
Signature
(denote-file-has-denoted-filename-p FILE)
Documentation
Return non-nil if FILE respects the Denote file-naming scheme.
Test the rules of Denote's file-naming scheme, notwithstanding the
denote-file-name-slug-functions. As such, ignore sluggification, by
removing all file name components and validating what remains.
Aliases
denote-filename-is-note-p (obsolete since 4.1.0)
denote-file-is-note-p (obsolete since 4.1.0)
Source Code
;; Defined in ~/.emacs.d/elpa/denote-4.2.3/denote.el
(defun denote-file-has-denoted-filename-p (file)
"Return non-nil if FILE respects the Denote file-naming scheme.
Test the rules of Denote's file-naming scheme, notwithstanding the
`denote-file-name-slug-functions'. As such, ignore sluggification, by
removing all file name components and validating what remains."
(let* ((initial-filename (file-name-nondirectory file))
(filename initial-filename)
(title (denote-retrieve-filename-title file))
(keywords-string (denote-retrieve-filename-keywords file))
(signature (denote-retrieve-filename-signature file))
(identifier (denote-retrieve-filename-identifier file)))
(when title
(setq filename (replace-regexp-in-string (concat "\\(--" (regexp-quote title) "\\).*\\'") "" filename nil nil 1)))
(when keywords-string
(setq filename (replace-regexp-in-string (concat "\\(__" (regexp-quote keywords-string) "\\).*\\'") "" filename nil nil 1)))
(when signature
(setq filename (replace-regexp-in-string (concat "\\(==" (regexp-quote signature) "\\).*\\'") "" filename nil nil 1)))
(when identifier
(if (string-match-p "@@" filename)
(setq filename (replace-regexp-in-string (concat "\\(@@" (regexp-quote identifier) "\\).*\\'") "" filename nil nil 1))
(setq filename (replace-regexp-in-string (concat "\\(" (regexp-quote identifier) "\\).*\\'") "" filename nil nil 1))))
;; What remains should be the empty string or the file extension.
(and (not (string-prefix-p "." initial-filename))
(or (string-empty-p filename)
(string-prefix-p "." filename)))))