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

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

[nongnu] elpa/projectile b952a02 1/3: [Fix #1511] projectile-ripgrep: su


From: ELPA Syncer
Subject: [nongnu] elpa/projectile b952a02 1/3: [Fix #1511] projectile-ripgrep: support rg.el package
Date: Thu, 19 Aug 2021 04:57:32 -0400 (EDT)

branch: elpa/projectile
commit b952a02124da385c3b5e5ea485baa86d62db9568
Author: condy <condy0919@gmail.com>
Commit: Bozhidar Batsov <bozhidar@batsov.dev>

    [Fix #1511] projectile-ripgrep: support rg.el package
---
 CHANGELOG.md  |  4 ++++
 projectile.el | 28 ++++++++++++++++++----------
 2 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 45f4782..76fe104 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
 
 ## master (unreleased)
 
+### New features
+
+* [#1699](https://github.com/bbatsov/projectile/pull/1699): 
`projectile-ripgrep` supports [`rg.el`](https://github.com/dajva/rg.el)
+
 ## 2.5.0 (2021-08-10)
 
 ### New features
diff --git a/projectile.el b/projectile.el
index 33571d3..7c3ccbd 100644
--- a/projectile.el
+++ b/projectile.el
@@ -75,6 +75,7 @@
 (declare-function ggtags-ensure-project "ext:ggtags")
 (declare-function ggtags-update-tags "ext:ggtags")
 (declare-function ripgrep-regexp "ext:ripgrep")
+(declare-function rg-run "ext:rg")
 (declare-function vterm "ext:vterm")
 (declare-function vterm-send-return "ext:vterm")
 (declare-function vterm-send-string "ext:vterm")
@@ -3830,16 +3831,23 @@ regular expression."
    (list (projectile--read-search-string-with-default
           (format "Ripgrep %ssearch for" (if current-prefix-arg "regexp " "")))
          current-prefix-arg))
-  (if (require 'ripgrep nil 'noerror)
-      (let ((args (mapcar (lambda (val) (concat "--glob !" val))
-                          (append projectile-globally-ignored-files
-                                  projectile-globally-ignored-directories))))
-        (ripgrep-regexp search-term
-                        (projectile-acquire-root)
-                        (if arg
-                            args
-                          (cons "--fixed-strings" args))))
-    (error "Package `ripgrep' is not available")))
+  (let ((args (mapcar (lambda (val) (concat "--glob !" val))
+                      (append projectile-globally-ignored-files
+                              projectile-globally-ignored-directories))))
+    (cond ((require 'ripgrep nil 'noerror)
+           (ripgrep-regexp search-term
+                           (projectile-acquire-root)
+                           (if arg
+                               args
+                             (cons "--fixed-strings" args))))
+          ((require 'rg nil 'noerror)
+           (rg-run search-term
+                   "*"                       ;; all files
+                   (projectile-acquire-root)
+                   (not arg)                 ;; literal search?
+                   nil                       ;; no need to confirm
+                   args))
+          (t (error "Package `ripgrep' and `rg' are not available")))))
 
 (defun projectile-tags-exclude-patterns ()
   "Return a string with exclude patterns for ctags."



reply via email to

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