mirror of
https://github.com/protesilaos/denote.git
synced 2026-09-16 02:06:23 -04:00
Make denote-file-prompt accept a PROMPT-TEXT argument like other prompts
This commit is contained in:
parent
ce134fed64
commit
5c10aa2863
12
README.org
12
README.org
|
|
@ -4462,11 +4462,13 @@ might change them without further notice.
|
|||
|
||||
#+findex: denote-file-prompt
|
||||
+ Function ~denote-file-prompt~ :: Prompt for file with identifier in
|
||||
variable ~denote-directory~. With optional =FILES-MATCHING-REGEXP=,
|
||||
filter the candidates per the given regular expression. [ As part of
|
||||
{{{development-version}}}, completion candidates have a relative
|
||||
file path, but the return value and what is stored in the minibuffer
|
||||
history is still the full file system path. ]
|
||||
variable ~denote-directory~. With optional =FILES-MATCHING-REGEXP=,
|
||||
filter the candidates per the given regular expression. With
|
||||
optional =PROMPT-TEXT=, use it instead of the default "Select NOTE".
|
||||
[ As part of {{{development-version}}}, completion candidates have a
|
||||
relative file path, but the return value and what is stored in the
|
||||
minibuffer history is still the full file system path. Furthermore,
|
||||
the =PROMPT-TEXT= is added. ]
|
||||
|
||||
#+findex: denote-keywords-prompt
|
||||
+ Function ~denote-keywords-prompt~ :: Prompt for one or more keywords.
|
||||
|
|
|
|||
12
denote.el
12
denote.el
|
|
@ -1132,19 +1132,23 @@ file in the returned list."
|
|||
|
||||
;; NOTE 2024-02-29: Based on `project--read-file-cpd-relative' from
|
||||
;; the built-in project.el
|
||||
(defun denote-file-prompt (&optional files-matching-regexp)
|
||||
(defun denote-file-prompt (&optional files-matching-regexp prompt-text)
|
||||
"Prompt for file with identifier in variable `denote-directory'.
|
||||
With optional FILES-MATCHING-REGEXP, filter the candidates per
|
||||
the given regular expression."
|
||||
the given regular expression.
|
||||
|
||||
With optional PROMPT-TEXT, use it instead of the default call to
|
||||
\"Select NOTE\"."
|
||||
(when-let ((all-files (denote-directory-files files-matching-regexp :omit-current)))
|
||||
(let* ((common-parent-directory
|
||||
(let ((common-prefix (try-completion "" all-files)))
|
||||
(if (> (length common-prefix) 0)
|
||||
(file-name-directory common-prefix))))
|
||||
(cpd-length (length common-parent-directory))
|
||||
(prompt-prefix (or prompt-text "Select NOTE"))
|
||||
(prompt (if (zerop cpd-length)
|
||||
"Select note: "
|
||||
(format "Select note in %s: " common-parent-directory)))
|
||||
(format "%s: " prompt-prefix)
|
||||
(format "%s in %s: " prompt-prefix common-parent-directory)))
|
||||
(included-cpd (when (member common-parent-directory all-files)
|
||||
(setq all-files
|
||||
(delete common-parent-directory all-files))
|
||||
|
|
|
|||
Loading…
Reference in a new issue