Function: denote-file-type
denote-file-type is a byte-compiled function defined in denote.el.
Signature
(denote-file-type FILE)
Documentation
Use the file extension to detect the file type of FILE.
Do so in accordance with denote-file-types.
If more than one file type correspond to this file extension, return the
first file type whose :get-file-type-function returns non-nil. If
:get-file-type-function is nil rely on the :title-key-regexp and
return the first matching file type.
Return nil if FILE is not recognized.
Source Code
;; Defined in ~/.emacs.d/elpa/denote-4.2.3/denote.el
(defun denote-file-type (file)
"Use the file extension to detect the file type of FILE.
Do so in accordance with `denote-file-types'.
If more than one file type correspond to this file extension, return the
first file type whose `:get-file-type-function' returns non-nil. If
`:get-file-type-function' is nil rely on the `:title-key-regexp' and
return the first matching file type.
Return nil if FILE is not recognized."
(when-let* ((extension (denote-get-file-extension-sans-encryption file))
(types (denote--file-types-with-extension extension))
(length (length types)))
(cond
((when-let* ((_ (> length 1))
(found (seq-find
(lambda (type)
(let ((properties (cdr type)))
(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)))))
types)))
(car found)))
((and (> length 1)
(memq denote-file-type (mapcar #'car types)))
denote-file-type)
(t
(caar types)))))