branch: elpa/hyperdrive
commit 6d23e595b5d58e5c71d0098127b2ead4e89eda7f
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
Add/Change: (-mirror-read-prediate) New function
Created from existing code, previously in `hyperdrive-mirror'.
---
hyperdrive-mirror.el | 33 ++++++++++++++++++---------------
1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/hyperdrive-mirror.el b/hyperdrive-mirror.el
index 9146edd90b..5ce73f5a31 100644
--- a/hyperdrive-mirror.el
+++ b/hyperdrive-mirror.el
@@ -113,21 +113,7 @@ predicate and set NO-CONFIRM to t."
:target-dir (hyperdrive-read-path :hyperdrive hyperdrive :prompt
"Target directory in «%s»" :default "/")
:no-confirm (equal '(16) current-prefix-arg)
:predicate (if current-prefix-arg
- (let* ((collection
- '(("Mirror all files" . (lambda ()
- #'always))
- ("`rx' form" . (lambda ()
- (eval (read--expression
"`rx' form: " "(rx )"))))
- ("Regexp string" . (lambda ()
- (read-regexp "Regular
expression: ")))
- ("Lambda function" . (lambda ()
- (read--expression
"Lambda: " "(lambda (filename) )")))
- ("Named function" .
- (lambda ()
- (completing-read "Named function: "
obarray #'functionp t)))))
- (choice (completing-read "Predicate type: "
collection))
- (result (funcall (alist-get choice collection
nil nil #'equal))))
- result)
+ (hyperdrive-mirror-read-predicate)
#'always))))
(cl-callf expand-file-name source)
(setf target-dir (hyperdrive--format-path target-dir :directoryp t))
@@ -205,6 +191,23 @@ predicate and set NO-CONFIRM to t."
(hyperdrive-entry-url entry)
plz-error))))))))
(pop-to-buffer (current-buffer))))))))
+(defun hyperdrive-mirror-read-predicate ()
+ "Read a function for filtering source files for mirroring."
+ (let* ((collection
+ '(("Mirror all files" .
+ (lambda () #'always))
+ ("`rx' form" .
+ (lambda () (eval (read--expression "`rx' form: " "(rx )"))))
+ ("Regexp string" .
+ (lambda () (read-regexp "Regular expression: ")))
+ ("Lambda function" .
+ (lambda () (read--expression "Lambda: " "(lambda (filename) )")))
+ ("Named function" .
+ (lambda () (completing-read "Named function: " obarray
#'functionp t)))))
+ (choice (completing-read "Predicate type: " collection))
+ (result (funcall (alist-get choice collection nil nil #'equal))))
+ result))
+
(defun hyperdrive-mirror-do-upload ()
"Upload files in current \"*hyperdrive-mirror*\" buffer."
(declare (modes hyperdrive-mirror-mode))