~protesilaos/denote

9d6b50b0c10623acaee8f1301709a343b4d05b6e — Protesilaos Stavrou 2 months ago 9c24528
Add single prompt function for all "files matching regexp" type of prompts
4 files changed, 19 insertions(+), 18 deletions(-)

M README.org
M denote-org-dblock.el
M denote-sort.el
M denote.el
M README.org => README.org +5 -0
@@ 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~.

M denote-org-dblock.el => denote-org-dblock.el +2 -6
@@ 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"

M denote-sort.el => denote-sort.el +1 -8
@@ 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))

M denote.el => denote.el +11 -4
@@ 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))