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

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

[nongnu] elpa/hyperdrive d0d444aab2 040/102: Change: (hyperdrive-mirror)


From: ELPA Syncer
Subject: [nongnu] elpa/hyperdrive d0d444aab2 040/102: Change: (hyperdrive-mirror) Rename PREDICATE argument to FILTER
Date: Wed, 29 Nov 2023 04:00:50 -0500 (EST)

branch: elpa/hyperdrive
commit d0d444aab267eca9071330aa20a33d5953807aa9
Author: Joseph Turner <joseph@ushin.org>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    Change: (hyperdrive-mirror) Rename PREDICATE argument to FILTER
    
    Since this argument is user-facing and we already say filter in
    hyperdrive-menu-hyperdrive, let's consistently use the simpler term.
---
 doc/hyperdrive.org   | 12 ++++++------
 doc/hyperdrive.texi  | 12 ++++++------
 hyperdrive-menu.el   |  4 ++--
 hyperdrive-mirror.el | 34 +++++++++++++++++-----------------
 4 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/doc/hyperdrive.org b/doc/hyperdrive.org
index b9c8083407..d84022528d 100644
--- a/doc/hyperdrive.org
+++ b/doc/hyperdrive.org
@@ -489,37 +489,37 @@ t~.  Interactively, use two universal prefix arguments 
~C-u C-u~.
 
 *** Mirror files by tag or other attributes
 
-~hyperdrive-mirror~ can accept a ~PREDICATE~ argument, which you can
+~hyperdrive-mirror~ can accept a ~FILTER~ argument, which you can
 use to upload only certain files.  Interactively, one universal prefix
-argument ~C-u~ make this command prompt you for ~PREDICATE~.
+argument ~C-u~ make this command prompt you for ~FILTER~.
 
 Let's say that you have some files on your filesystem in the ~~/blog/~
 directory, but you only want to upload those files which have been
 tagged as "public" using Protesilaos Stavrou's 
