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

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

[elpa] externals/urgrep dfda4599ef 1/3: Change `:files` to `:file-wildca


From: ELPA Syncer
Subject: [elpa] externals/urgrep dfda4599ef 1/3: Change `:files` to `:file-wildcard`
Date: Sun, 19 Nov 2023 03:58:43 -0500 (EST)

branch: externals/urgrep
commit dfda4599ef9633db993f68f33fec61e0b9d92d16
Author: Jim Porter <jporterbugs@gmail.com>
Commit: Jim Porter <jporterbugs@gmail.com>

    Change `:files` to `:file-wildcard`
---
 NEWS.md         |  4 ++++
 urgrep-tests.el | 29 ++++++++++++-----------
 urgrep.el       | 72 +++++++++++++++++++++++++++++----------------------------
 3 files changed, 56 insertions(+), 49 deletions(-)

diff --git a/NEWS.md b/NEWS.md
index ceab95e0c2..10459c8593 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -5,6 +5,10 @@
 ### Bug fixes
 - Respect buffer-local values of `urgrep-preferred-tools`
 
+### Breaking changes
+- `:files` keyword argument in `urgrep-command` and friends is now
+  `:file-wildcard`
+
 ---
 
 ## v0.2.0 (2023-08-31)
diff --git a/urgrep-tests.el b/urgrep-tests.el
index f005b54ef2..ac2824c371 100644
--- a/urgrep-tests.el
+++ b/urgrep-tests.el
@@ -192,11 +192,11 @@ joined to compare against COMMAND."
        `(,@common-args "--hidden" "--heading" "--break" "-i" "-F" "-e" "foo")))
     (ert-info ("File wildcard")
       (urgrep-tests/check-command
-       (urgrep-command "foo" :tool tool :files "*.el")
+       (urgrep-command "foo" :tool tool :file-wildcard "*.el")
        `(,@common-args "--include=*.el" "--heading" "--break" "-i" "-F" "-e"
                        "foo"))
       (urgrep-tests/check-command
-       (urgrep-command "foo" :tool tool :files '("*.c" "*.h"))
+       (urgrep-command "foo" :tool tool :file-wildcard '("*.c" "*.h"))
        `(,@common-args "--include=*.c" "--include=*.h" "--heading" "--break"
                        "-i" "-F" "-e" "foo")))
     (ert-info ("Directory")
@@ -275,10 +275,10 @@ joined to compare against COMMAND."
        `(,@common-args "--hidden" "--heading" "-i" "-F" "--" "foo")))
     (ert-info ("File wildcard")
       (urgrep-tests/check-command
-       (urgrep-command "foo" :tool tool :files "*.el")
+       (urgrep-command "foo" :tool tool :file-wildcard "*.el")
        `(,@common-args "-g" "*.el" "--heading" "-i" "-F" "--" "foo"))
       (urgrep-tests/check-command
-       (urgrep-command "foo" :tool tool :files '("*.c" "*.h"))
+       (urgrep-command "foo" :tool tool :file-wildcard '("*.c" "*.h"))
        `(,@common-args "-g" "*.c" "-g" "*.h" "--heading" "-i" "-F" "--" 
"foo")))
     (ert-info ("Directory")
       (urgrep-tests/check-command
@@ -348,10 +348,10 @@ joined to compare against COMMAND."
        `(,@common-args "--group" "-B2" "-A4" "-i" "-Q" "--" "foo")))
     (ert-info ("File wildcard")
       (urgrep-tests/check-command
-       (urgrep-command "foo" :tool tool :files "*.el")
+       (urgrep-command "foo" :tool tool :file-wildcard "*.el")
        `(,@common-args "-G" "^[^\\000]*\\.el$" "--group" "-i" "-Q" "--" "foo"))
       (urgrep-tests/check-command
-       (urgrep-command "foo" :tool tool :files '("*.c" "*.h"))
+       (urgrep-command "foo" :tool tool :file-wildcard '("*.c" "*.h"))
        `(,@common-args "-G" "^[^\\000]*\\.(c|h)$" "--group" "-i" "-Q" "--"
                        "foo")))
     (ert-info ("Directory")
@@ -430,11 +430,11 @@ joined to compare against COMMAND."
        `(,@common-args "--group" "-i" "-Q" "--" "foo")))
     (ert-info ("File wildcard")
       (urgrep-tests/check-command
-       (urgrep-command "foo" :tool tool :files "*.el")
+       (urgrep-command "foo" :tool tool :file-wildcard "*.el")
        `(,@common-args ,@no-hidden-args "-G" "^[^\\000]*\\.el$" "--group" "-i"
                        "-Q" "--" "foo"))
       (urgrep-tests/check-command
-       (urgrep-command "foo" :tool tool :files '("*.c" "*.h"))
+       (urgrep-command "foo" :tool tool :file-wildcard '("*.c" "*.h"))
        `(,@common-args ,@no-hidden-args "-G" "^[^\\000]*\\.(c|h)$" "--group"
                        "-i" "-Q" "--" "foo")))
     (ert-info ("Directory")
@@ -523,11 +523,11 @@ joined to compare against COMMAND."
        `(,@common-args ,@group-args "-i" "-F" "-e" "foo" "--")))
     (ert-info ("File wildcard")
       (urgrep-tests/check-command
-       (urgrep-command "foo" :tool tool :files "*.el")
+       (urgrep-command "foo" :tool tool :file-wildcard "*.el")
        `(,@common-args ,@group-args "-i" "-F" "-e" "foo" "--" ,@no-hidden-args
                        "*.el"))
       (urgrep-tests/check-command
-       (urgrep-command "foo" :tool tool :files '("*.c" "*.h"))
+       (urgrep-command "foo" :tool tool :file-wildcard '("*.c" "*.h"))
        `(,@common-args ,@group-args "-i" "-F" "-e" "foo" "--" ,@no-hidden-args
                        "*.c" "*.h")))
     (ert-info ("Directory")
@@ -541,11 +541,11 @@ joined to compare against COMMAND."
                        "dir1" "dir2")))
     (ert-info ("File wildcard + Directory")
       (urgrep-tests/check-command
-       (urgrep-command "foo" :tool tool :files "*.el" :directory "dir")
+       (urgrep-command "foo" :tool tool :file-wildcard "*.el" :directory "dir")
        `(,@common-args ,@group-args "-i" "-F" "-e" "foo" "--" ,@no-hidden-args
                        ":(glob)dir/**/*.el"))
       (urgrep-tests/check-command
-       (urgrep-command "foo" :tool tool :files '("*.c" "*.h")
+       (urgrep-command "foo" :tool tool :file-wildcard '("*.c" "*.h")
                        :directory '("dir1" "dir2"))
        `(,@common-args ,@group-args "-i" "-F" "-e" "foo" "--" ,@no-hidden-args
                        ":(glob)dir1/**/*.c" ":(glob)dir2/**/*.c"
@@ -615,13 +615,14 @@ joined to compare against COMMAND."
                  (format template "."
                          (concat "-i?name " (funcall escape "*.el") " ")
                          "--color=always -i -F" "foo")
-                 (urgrep-command "foo" :tool tool :files "*.el")))
+                 (urgrep-command "foo" :tool tool :file-wildcard "*.el")))
         (should (string-match
                  (format template "."
                          (concat "-i?name " (funcall escape "*.c") " -o "
                                  "-i?name " (funcall escape "*.h") " ")
                          "--color=always -i -F" "foo")
-                 (urgrep-command "foo" :tool tool :files '("*.c" "*.h"))))))
+                 (urgrep-command "foo" :tool tool
+                                 :file-wildcard '("*.c" "*.h"))))))
     (ert-info ("Directory")
       (should (string-match
                (format template "dir" "" "--color=always -i -F" "foo")
diff --git a/urgrep.el b/urgrep.el
index 24037a3412..71cc817173 100644
--- a/urgrep.el
+++ b/urgrep.el
@@ -239,17 +239,17 @@ properties defined in the `urgrep-tools' entry for TOOL."
     ((or `(,c . ,c) (and c (pred numberp))) (list (format "-C%d" c)))
     (`(,b . ,a) (list (format "-B%d" b) (format "-A%d" a)))))
 
-(cl-defun urgrep--rgrep-command (query &key tool regexp case-fold hidden files
-                                       directory context color
+(cl-defun urgrep--rgrep-command (query &key tool regexp case-fold hidden
+                                       file-wildcard directory context color
                                        &allow-other-keys)
   "Get the command to run for QUERY when using rgrep.
-Optional keys TOOL, REGEXP, CASE-FOLD, HIDDEN, FILES, DIRECTORY,
-CONTEXT, and COLOR are as in `urgrep-command'."
+Optional keys TOOL, REGEXP, CASE-FOLD, HIDDEN, FILE-WILDCARD,
+DIRECTORY, CONTEXT, and COLOR are as in `urgrep-command'."
   (grep-compute-defaults)
   ;; Locally add options to `grep-find-template' that grep.el isn't aware of.
   (let ((grep-find-template grep-find-template)
         (grep-highlight-matches (if color 'always nil))
-        (files (if files (mapconcat #'identity files " ") "*"))
+        (file-wildcard (if file-wildcard (string-join file-wildcard " ") "*"))
         (directory (when directory
                      (mapconcat #'urgrep--maybe-shell-quote-argument
                                 directory " "))))
@@ -272,7 +272,7 @@ CONTEXT, and COLOR are as in `urgrep-command'."
               grep-find-ignored-files
               (cons ".*" (seq-filter (lambda (s) (not (string-prefix-p "." s)))
                                      grep-find-ignored-files))))
-      (let ((command (rgrep-default-command query files directory)))
+      (let ((command (rgrep-default-command query file-wildcard directory)))
         (save-match-data
           ;; Hide excessive part of rgrep command.
           (when (string-match
@@ -283,19 +283,20 @@ CONTEXT, and COLOR are as in `urgrep-command'."
         command))))
 
 (cl-defun urgrep--git-grep-command (query &key tool regexp case-fold hidden
-                                          files directory group context color)
+                                          file-wildcard directory group context
+                                          color)
   "Get the command to run for QUERY when using git grep.
-Optional keys TOOL, REGEXP, CASE-FOLD, HIDDEN, FILES, DIRECTORY,
-CONTEXT, and COLOR are as in `urgrep-command'."
+Optional keys TOOL, REGEXP, CASE-FOLD, HIDDEN, FILE-WILDCARD,
+DIRECTORY, CONTEXT, and COLOR are as in `urgrep-command'."
   (let ((pathspecs
-         (if (and files directory)
+         (if (and file-wildcard directory)
              (mapcan
               (lambda (file)
                 (mapcar (lambda (dir)
                           (concat ":(glob)" (file-name-concat dir "**" file)))
                         directory))
-              files)
-           (or files directory))))
+              file-wildcard)
+           (or file-wildcard directory))))
     (urgrep--interpolate-arguments query tool
                                    `((regexp      . ,regexp)
                                      (case-fold   . ,case-fold)
@@ -321,7 +322,7 @@ See also `grep-process-setup'."
      (executable-name . "ugrep")
      (regexp-syntax bre ere pcre)
      (arguments executable (:abbreviate color "-rn" "--ignore-files")
-                hidden-file file-wildcards group context case-fold regexp "-e"
+                hidden-file file-wildcard group context case-fold regexp "-e"
                 query directory)
      (regexp-arguments ('bre  '("-G"))
                        ('ere  '("-E"))
@@ -329,7 +330,7 @@ See also `grep-process-setup'."
                        (_     '("-F")))
      (case-fold-arguments ((pred identity) '("-i")))
      (hidden-file-arguments ((pred identity) '("--hidden")))
-     (file-wildcards-arguments
+     (file-wildcard-arguments
       ((and x (pred identity))
        (mapcar (lambda (i) (concat "--include=" i)) x)))
      (directory-arguments (x x))
@@ -342,12 +343,12 @@ See also `grep-process-setup'."
     (ripgrep
      (executable-name . "rg")
      (regexp-syntax pcre)
-     (arguments executable (:abbreviate color) hidden-file file-wildcards group
+     (arguments executable (:abbreviate color) hidden-file file-wildcard group
                 context case-fold regexp "--" query directory)
      (regexp-arguments ('nil '("-F")))
      (case-fold-arguments ((pred identity) '("-i")))
      (hidden-file-arguments ((pred identity) '("--hidden")))
-     (file-wildcards-arguments
+     (file-wildcard-arguments
       ((and x (pred identity))
        (flatten-list (mapcar (lambda (i) (cons "-g" i)) x))))
      (directory-arguments (x x))
@@ -363,13 +364,13 @@ See also `grep-process-setup'."
     (ag
      (executable-name . "ag")
      (regexp-syntax pcre)
-     (arguments executable (:abbreviate color) hidden-file file-wildcards group
+     (arguments executable (:abbreviate color) hidden-file file-wildcard group
                 context case-fold regexp "--" query directory)
      (regexp-arguments ('nil '("-Q")))
      (case-fold-arguments ('nil '("-s"))
                           (_    '("-i")))
      (hidden-file-arguments ((pred identity) '("--hidden")))
-     (file-wildcards-arguments
+     (file-wildcard-arguments
       ((and x (pred identity))
        (list "-G" (urgrep--wildcards-to-regexp x 'pcre))))
      (directory-arguments (x x))
@@ -382,13 +383,13 @@ See also `grep-process-setup'."
     (ack
      (executable-name . "ack")
      (regexp-syntax pcre)
-     (arguments executable (:abbreviate color) hidden-file file-wildcards group
+     (arguments executable (:abbreviate color) hidden-file file-wildcard group
                 context case-fold regexp "--" query directory)
      (regexp-arguments ('nil '("-Q")))
      (case-fold-arguments ((pred identity) '("-i")))
      (hidden-file-arguments ('nil '("--ignore-dir=match:/^\\./"
                                     "--ignore-file=match:/^\\./")))
-     (file-wildcards-arguments
+     (file-wildcard-arguments
       ((and x (pred identity))
        (list "-G" (urgrep--wildcards-to-regexp x 'pcre))))
      (directory-arguments (x x))
@@ -596,7 +597,8 @@ it up in `urgrep-tools'.  Otherwise, return TOOL as-is."
 
 ;;;###autoload
 (cl-defun urgrep-command (query &key tool regexp (case-fold 'inherit) hidden
-                                files directory (group t) (context 0) (color 
t))
+                                file-wildcard directory (group t) (context 0)
+                                (color t))
   "Return a command to use to search for QUERY.
 Several keyword arguments can be supplied to adjust the resulting
 command:
@@ -615,8 +617,8 @@ possible values are as `urgrep-case-fold', defaulting to
 
 HIDDEN: non-nil to search in hidden files; defaults to nil.
 
-FILES: a wildcard (or list of wildcards) to limit the files
-searched.
+FILE-WILDCARD: a wildcard (or list of wildcards) to limit the
+files searched.
 
 GROUP: show results grouped by filename (t, the default), or if
 nil, prefix the filename on each result line.
@@ -629,7 +631,7 @@ respectively).
 COLOR: non-nil (the default) if the output should use color."
   (with-connection-local-variables
    (let* ((regexp-syntax (if (eq regexp t) urgrep-regexp-syntax regexp))
-          (files (ensure-list files))
+          (file-wildcard (ensure-list file-wildcard))
           (directory (ensure-list directory))
           (tool (or (urgrep-get-tool tool)
                     (error "unknown tool %s" tool)))
@@ -644,18 +646,18 @@ COLOR: non-nil (the default) if the output should use 
color."
      ;; Build the command arguments.
      (if cmd-fun
          (funcall cmd-fun query :tool tool :regexp tool-re-syntax
-                  :case-fold case-fold :hidden hidden :files files
-                  :directory directory :group group :context context
-                  :color color)
+                  :case-fold case-fold :hidden hidden
+                  :file-wildcard file-wildcard :directory directory
+                  :group group :context context :color color)
        (urgrep--interpolate-arguments query tool
-                                      `((regexp         . ,tool-re-syntax)
-                                        (case-fold      . ,case-fold)
-                                        (hidden-file    . ,hidden)
-                                        (file-wildcards . ,files)
-                                        (directory      . ,directory)
-                                        (group          . ,group)
-                                        (context        . ,context)
-                                        (color          . ,color)))))))
+                                      `((regexp        . ,tool-re-syntax)
+                                        (case-fold     . ,case-fold)
+                                        (hidden-file   . ,hidden)
+                                        (file-wildcard . ,file-wildcard)
+                                        (directory     . ,directory)
+                                        (group         . ,group)
+                                        (context       . ,context)
+                                        (color         . ,color)))))))
 
 
 ;; urgrep-mode



reply via email to

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