branch: externals/denote
commit 9d6b50b0c10623acaee8f1301709a343b4d05b6e
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>
Add single prompt function for all "files matching regexp" type of prompts
---
README.org | 5 +++++
denote-org-dblock.el | 8 ++------
denote-sort.el | 9 +--------
denote.el | 15 +++++++++++----
4 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/README.org b/README.org
index d478230e56..db4882fa64 100644
--- a/README.org
+++ b/README.org
@@ -4093,6 +4093,11 @@ might change them without further notice.
+ Function ~denote-command-prompt~ :: Prompt for command among
~denote-commands-for-new-notes~
([[#h:17896c8c-d97a-4faa-abf6-31df99746ca6][Points of entry]]).
+#+findex: denote-files-matching-regexp-prompt
++ Function ~denote-files-matching-regexp-prompt~ :: Prompt for
+ =REGEXP= to filter Denote files by. With optional =PROMPT-TEXT= use
+ it instead of a generic prompt. [ Part of {{{development-version}}}. ]
+
#+findex: denote-prompt-for-date-return-id
+ Function ~denote-prompt-for-date-return-id~ :: Use
~denote-date-prompt~ and return it as ~denote-id-format~.
diff --git a/denote-org-dblock.el b/denote-org-dblock.el
index 24e22f3fa9..c5d66142c4 100644
--- a/denote-org-dblock.el
+++ b/denote-org-dblock.el
@@ -58,10 +58,6 @@ sorting."
(t
(denote-directory-files files-matching-regexp :omit-current))))
-(defun denote-org-dblock--file-regexp-prompt ()
- "Prompt for regexp to match Denote file names."
- (read-regexp "Search for notes matching REGEX: " nil
'denote-link--add-links-history))
-
;;;; Dynamic block to insert links
;;;###autoload
@@ -69,7 +65,7 @@ sorting."
"Create Org dynamic block to insert Denote links matching REGEXP."
(interactive
(list
- (denote-org-dblock--file-regexp-prompt))
+ (denote-files-matching-regexp-prompt))
org-mode)
(org-create-dblock (list :name "denote-links"
:regexp regexp
@@ -219,7 +215,7 @@ Sort the files according to SORT-BY-COMPONENT, which is a
symbol
among `denote-sort-components'."
(interactive
(list
- (denote-org-dblock--file-regexp-prompt)
+ (denote-files-matching-regexp-prompt)
(denote-sort-component-prompt))
org-mode)
(org-create-dblock (list :name "denote-files"
diff --git a/denote-sort.el b/denote-sort.el
index a46d3f57e4..a0394fd905 100644
--- a/denote-sort.el
+++ b/denote-sort.el
@@ -137,13 +137,6 @@ With optional REVERSE as a non-nil value, reverse the sort
order."
current-file-type
id-only))
-(defvar denote-sort--files-matching-regexp-hist nil
- "Minibuffer history of `denote-sort--files-matching-regexp-prompt'.")
-
-(defun denote-sort--files-matching-regexp-prompt ()
- "Prompt for REGEXP to filter Denote files by."
- (read-regexp "Match files with the given REGEXP: " nil
'denote-sort--files-matching-regexp-hist))
-
(defvar denote-sort--component-hist nil
"Minibuffer history of `denote-sort-component-prompt'.")
@@ -177,7 +170,7 @@ When called from Lisp, the arguments are a string, a
keyword, and
a non-nil value, respectively."
(interactive
(list
- (denote-sort--files-matching-regexp-prompt)
+ (denote-files-matching-regexp-prompt)
(denote-sort-component-prompt)
(y-or-n-p "Reverse sort? ")))
(let* ((default-directory (denote-directory))
diff --git a/denote.el b/denote.el
index 7b95e9aa57..1d9b10d075 100644
--- a/denote.el
+++ b/denote.el
@@ -1971,6 +1971,16 @@ histories between sessions."
denote--signature-history
nil nil default-signature 'denote--signature-history)))
+(defvar denote--files-matching-regexp-hist nil
+ "Minibuffer history of `denote-files-matching-regexp-prompt'.")
+
+(defun denote-files-matching-regexp-prompt (&optional prompt-text)
+ "Prompt for REGEXP to filter Denote files by.
+With optional PROMPT-TEXT use it instead of a generic prompt."
+ (read-regexp
+ (format-prompt (or prompt-text "Match files with the given REGEXP") nil)
+ nil 'denote--files-matching-regexp-hist))
+
;;;;; Convenience commands as `denote' variants
(defalias 'denote-create-note 'denote
@@ -3619,9 +3629,6 @@ Otherwise sort lines while accounting for
`denote-link-add-links-sort'."
(sort-lines denote-link-add-links-sort (point-min) (point-max)))
(buffer-string)))
-(defvar denote-link--add-links-history nil
- "Minibuffer history for `denote-add-links'.")
-
(define-obsolete-function-alias
'denote-link-add-links
'denote-add-links
@@ -3652,7 +3659,7 @@ Optional ID-ONLY has the same meaning as in
`denote-link': it
inserts links with just the identifier."
(interactive
(list
- (read-regexp "Insert links matching REGEX: " nil
'denote-link--add-links-history)
+ (denote-files-matching-regexp-prompt "Insert links matching REGEXP")
current-prefix-arg))
(let ((file-type (denote-filetype-heuristics (buffer-file-name))))
(if-let ((files (denote-directory-files regexp :omit-current))