Function: denote-file-prompt
denote-file-prompt is a byte-compiled function defined in denote.el.
Signature
(denote-file-prompt &optional FILES-MATCHING-REGEXP PROMPT-TEXT NO-REQUIRE-MATCH HAS-IDENTIFIER)
Documentation
Prompt for file in variable denote-directory(var)/denote-directory(fun).
Files that match denote-excluded-files-regexp are excluded from the
list.
With optional FILES-MATCHING-REGEXP, filter the candidates per the given regular expression.
With optional PROMPT-TEXT, use it instead of the default call to select a file.
With optional NO-REQUIRE-MATCH, accept the given input as-is.
With optional HAS-IDENTIFIER, only show candidates that have an identifier.
Return the absolute path to the matching file.
Source Code
;; Defined in ~/.emacs.d/elpa/denote-4.2.3/denote.el
(defun denote-file-prompt (&optional files-matching-regexp prompt-text no-require-match has-identifier)
"Prompt for file in variable `denote-directory'.
Files that match `denote-excluded-files-regexp' are excluded from the
list.
With optional FILES-MATCHING-REGEXP, filter the candidates per
the given regular expression.
With optional PROMPT-TEXT, use it instead of the default call to
select a file.
With optional NO-REQUIRE-MATCH, accept the given input as-is.
With optional HAS-IDENTIFIER, only show candidates that have an
identifier.
Return the absolute path to the matching file."
(let* ((roots (denote-directories))
(single-dir-p (null (cdr roots)))
;; Some external program may use `default-directory' with the
;; relative file paths of the completion candidates.
(default-directory (if single-dir-p
(car roots)
(denote-directories-get-common-root)))
(files (denote-directory-files
(or denote-file-prompt-use-files-matching-regexp files-matching-regexp)
:omit-current nil nil has-identifier))
(relative-files (if single-dir-p
(mapcar
(lambda (file)
(denote--get-file-name-relative-to-directories file roots))
files)
files))
(prompt (if single-dir-p
(format "%s: " (or prompt-text "Select FILE"))
(format "%s in %s: "
(or prompt-text "Select FILE")
(propertize default-directory 'face 'denote-faces-prompt-current-name))))
(input (completing-read
prompt
(apply 'denote-get-completion-table relative-files denote-file-prompt-extra-metadata)
nil (unless no-require-match t)
nil 'denote-file-history))
(absolute-file (if single-dir-p
(expand-file-name input default-directory)
input)))
;; NOTE: This block is executed when no-require-match is t. It is useful
;; for commands such as `denote-open-or-create' or similar.
(unless (file-exists-p absolute-file)
(setq denote-file-prompt-latest-input input)
(setq denote-file-history (delete input denote-file-history)))
;; NOTE: We must always return an absolute path, even if it does not
;; exist, because callers expect one. They handle a non-existent file
;; appropriately.
absolute-file))