emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/denote 2e444f3f22 03/12: BREAKING make 'denote-file-pro


From: ELPA Syncer
Subject: [elpa] externals/denote 2e444f3f22 03/12: BREAKING make 'denote-file-prompt' accept optional regexp filter
Date: Mon, 25 Sep 2023 09:58:14 -0400 (EDT)

branch: externals/denote
commit 2e444f3f224797131506ac81c0cc62728c16af0e
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    BREAKING make 'denote-file-prompt' accept optional regexp filter
---
 README.org |  6 ++++--
 denote.el  | 13 ++++++++-----
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/README.org b/README.org
index f1215d4ca9..c13e3f0bf6 100644
--- a/README.org
+++ b/README.org
@@ -3662,8 +3662,10 @@ 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 =INITIAL-TEXT=, use it
-  to prepopulate the minibuffer.
+  variable ~denote-directory~.  With optional =FILES-MATCHING-REGEXP=,
+  filter the candidates per the given regular expression. [ Refactored
+  as part of {{{development-version}}} because the old =INITIAL-INPUT=
+  argument was not actually used anywhere. ]
 
 #+findex: denote-keywords-prompt
 + Function ~denote-keywords-prompt~ :: Prompt for one or more
diff --git a/denote.el b/denote.el
index 61a92d956b..a36eda6189 100644
--- a/denote.el
+++ b/denote.el
@@ -888,14 +888,17 @@ The path is relative to DIRECTORY (default: 
‘default-directory’)."
 (defvar denote--file-history nil
   "Minibuffer history of `denote-file-prompt'.")
 
-(defun denote-file-prompt (&optional initial-text)
+(defun denote-file-prompt (&optional files-matching-regexp)
   "Prompt for file with identifier in variable `denote-directory'.
-With optional INITIAL-TEXT, use it to prepopulate the minibuffer."
-  (let* ((all-files (denote-all-files))
+With optional FILES-MATCHING-REGEXP, filter the candidates per
+the given regular expression."
+  (let* ((files (if files-matching-regexp
+                    (denote-directory-files-matching-regexp 
files-matching-regexp)
+                  (denote-all-files)))
          (completion-ignore-case read-file-name-completion-ignore-case))
-    (when all-files
+    (when files
       (funcall project-read-file-name-function
-               "Select note: " all-files nil 'denote--file-history 
initial-text))))
+               "Select note: " files nil 'denote--file-history))))
 
 (define-obsolete-function-alias
   'denote--retrieve-read-file-prompt



reply via email to

[Prev in Thread] Current Thread [Next in Thread]