aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--projectile.el8
-rw-r--r--test/projectile-test.el27
3 files changed, 35 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9aec45a..5b00d2d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,7 @@
* [#1385](https://github.com/bbatsov/projectile/issues/1385): Update `projectile-replace` for Emacs 27.
* [#1432](https://github.com/bbatsov/projectile/issues/1432): Support .NET project.
* [#1270](https://github.com/bbatsov/projectile/issues/1270): Fix running commands that don't have a default value.
+* [#1482](https://github.com/bbatsov/projectile/issues/1482): Run a seperate grep buffer per project root
## 2.0.0 (2019-01-01)
diff --git a/projectile.el b/projectile.el
index 368f2e4..0ee15b1 100644
--- a/projectile.el
+++ b/projectile.el
@@ -3206,7 +3206,13 @@ With REGEXP given, don't query the user for a regexp."
(projectile-grep-find-unignored-patterns (projectile-patterns-to-ensure)))
(grep-compute-defaults)
(cl-letf (((symbol-function 'rgrep-default-command) #'projectile-rgrep-default-command))
- (rgrep search-regexp (or files "* .*") root-dir)))))
+ (rgrep search-regexp (or files "* .*") root-dir)
+ (when (get-buffer "*grep*")
+ ;; When grep is using a global *grep* buffer rename it to be
+ ;; scoped to the current root to allow multiple concurrent grep
+ ;; operations, one per root
+ (with-current-buffer "*grep*"
+ (rename-buffer (concat "*grep <" root-dir ">*"))))))))
(run-hooks 'projectile-grep-finished-hook)))
;;;###autoload
diff --git a/test/projectile-test.el b/test/projectile-test.el
index 0d56c57..32b915d 100644
--- a/test/projectile-test.el
+++ b/test/projectile-test.el
@@ -28,6 +28,7 @@
(require 'projectile)
(require 'buttercup)
+
(message "Running tests on Emacs %s" emacs-version)
;; TODO: Revise this init logic
@@ -643,6 +644,32 @@ You'd normally combine this with `projectile-test-with-sandbox'."
(expect (projectile-project-root) :to-equal correct-project-root))))))
(describe "projectile-grep"
+ (describe "multi-root grep"
+ (after-each
+ (cl-flet ((grep-buffer-p (b) (string-prefix-p "*grep" (buffer-name b))))
+ (let ((grep-buffers (cl-remove-if-not #'grep-buffer-p (buffer-list))))
+ (dolist (grep-buffer grep-buffers)
+ (let ((kill-buffer-query-functions nil))
+ (kill-buffer grep-buffer))))))
+ (it "grep multi-root projects"
+ (projectile-test-with-sandbox
+ (projectile-test-with-files
+ ("project/bar/"
+ "project/baz/")
+ (cd "project")
+ (with-temp-file ".projectile" (insert (concat "+/baz\n"
+ "+/bar\n")))
+ (with-temp-file "foo.txt" (insert "hi"))
+ (with-temp-file "bar/bar.txt" (insert "hi"))
+ (with-temp-file "baz/baz.txt" (insert "hi"))
+ (with-current-buffer (find-file-noselect ".projectile" t)
+ (let ((grep-find-template "<X>")
+ grep-find-ignored-directories grep-find-ignored-files
+ projectile-globally-ignored-files
+ projectile-globally-ignored-file-suffixes
+ projectile-globally-ignored-directories)
+ (projectile-grep "hi")))))))
+
(describe "rgrep"
(before-each
(spy-on 'compilation-start))