[[https://protesilaos.com/emacs/denote][Denote]] file-naming
 scheme.
 
-The following snippet includes a ~PREDICATE~ key whose value is a
+The following snippet includes a ~FILTER~ key whose value is a
 regular expression against which every expanded filename inside will
 be tested.
 
 #+begin_src elisp
 (hyperdrive-mirror "~/blog/" (hyperdrive-by-slot 'petname "foo")
                    :target-dir "/blog/"
-                   :predicate ".*_public.*")
+                   :filter ".*_public.*")
 #+end_src
 
 Alternatively, you could select files by tag with Karl Voit's
 [[https://github.com/novoid/filetags/][filetags]]. Either way allows for a 
"non-splitting" approach where
 public and private files exist in the same directory.
 
-~PREDICATE~ may also be a function, which receives the expanded filename
+~FILTER~ may also be a function, which receives the expanded filename
 as its only argument. For example, the following snippet will mirror
 only those files in ~~/blog/~ which are smaller than 5MB:
 
 #+begin_src elisp
 (hyperdrive-mirror "~/blog/" (hyperdrive-by-slot 'petname "foo")
                    :target-dir "/blog/"
-                   :predicate (lambda (file) (> (* 5 1024 1024)
+                   :filter (lambda (file) (> (* 5 1024 1024)
                                               (file-attribute-size 
(file-attributes file)))))
 #+end_src
 
diff --git a/doc/hyperdrive.texi b/doc/hyperdrive.texi
index a4845873e4..5b750f84d7 100644
--- a/doc/hyperdrive.texi
+++ b/doc/hyperdrive.texi
@@ -818,37 +818,37 @@ t}.  Interactively, use two universal prefix arguments 
@code{C-u C-u}.
 @node Mirror files by tag or other attributes
 @subsection Mirror files by tag or other attributes
 
-@code{hyperdrive-mirror} can accept a @code{PREDICATE} argument, which you can
+@code{hyperdrive-mirror} can accept a @code{FILTER} argument, which you can
 use to upload only certain files.  Interactively, one universal prefix
-argument @code{C-u} make this command prompt you for @code{PREDICATE}.
+argument @code{C-u} make this command prompt you for @code{FILTER}.
 
 Let's say that you have some files on your filesystem in the @code{~/blog/}
 directory, but you only want to upload those files which have been
 tagged as ``public'' using Protesilaos Stavrou's 
@uref{https://protesilaos.com/emacs/denote, Denote} file-naming
 scheme.
 
-The following snippet includes a @code{PREDICATE} key whose value is a
+The following snippet includes a @code{FILTER} key whose value is a
 regular expression against which every expanded filename inside will
 be tested.
 
 @lisp
 (hyperdrive-mirror "~/blog/" (hyperdrive-by-slot 'petname "foo")
                    :target-dir "/blog/"
-                   :predicate ".*_public.*")
+                   :filter ".*_public.*")
 @end lisp
 
 Alternatively, you could select files by tag with Karl Voit's
 @uref{https://github.com/novoid/filetags/, filetags}. Either way allows for a 
``non-splitting'' approach where
 public and private files exist in the same directory.
 
-@code{PREDICATE} may also be a function, which receives the expanded filename
+@code{FILTER} may also be a function, which receives the expanded filename
 as its only argument. For example, the following snippet will mirror
 only those files in @code{~/blog/} which are smaller than 5MB:
 
 @lisp
 (hyperdrive-mirror "~/blog/" (hyperdrive-by-slot 'petname "foo")
                    :target-dir "/blog/"
-                   :predicate (lambda (file) (> (* 5 1024 1024)
+                   :filter (lambda (file) (> (* 5 1024 1024)
                                               (file-attribute-size 
(file-attributes file)))))
 @end lisp
 
diff --git a/hyperdrive-menu.el b/hyperdrive-menu.el
index 1df34e4cb3..38ec12a59a 100644
--- a/hyperdrive-menu.el
+++ b/hyperdrive-menu.el
@@ -275,7 +275,7 @@
   (hyperdrive-mirror (or hyperdrive-mirror-source default-directory)
                      (hyperdrive-menu--scope)
                      :target-dir hyperdrive-mirror-target
-                     :predicate hyperdrive-mirror-filter
+                     :filter hyperdrive-mirror-filter
                      :no-confirm (not hyperdrive-mirror-confirm)))
 
 ;; TODO(transient): Use a suffix class, so these commands can be invoked
@@ -338,7 +338,7 @@
                     ;; TODO: Fontify the whole lambda.
                     ((and (pred consp) it) (propertize (prin1-to-string it) 
'face 'default))))
   :reader (lambda (_prompt _default _history)
-            (hyperdrive-mirror-read-predicate)))
+            (hyperdrive-mirror-read-filter)))
 
 (transient-define-infix hyperdrive-mirror-set-confirm ()
   :class 'hyperdrive-mirror-variable
diff --git a/hyperdrive-mirror.el b/hyperdrive-mirror.el
index 78d197b184..72224586bb 100644
--- a/hyperdrive-mirror.el
+++ b/hyperdrive-mirror.el
@@ -145,11 +145,11 @@ Runs `hyperdrive-mirror' again with the same query."
 
 ;;;###autoload
 (cl-defun hyperdrive-mirror
-    (source hyperdrive &key target-dir (predicate #'always) no-confirm)
+    (source hyperdrive &key target-dir (filter #'always) no-confirm)
   "Mirror SOURCE to TARGET-DIR in HYPERDRIVE.
 
-Only mirror paths within SOURCE for which PREDICATE returns
-non-nil.  PREDICATE may be a function, which receives the expanded
+Only mirror paths within SOURCE for which FILTER returns
+non-nil.  FILTER may be a function, which receives the expanded
 filename path as its argument, or a regular expression, which is
 tested against each expanded filename path.  SOURCE is a directory
 name.
@@ -164,10 +164,10 @@ be uploaded and the URL at which each file will be 
published.  See
 When NO-CONFIRM is non-nil, upload without prompting.
 
 Interactively, with one universal prefix argument
-\\[universal-argument], prompt for predicate, otherwise mirror
+\\[universal-argument], prompt for filter, otherwise mirror
 all files. With two universal prefix arguments
 \\[universal-argument] \\[universal-argument], prompt for
-predicate and set NO-CONFIRM to t."
+filter and set NO-CONFIRM to t."
   (interactive
    (let ((source (read-directory-name "Mirror directory: " nil nil t))
          (hyperdrive (hyperdrive-complete-hyperdrive :predicate 
#'hyperdrive-writablep
@@ -177,16 +177,16 @@ predicate and set NO-CONFIRM to t."
            ;; auto-fill (or add as "future history") in target-dir prompt.
            :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
-                          (hyperdrive-mirror-read-predicate)
-                        #'always))))
+           :filter (if current-prefix-arg
+                       (hyperdrive-mirror-read-filter)
+                     #'always))))
   (cl-callf expand-file-name source)
   (setf target-dir (hyperdrive--format-path target-dir :directoryp t))
-  (when (stringp predicate)
-    (let ((regexp predicate))
-      (setf predicate (lambda (filename)
-                        (string-match-p regexp filename)))))
-  (let* ((files (cl-remove-if-not predicate (directory-files-recursively 
source ".")))
+  (when (stringp filter)
+    (let ((regexp filter))
+      (setf filter (lambda (filename)
+                     (string-match-p regexp filename)))))
+  (let* ((files (cl-remove-if-not filter (directory-files-recursively source 
".")))
          (parent-entry (hyperdrive-entry-create :hyperdrive hyperdrive :path 
target-dir))
          (buffer (unless no-confirm
                    (get-buffer-create "*hyperdrive-mirror*")))
@@ -194,7 +194,7 @@ predicate and set NO-CONFIRM to t."
          (num-of (length files))
          metadata-queue files-and-urls)
     (unless files
-      (hyperdrive-user-error "No files selected for mirroring (double-check 
predicate)"))
+      (hyperdrive-user-error "No files selected for mirroring (double-check 
filter)"))
     (if no-confirm
         (hyperdrive--mirror files-and-urls parent-entry)
       (with-current-buffer buffer
@@ -208,7 +208,7 @@ predicate and set NO-CONFIRM to t."
                                                   'face 
'font-lock-comment-face)))))))
             (hyperdrive-mirror-mode)
             (setq-local hyperdrive-mirror-query
-                        `(,source ,hyperdrive :target-dir ,target-dir 
:predicate ,predicate)
+                        `(,source ,hyperdrive :target-dir ,target-dir :filter 
,filter)
                         hyperdrive-mirror-parent-entry parent-entry)
             ;; TODO: Add command to clear plz queue.
             (setf metadata-queue
@@ -339,7 +339,7 @@ grouping keys, as in `hyperdrive-mirror-default-keys'."
           (taxy-magit-section-insert taxy :items 'first :initial-depth 0))
         taxy))))
 
-(defun hyperdrive-mirror-read-predicate ()
+(defun hyperdrive-mirror-read-filter ()
   "Read a function for filtering source files for mirroring."
   (let* ((readers
           '(("Mirror all files" . nil)
@@ -351,7 +351,7 @@ grouping keys, as in `hyperdrive-mirror-default-keys'."
              (lambda () (intern (completing-read "Named function: " obarray 
#'functionp t))))))
          ;; TODO(transient): Implement returning values from prefixes,
          ;; allowing us to use a sub-prefix here instead of completing-read.
-         (reader (completing-read "Predicate type: " readers nil t))
+         (reader (completing-read "Filter type: " readers nil t))
          (reader (alist-get reader readers nil nil #'equal)))
     (and reader (funcall reader))))
 



reply via email to

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