Skip to content

Commit 1b59e35

Browse files
committed
Deprecate projectile-ag and the ripgrep.el path of projectile-ripgrep
The Silver Searcher has had no commits since 2020 and ag.el is archived, as is ripgrep.el. projectile-ag, the ag search backend and the ripgrep.el branch of projectile-ripgrep keep working until 4.0, and each says once per session that it is going away and what to use instead. The command keeps its key, dispatch entry and menu item for the same period, hence the two suppressed obsolete warnings.
1 parent c22cbf4 commit 1b59e35

8 files changed

Lines changed: 113 additions & 26 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323

2424
### Changes
2525

26+
- [#2205](https://github.com/bbatsov/projectile/pull/2205): Deprecate `projectile-ag` and the `ag` search backend, to be removed in Projectile 4.0. The Silver Searcher has not been developed since 2020 and the `ag` package is archived; `projectile-ripgrep` and `projectile-search-review` take its place.
27+
- Running `projectile-ripgrep` through the archived `ripgrep` package is deprecated as well, in favour of the `rg` package.
28+
- Each warns once per session when used.
2629
- [#2205](https://github.com/bbatsov/projectile/pull/2205): `projectile-ripgrep` now uses the `rg` package when both `rg` and `ripgrep` are installed, instead of the other way around. `ripgrep` was archived by its author in 2022.
2730
- [#2205](https://github.com/bbatsov/projectile/pull/2205): `projectile-replace` and the replace reviewer no longer use `ag` to narrow down the files to look at; `rg`, `git grep` and `grep` do that now.
2831
- [#2204](https://github.com/bbatsov/projectile/pull/2204): `projectile-replace` and the replace reviewer no longer use `ack` to narrow down the files to look at. It was only ever reached with `ack` installed and neither `rg` nor `ag`, where `git grep` or `grep` now do the same job.

‎doc/modules/ROOT/pages/cheatsheet.adoc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ Here's a list of the interactive Emacs Lisp functions, provided by Projectile:
8989

9090
| kbd:[s-p s r]
9191
| `projectile-ripgrep`
92-
| Runs `rg` (`ripgrep`) on the project, performing a literal search. Requires the presence of `rg.el` or `ripgrep.el`. With a prefix argument it will perform a regex search.
92+
| Runs `rg` (`ripgrep`) on the project, performing a literal search. Requires the presence of `rg.el` (the archived `ripgrep.el` still works, but support for it is deprecated). With a prefix argument it will perform a regex search.
9393

9494
| kbd:[s-p s a]
9595
| `projectile-ag`
96-
| Runs `ag` (`the_silver_searcher`) on the project, performing a literal search. Requires the presence of `ag.el`. With a prefix argument it will perform a regex search.
96+
| Runs `ag` (`the_silver_searcher`) on the project, performing a literal search. Requires the presence of `ag.el`. With a prefix argument it will perform a regex search. Deprecated: `ag` is no longer maintained, and the command will be removed in Projectile 4.0.
9797

9898
| kbd:[s-p s x] or kbd:[s-p ?]
9999
| `projectile-find-references`

‎doc/modules/ROOT/pages/configuration.adoc‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,11 @@ The dedicated commands `projectile-grep` (kbd:[s-p s g]), `projectile-ripgrep`
424424
(kbd:[s-p s r]) and `projectile-ag` (kbd:[s-p s a]) still exist; they're just
425425
`projectile-search` with a forced backend.
426426

427+
NOTE: The `ag` backend and `projectile-ag` are deprecated as of Projectile 3.5
428+
and will be removed in 4.0 - neither The Silver Searcher nor the `ag` package
429+
is maintained any longer. The same goes for running `projectile-ripgrep`
430+
through the archived `ripgrep` package: install `rg` and it's used instead.
431+
427432
For the `grep` backend, in Git projects you can use `vc-git-grep` instead of
428433
`rgrep`, which tends to be faster as it respects `.gitignore`:
429434

‎doc/modules/ROOT/pages/index.adoc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Here are some of Projectile's features in no particular order:
4747
* kill (close) all project buffers
4848
* xref:usage.adoc#reviewing-and-applying-replacements[replace in project], with a reviewable before/after preview
4949
* multi-occur in project buffers
50-
* xref:usage.adoc#reviewing-search-matches[grep (search) in project] (multiple back-ends like `ag`, `rg`, and a native reviewable results UI)
50+
* xref:usage.adoc#reviewing-search-matches[grep (search) in project] (back-ends like `grep` and `rg`, and a native reviewable results UI)
5151
* find references in project (using `xref` internally)
5252
* visit project in `dired`
5353
* run xref:tasks.adoc#project-tasks[project commands and tasks] (build/test/run, your own named tasks, and the npm scripts, Make targets and justfile recipes a project already defines)

‎doc/modules/ROOT/pages/projectile_vs_project.adoc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ Side-by-side mapping of the most common entry points. Useful both when picking b
260260
| —
261261

262262
| Ag
263-
| `projectile-ag`
263+
| `projectile-ag` (deprecated)
264264
| —
265265

266266
| Find regex via xref

‎doc/modules/ROOT/pages/usage.adoc‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ Here's how a typical Projectile configuration would look:
6464

6565
[source,elisp]
6666
----
67-
;; Optional: ag is nice alternative to using grep with Projectile
68-
(use-package ag
67+
;; Optional: rg is a nice alternative to using grep with Projectile
68+
(use-package rg
6969
:ensure t)
7070
7171
;; Optional: Enable vertico as the selection framework to use with Projectile
@@ -195,12 +195,11 @@ the deletions are staged, which can be confusing. You can eliminate
195195
the use of fd in this circumstance by setting `projectile-git-use-fd`
196196
to nil.
197197

198-
To benefit from the `projectile-ag` and `projectile-ripgrep` commands
199-
to perform file search, it's recommended to install
200-
https://github.com/ggreer/the_silver_searcher[ag] (`the_silver_searcher`) and/or
201-
https://github.com/BurntSushi/ripgrep[rg] (`ripgrep`)
198+
To benefit from the `projectile-ripgrep` command, and to make the
199+
xref:usage.adoc#reviewing-search-matches[reviewable search] faster, it's
200+
recommended to install https://github.com/BurntSushi/ripgrep[rg] (`ripgrep`).
202201

203-
TIP: You should also install the Emacs packages `ag`, `ripgrep` or `rg` if you want to make use of Projectile's commands `projectile-ag` and `projectile-ripgrep`.
202+
TIP: `projectile-ripgrep` also needs the Emacs package `rg`. The reviewable search talks to `rg` directly and needs no package.
204203

205204
== Interactive commands
206205

‎projectile.el‎

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -916,13 +916,15 @@ Either a backend name registered in `projectile-search-backends'
916916
\(`grep', `ripgrep', `ag', or one you registered yourself with
917917
`projectile-register-search-backend'), `auto' to pick the first
918918
available backend (favouring ripgrep, then grep), or `prompt' to be
919-
asked which backend to use each time."
919+
asked which backend to use each time.
920+
921+
The `ag' backend is deprecated and will be removed in Projectile 4.0."
920922
:group 'projectile
921923
:type '(choice (const :tag "Automatic" auto)
922924
(const :tag "Prompt each time" prompt)
923925
(const :tag "grep" grep)
924926
(const :tag "ripgrep" ripgrep)
925-
(const :tag "ag" ag)
927+
(const :tag "ag (deprecated)" ag)
926928
(symbol :tag "Other registered backend"))
927929
:package-version '(projectile . "3.0.0"))
928930

@@ -8662,12 +8664,27 @@ left matches at any depth, which is as close as `ag' gets."
86628664
(t body))))
86638665
(projectile--ignore-patterns))))
86648666

8667+
(defvar projectile--deprecations-warned nil
8668+
"The deprecated features this session has already been warned about.")
8669+
8670+
(defun projectile--warn-deprecated (feature message)
8671+
"Warn that FEATURE is deprecated, with MESSAGE, once per session."
8672+
(unless (memq feature projectile--deprecations-warned)
8673+
(push feature projectile--deprecations-warned)
8674+
(display-warning 'projectile message :warning)))
8675+
86658676
(defun projectile--ag (search-term &optional regexp)
86668677
"Run an `ag' search for SEARCH-TERM in the project.
86678678
When REGEXP is non-nil, SEARCH-TERM is treated as a regular expression.
8668-
Requires the `ag' Emacs package."
8679+
Requires the `ag' Emacs package.
8680+
8681+
Deprecated: neither The Silver Searcher nor the `ag' package is
8682+
maintained any longer, and this backend goes away in Projectile 4.0."
86698683
(unless (require 'ag nil 'noerror)
86708684
(user-error "Package `ag' is not available"))
8685+
(projectile--warn-deprecated
8686+
'ag
8687+
"The ag search backend is deprecated and will be removed in Projectile 4.0: The Silver Searcher and the `ag' package are no longer maintained. Use `projectile-ripgrep' or `projectile-search-review' instead.")
86718688
(let ((ag-command (if regexp 'ag-regexp 'ag))
86728689
(ag-ignore-list (delq nil
86738690
(seq-uniq
@@ -8711,7 +8728,8 @@ alone."
87118728
When REGEXP is non-nil, SEARCH-TERM is treated as a regular expression.
87128729
Requires the `rg' Emacs package, or failing that the `ripgrep' one.
87138730
`rg' comes first when both are installed: it is the maintained one of
8714-
the two, `ripgrep' having been archived by its author."
8731+
the two, `ripgrep' having been archived by its author. Support for
8732+
`ripgrep' is deprecated and goes away in Projectile 4.0."
87158733
;; we rely on the external packages rg and ripgrep for the actual search
87168734
(cond ((require 'rg nil 'noerror)
87178735
(rg-run search-term
@@ -8722,6 +8740,9 @@ the two, `ripgrep' having been archived by its author."
87228740
;; `rg' quotes these itself
87238741
(projectile--ripgrep-ignore-globs)))
87248742
((require 'ripgrep nil 'noerror)
8743+
(projectile--warn-deprecated
8744+
'ripgrep
8745+
"Support for the `ripgrep' package is deprecated and will be removed in Projectile 4.0: the package has been archived. Install the `rg' package and `projectile-ripgrep' will use that instead.")
87258746
;; `ripgrep' runs its command line through the shell, so quote
87268747
(let ((args (projectile--ripgrep-ignore-globs t)))
87278748
(ripgrep-regexp search-term
@@ -8758,9 +8779,10 @@ Use this to plug in your own search tool, e.g.:
87588779
(apply #'projectile-register-backend 'projectile-search-backends name plist))
87598780

87608781
;; Built-ins. Registered so the `auto' preference favours ripgrep, then grep
8761-
;; (which is always available); ag is only used when explicitly selected.
8782+
;; (which is always available); ag is only used when explicitly selected,
8783+
;; and is deprecated.
87628784
(projectile-register-search-backend 'ag
8763-
:description "the Silver Searcher (ag)"
8785+
:description "the Silver Searcher (ag, deprecated)"
87648786
:available (lambda () (require 'ag nil 'noerror))
87658787
:search #'projectile--ag)
87668788
(projectile-register-search-backend 'grep
@@ -8823,7 +8845,10 @@ With REGEXP given, don't query the user for a regexp."
88238845
This is `projectile-search' with the ag backend.
88248846

88258847
With an optional prefix argument ARG SEARCH-TERM is interpreted as a
8826-
regular expression."
8848+
regular expression.
8849+
8850+
This command is obsolete: The Silver Searcher is no longer maintained.
8851+
Use `projectile-ripgrep' or `projectile-search-review' instead."
88278852
(interactive
88288853
(list (projectile--read-search-string-with-default
88298854
(format "Search %s%s for"
@@ -8833,6 +8858,8 @@ regular expression."
88338858
(let ((projectile-search-backend 'ag))
88348859
(projectile-search search-term arg)))
88358860

8861+
(make-obsolete 'projectile-ag 'projectile-ripgrep "3.5.0")
8862+
88368863
;;;###autoload
88378864
(defun projectile-ripgrep (search-term &optional arg)
88388865
"Run a ripgrep (rg) search with SEARCH-TERM in the project.
@@ -8841,8 +8868,9 @@ This is `projectile-search' with the ripgrep backend.
88418868
With an optional prefix argument ARG SEARCH-TERM is interpreted as a
88428869
regular expression.
88438870

8844-
This command depends on the Emacs packages ripgrep or rg being
8845-
installed to work."
8871+
This command depends on the Emacs package rg being installed to work.
8872+
The ripgrep package is still accepted in its place, but support for it
8873+
is deprecated."
88468874
(interactive
88478875
(list (projectile--read-search-string-with-default
88488876
(format "Search %s%s for"
@@ -17224,7 +17252,9 @@ Magit that don't trigger `find-file-hook'."
1722417252
(define-key map (kbd "s s") #'projectile-search)
1722517253
(define-key map (kbd "s g") #'projectile-grep)
1722617254
(define-key map (kbd "s r") #'projectile-ripgrep)
17227-
(define-key map (kbd "s a") #'projectile-ag)
17255+
;; obsolete, but it keeps its key until it is removed in 4.0
17256+
(with-suppressed-warnings ((obsolete projectile-ag))
17257+
(define-key map (kbd "s a") #'projectile-ag))
1722817258
(define-key map (kbd "s x") #'projectile-find-references)
1722917259
(define-key map (kbd "s R") #'projectile-search-review)
1723017260
(define-key map (kbd "s X") #'projectile-search-regexp-review)
@@ -17451,8 +17481,11 @@ PROPS is a plist of:
1745117481
;; Regexp search
1745217482
(projectile-dispatch--define projectile-dispatch-search projectile-search
1745317483
:prefix-arg "--regexp")
17454-
(projectile-dispatch--define projectile-dispatch-ag projectile-ag
17455-
:prefix-arg "--regexp")
17484+
;; `projectile-ag' is obsolete, and so is its wrapper; both stay until 4.0
17485+
(with-suppressed-warnings ((obsolete projectile-ag))
17486+
(projectile-dispatch--define projectile-dispatch-ag projectile-ag
17487+
:prefix-arg "--regexp"))
17488+
(make-obsolete 'projectile-dispatch-ag 'projectile-dispatch-ripgrep "3.5.0")
1745617489
(projectile-dispatch--define projectile-dispatch-ripgrep projectile-ripgrep
1745717490
:prefix-arg "--regexp")
1745817491

@@ -17579,7 +17612,7 @@ search/replace case-sensitive, `--word' makes it match whole words,
1757917612
("ss" "search" projectile-dispatch-search)
1758017613
("sg" "grep" projectile-grep)
1758117614
("sr" "ripgrep" projectile-dispatch-ripgrep)
17582-
("sa" "ag" projectile-dispatch-ag)
17615+
("sa" "ag (deprecated)" projectile-dispatch-ag)
1758317616
("sx" "references" projectile-find-references)
1758417617
("sR" "search (review)" projectile-dispatch-search-review)
1758517618
("ns" "search siblings" projectile-dispatch-search-siblings)
@@ -17734,7 +17767,7 @@ search/replace case-sensitive, `--word' makes it match whole words,
1773417767
["Search (default backend)" projectile-search]
1773517768
["Search with grep" projectile-grep]
1773617769
["Search with ripgrep" projectile-ripgrep]
17737-
["Search with ag" projectile-ag]
17770+
["Search with ag (deprecated)" projectile-ag]
1773817771
["Search in sibling projects" projectile-search-in-sibling-projects]
1773917772
["TODOs in sibling projects" projectile-todos-in-sibling-projects]
1774017773
["Multi-occur in sibling projects" projectile-multi-occur-in-sibling-projects]

‎test/projectile-grep-test.el‎

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,26 @@
8181
(describe "projectile--ripgrep"
8282
(before-each
8383
(spy-on 'projectile-acquire-root :and-return-value "/my/root/")
84-
(spy-on 'projectile--ripgrep-ignore-globs :and-return-value '("--glob=!x")))
84+
(spy-on 'projectile--ripgrep-ignore-globs :and-return-value '("--glob=!x"))
85+
(spy-on 'display-warning)
86+
(setq projectile--deprecations-warned nil))
87+
88+
(it "warns once that the `ripgrep' package is on its way out"
89+
(cl-letf (((symbol-function 'require)
90+
(lambda (feature &rest _) (eq feature 'ripgrep)))
91+
((symbol-function 'ripgrep-regexp) #'ignore))
92+
(projectile--ripgrep "foo")
93+
(projectile--ripgrep "bar"))
94+
(expect 'display-warning :to-have-been-called-times 1)
95+
(expect (cadr (spy-calls-args-for 'display-warning 0))
96+
:to-match "`ripgrep' package is deprecated"))
97+
98+
(it "has nothing to warn about on the `rg' path"
99+
(cl-letf (((symbol-function 'require)
100+
(lambda (feature &rest _) (eq feature 'rg)))
101+
((symbol-function 'rg-run) #'ignore))
102+
(projectile--ripgrep "foo"))
103+
(expect 'display-warning :not :to-have-been-called))
85104

86105
(it "prefers the `rg' package when both are installed"
87106
(cl-letf (((symbol-function 'require)
@@ -120,6 +139,34 @@
120139
(projectile--ripgrep "foo" t))
121140
(expect 'projectile--ripgrep-ignore-globs :to-have-been-called-with)))
122141

142+
;; ag.el's own variable, unbound here because the package is not loaded
143+
(defvar ag-ignore-list)
144+
145+
(describe "the deprecated ag backend"
146+
(before-each
147+
(spy-on 'projectile-acquire-root :and-return-value "/my/root/")
148+
(spy-on 'projectile-project-vcs :and-return-value 'git)
149+
(spy-on 'display-warning)
150+
(setq projectile--deprecations-warned nil))
151+
152+
(it "still searches, and warns once that it is going away"
153+
(let (searched ag-ignore-list)
154+
(cl-letf (((symbol-function 'require)
155+
(lambda (feature &rest _) (eq feature 'ag)))
156+
((symbol-function 'ag)
157+
(lambda (term dir) (push (list term dir) searched))))
158+
(projectile--ag "foo")
159+
(projectile--ag "bar"))
160+
(expect (nreverse searched)
161+
:to-equal '(("foo" "/my/root/") ("bar" "/my/root/"))))
162+
(expect 'display-warning :to-have-been-called-times 1)
163+
(expect (cadr (spy-calls-args-for 'display-warning 0))
164+
:to-match "ag search backend is deprecated"))
165+
166+
(it "marks projectile-ag obsolete in favour of projectile-ripgrep"
167+
(expect (car (get 'projectile-ag 'byte-obsolete-info))
168+
:to-be 'projectile-ripgrep)))
169+
123170
(describe "projectile--ag-ignore-patterns"
124171
(it "strips the gitignore markers ag can't make sense of"
125172
(spy-on 'projectile--dirconfig-ignore

0 commit comments

Comments
 (0)